26#if !defined(TIMEMORY_LIBRARY_SOURCE)
27# define TIMEMORY_LIBRARY_SOURCE 1
42invoke_preinit<kokkosp::memory_tracker>(
long)
54 "#---------------------------------------------------------------------------#";
59configure_environment()
61 tim::set_env(
"KOKKOS_PROFILE_LIBRARY",
"libtimemory.so", 0);
65auto env_configured = (configure_environment(),
true);
66bool enable_kernel_logger =
false;
71 static bool _first =
true;
75 using strvec_t = std::vector<std::string>;
79 std::string{
"Enables kernel logging" }, enable_kernel_logger,
80 strvec_t({
"--timemory-kokkos-kernel-logger" }));
103 std::vector<std::string>
_args = {
argv,
"--help" };
113 std::vector<std::string>
_args{};
115 for(
int i = 0; i < argc; ++i)
120 setup_kernel_logger();
129 const uint32_t devInfoCount,
void* deviceInfo)
139 printf(
"%s\n", kokkos_banner.c_str());
140 printf(
"# KokkosP: timemory Connector (sequence is %d, version: %llu)\n", loadSeq,
141 (
unsigned long long) interfaceVer);
142 printf(
"%s\n\n", kokkos_banner.c_str());
147 std::array<char*, 1> cstr = { {
strdup(
"kokkosp") } };
151 assert(env_configured);
155 operation::init<kokkosp::kokkos_bundle>(
156 operation::mode_constant<operation::init_mode::global>{});
159 if(kokkosp::kokkos_bundle::bundle_size() == 0)
160 kokkosp::kokkos_bundle::configure<tim::component::wall_clock>();
162 setup_kernel_logger();
167 printf(
"\n%s\n", kokkos_banner.c_str());
168 printf(
"KokkosP: Finalization of timemory Connector. Complete.\n");
169 printf(
"%s\n\n", kokkos_banner.c_str());
186 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
187 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
193 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
194 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
207 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
208 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
214 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
215 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
228 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
229 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
235 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
236 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
249 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
250 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
256 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
257 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
265 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().push_back(
267 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().back().start();
273 if(kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().empty())
275 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().back().stop();
276 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().pop_back();
285 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *secid);
290 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(secid);
298 kokkosp::start_profiler<kokkosp::kokkos_bundle>(secid);
304 kokkosp::start_profiler<kokkosp::kokkos_bundle>(secid);
310 const void*
const ptr,
const uint64_t size)
316 .store(std::plus<int64_t>{}, size);
320 const void*
const ptr,
const uint64_t size)
326 .store(std::plus<int64_t>{}, size);
332 const void* dst_ptr, SpaceHandle src_handle,
333 const char* src_name,
const void* src_ptr, uint64_t size)
343 auto& _data = kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>();
344 _data.emplace_back(name);
345 _data.back().audit(dst_handle, dst_name, dst_ptr, src_handle, src_name, src_ptr,
347 _data.back().start();
348 _data.back().store(std::plus<int64_t>{}, size);
354 auto& _data = kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>();
357 _data.back().store(std::minus<int64_t>{}, 0);
This is a variadic component wrapper where all components are allocated on the stack and cannot be di...
static void add_metadata(const std::string &, const Tp &)
Add a metadata entry of a non-string type. If this fails to serialize, either include either the appr...
#define TIMEMORY_INITIALIZE_STORAGE(...)
void kokkosp_end_deep_copy()
void kokkosp_end_fence(uint64_t kernid)
void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer, const uint32_t devInfoCount, void *deviceInfo)
void kokkosp_push_profile_region(const char *name)
void kokkosp_start_profile_section(uint32_t secid)
void kokkosp_end_parallel_scan(uint64_t kernid)
void kokkosp_parse_args(int argc, char **argv)
void kokkosp_begin_parallel_reduce(const char *name, uint32_t devid, uint64_t *kernid)
void kokkosp_end_parallel_reduce(uint64_t kernid)
void kokkosp_begin_parallel_scan(const char *name, uint32_t devid, uint64_t *kernid)
void kokkosp_stop_profile_section(uint32_t secid)
void kokkosp_begin_deep_copy(SpaceHandle dst_handle, const char *dst_name, const void *dst_ptr, SpaceHandle src_handle, const char *src_name, const void *src_ptr, uint64_t size)
void kokkosp_profile_event(const char *name)
void kokkosp_pop_profile_region()
void kokkosp_finalize_library()
void kokkosp_begin_fence(const char *name, uint32_t devid, uint64_t *kernid)
void kokkosp_begin_parallel_for(const char *name, uint32_t devid, uint64_t *kernid)
void kokkosp_declare_metadata(const char *key, const char *value)
void kokkosp_create_profile_section(const char *name, uint32_t *secid)
void kokkosp_deallocate_data(const SpaceHandle space, const char *label, const void *const ptr, const uint64_t size)
void kokkosp_allocate_data(const SpaceHandle space, const char *label, const void *const ptr, const uint64_t size)
void kokkosp_destroy_profile_section(uint32_t secid)
void kokkosp_print_help(char *argv)
void kokkosp_end_parallel_for(uint64_t kernid)
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
tim::component_bundle_t< project::kokkosp, kokkosp::kernel_logger * > logger_t
tim::component_bundle_t< project::kokkosp, kokkosp::memory_tracker, Tail... > profiler_t
std::vector< string_t > strvec_t
std::array< char *, 4 > _args
void set_env(const std::string &env_var, const Tp &_val, int override)
void timemory_finalize()
finalization of the specified types
timemory_argparse(argc, argv)
void timemory_init(Args &&... _args)
tim::mpl::apply< std::string > string
void consume_parameters(ArgsT &&...)
This component is provided to facilitate data tracking. The first template parameter is the type of d...
static std::string & label()
a reference is returned here so that it can be easily updated
static std::string & description()
a reference is returned here so that it can be easily updated
auto insert(Sp &&_env, const std::string &_name, const std::string &_desc, Vp _init, Args &&... _args)
static settings * instance()
char * strdup(const char *s)
#define TIMEMORY_JOIN(delim,...)