1#ifndef STAN_MATH_REV_CORE_PROFILING_HPP
2#define STAN_MATH_REV_CORE_PROFILING_HPP
10#include <tbb/concurrent_unordered_map.h>
122 return std::hash<std::string>()(key.first)
123 ^ std::hash<std::thread::id>()(key.second);
128 return lhs.first == rhs.first && lhs.second == rhs.second;
157 :
key_({name, std::this_thread::get_id()}) {
158 profile_map::iterator p = profiles.find(
key_);
159 if (p == profiles.end()) {
164 std::ostringstream msg;
165 msg <<
"Profile '" <<
key_.first <<
"' already started!";
166 throw std::runtime_error(msg.str());
169 if (!is_constant<T>::value) {
171 [profile = this->profile_]()
mutable { profile->rev_pass_stop(); });
178 [
profile = this->profile_]()
mutable {
profile->rev_pass_start(); });
size_t start_chain_stack_size_
size_t get_num_AD_fwd_passes() const noexcept
size_t get_nochain_stack_used() const noexcept
size_t get_chain_stack_used() const noexcept
std::chrono::time_point< std::chrono::steady_clock > fwd_pass_tp_
size_t chain_stack_size_sum_
bool is_active() const noexcept
size_t get_num_rev_passes() const noexcept
size_t get_num_no_AD_fwd_passes() const noexcept
size_t n_fwd_no_AD_passes_
size_t get_num_fwd_passes() const noexcept
double get_fwd_time() const noexcept
size_t start_nochain_stack_size_
double get_rev_time() const noexcept
std::chrono::time_point< std::chrono::steady_clock > rev_pass_tp_
size_t nochain_stack_size_sum_
Class used for storing profiling information.
profile(std::string name, profile_map &profiles)
Profiles C++ lines where the object is in scope.
tbb::concurrent_unordered_map< profile_key, profile_info, internal::hash_profile_key, internal::equal_profile_key > profile_map
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
std::pair< std::string, std::thread::id > profile_key
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
std::vector< ChainableT * > var_stack_
std::vector< ChainableT * > var_nochain_stack_
static thread_local AutodiffStackStorage * instance_
bool operator()(const profile_key &lhs, const profile_key &rhs) const
std::size_t operator()(const profile_key &key) const