33#include "timemory/components/gperftools/backends.hpp"
59 return "Control switch for gperftools CPU profiler";
63 static void thread_init() { gperftools::cpu::register_thread(); }
67 if(gperftools::cpu::is_running())
69 gperftools::cpu::profiler_flush();
70 gperftools::cpu::profiler_stop();
76 if(!gperftools::cpu::is_running())
78 index = this_type::get_index()++;
79 const auto& _dmp_info = get_dmp_info();
80 bool _dmp_init = std::get<0>(_dmp_info);
81 int32_t _dmp_rank = std::get<1>(_dmp_info);
83 label() +
"_" + std::to_string(index),
".dat", _dmp_init, _dmp_rank);
84 auto ret = gperftools::cpu::profiler_start(fname);
87 fprintf(stderr,
"[gperftools_cpu_profiler]> Error starting %s...",
97 gperftools::cpu::profiler_flush();
98 gperftools::cpu::profiler_stop();
106 static std::atomic<int64_t>& get_index()
108 static std::atomic<int64_t> _instance(0);
112 using dmp_info_t = std::tuple<bool, int32_t, int32_t>;
114 static const dmp_info_t& get_dmp_info()
116 static dmp_info_t
_info{ dmp::is_initialized(), dmp::rank(), dmp::size() };
133 return "Control switch for the gperftools heap profiler";
139 if(gperftools::heap::is_running())
141 gperftools::heap::profiler_flush(
"global_finalize");
142 gperftools::heap::profiler_stop();
148 if(!gperftools::heap::is_running())
150 index = this_type::get_index()++;
152 auto ret = gperftools::heap::profiler_start(fname);
155 fprintf(stderr,
"[gperftools_heap_profiler]> Error starting %s...",
165 gperftools::heap::profiler_flush(
prefix);
166 gperftools::heap::profiler_stop();
177 static std::atomic<int64_t>& get_index()
179 static std::atomic<int64_t> _instance(0);
char const std::string & _prefix
tim::mpl::apply< std::string > string
static string_t compose_output_filename(string_t _tag, string_t _ext, bool _use_suffix=use_output_suffix(), int32_t _suffix=default_process_suffix(), bool _make_dir=false, std::string _explicit={})