timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
kokkosp.hpp File Reference
#include "timemory/api.hpp"
#include "timemory/compat/macros.h"
#include "timemory/components/data_tracker/components.hpp"
#include "timemory/components/user_bundle/types.hpp"
#include "timemory/variadic/component_bundle.hpp"
#include <cstdint>
#include <functional>
#include <map>
#include <mutex>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
+ Include dependency graph for kokkosp.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tim::kokkosp::kernel_logger
 

Namespaces

namespace  tim
 
namespace  tim::kokkosp
 

Macros

#define TIMEMORY_KOKKOSP_PREFIX
 
#define TIMEMORY_KOKKOSP_POSTFIX   TIMEMORY_VISIBILITY("default")
 

Typedefs

using tim::kokkosp::memory_tracker = tim::component::data_tracker< int64_t, tim::project::kokkosp >
 
using tim::kokkosp::kokkos_bundle = tim::component::user_kokkosp_bundle
 
using tim::kokkosp::logger_t = tim::component_bundle_t< project::kokkosp, kokkosp::kernel_logger * >
 
template<typename... Tail>
using tim::kokkosp::profiler_t = tim::component_bundle_t< project::kokkosp, kokkosp::memory_tracker, Tail... >
 
template<typename... Tail>
using tim::kokkosp::profiler_section_t = std::tuple< std::string, profiler_t< Tail... > >
 
template<typename... Tail>
using tim::kokkosp::profiler_alloc_t = tim::auto_tuple< kokkosp::memory_tracker, Tail... >
 
template<typename... Tail>
using tim::kokkosp::profiler_stack_t = std::vector< profiler_t< Tail... > >
 
template<typename... Tail>
using tim::kokkosp::profiler_memory_map_t = std::unordered_map< string_view_t, std::unordered_map< string_view_t, profiler_t< Tail... > > >
 
template<typename... Tail>
using tim::kokkosp::profiler_index_map_t = std::unordered_map< uint64_t, profiler_t< Tail... > >
 
template<typename... Tail>
using tim::kokkosp::profiler_section_map_t = std::unordered_map< uint64_t, profiler_section_t< Tail... > >
 

Enumerations

enum  tim::kokkosp::Space {
  tim::kokkosp::SPACE_HOST ,
  tim::kokkosp::SPACE_CUDA
}
 
enum  { tim::kokkosp::NSPACES = 2 }
 

Functions

Space tim::kokkosp::get_space (const SpaceHandle &handle)
 
const char * tim::kokkosp::get_space_name (int space)
 
uint64_t tim::kokkosp::get_unique_id ()
 
std::mutex & tim::kokkosp::get_cleanup_mutex ()
 
auto & tim::kokkosp::get_cleanup ()
 
template<typename Tp >
Tp & tim::kokkosp::get_tl_static ()
 
template<typename Tp >
Tp & tim::kokkosp::get_static ()
 
void tim::kokkosp::cleanup ()
 
template<typename... Tail>
profiler_index_map_t< Tail... > & tim::kokkosp::get_profiler_index_map ()
 
template<typename... Tail>
profiler_section_map_t< Tail... > & tim::kokkosp::get_profiler_section_map ()
 
template<typename... Tail>
profiler_memory_map_t< Tail... > & tim::kokkosp::get_profiler_memory_map ()
 
template<typename... Tail>
auto & tim::kokkosp::get_profiler_memory_map (SpaceHandle _space)
 
template<typename... Tail>
profiler_stack_t< Tail... > & tim::kokkosp::get_profiler_stack ()
 
template<typename... Tail>
void tim::kokkosp::create_profiler (const std::string &pname, uint64_t kernid)
 
template<typename... Tail>
void tim::kokkosp::destroy_profiler (uint64_t kernid)
 
template<typename... Tail>
void tim::kokkosp::start_profiler (uint64_t kernid)
 
template<typename... Tail>
void tim::kokkosp::stop_profiler (uint64_t kernid)
 
 TIMEMORY_DEFINE_CONCRETE_TRAIT (uses_memory_units, kokkosp::memory_tracker, std::true_type) TIMEMORY_DEFINE_CONCRETE_TRAIT(is_memory_category
 
std::true_type void kokkosp_print_help (char *argv0)
 
void kokkosp_parse_args (int argc, char **argv)
 
void kokkosp_declare_metadata (const char *key, const char *value)
 
void kokkosp_init_library (const int loadSeq, const uint64_t interfaceVer, const uint32_t devInfoCount, void *deviceInfo)
 
void kokkosp_finalize_library ()
 
void kokkosp_begin_parallel_for (const char *name, uint32_t devid, uint64_t *kernid)
 
void kokkosp_end_parallel_for (uint64_t kernid)
 
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_end_parallel_scan (uint64_t kernid)
 
void kokkosp_begin_fence (const char *name, uint32_t devid, uint64_t *kernid)
 
void kokkosp_end_fence (uint64_t kernid)
 
void kokkosp_push_profile_region (const char *name)
 
void kokkosp_pop_profile_region ()
 
void kokkosp_create_profile_section (const char *name, uint32_t *secid)
 
void kokkosp_destroy_profile_section (uint32_t secid)
 
void kokkosp_start_profile_section (uint32_t secid)
 
void kokkosp_stop_profile_section (uint32_t secid)
 
void kokkosp_allocate_data (const SpaceHandle space, const char *label, const void *const ptr, const uint64_t size)
 
void kokkosp_deallocate_data (const SpaceHandle space, const char *label, const void *const ptr, const uint64_t size)
 
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_end_deep_copy ()
 
void kokkosp_profile_event (const char *name)
 

Macro Definition Documentation

◆ TIMEMORY_KOKKOSP_POSTFIX

#define TIMEMORY_KOKKOSP_POSTFIX   TIMEMORY_VISIBILITY("default")

Definition at line 55 of file kokkosp.hpp.

◆ TIMEMORY_KOKKOSP_PREFIX

#define TIMEMORY_KOKKOSP_PREFIX

Definition at line 46 of file kokkosp.hpp.

Function Documentation

◆ kokkosp_allocate_data()

void kokkosp_allocate_data ( const SpaceHandle  space,
const char *  label,
const void *const  ptr,
const uint64_t  size 
)

Definition at line 309 of file kokkosp.cpp.

311 {
312 kokkosp::logger_t{}.mark(0, __FUNCTION__, space.name, label,
313 TIMEMORY_JOIN("", '[', ptr, ']'), size);
314 kokkosp::profiler_alloc_t<>{ TIMEMORY_JOIN('/', "kokkos/allocate", space.name,
315 label) }
316 .store(std::plus<int64_t>{}, size);
317 }
This is a variadic component wrapper where all components are allocated on the stack and cannot be di...
Definition: auto_tuple.hpp:65
tim::component_bundle_t< project::kokkosp, kokkosp::kernel_logger * > logger_t
Definition: kokkosp.hpp:244
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

References TIMEMORY_JOIN.

◆ kokkosp_begin_deep_copy()

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 
)

Definition at line 331 of file kokkosp.cpp.

334 {
335 kokkosp::logger_t{}.mark(1, __FUNCTION__, dst_handle.name, dst_name,
336 TIMEMORY_JOIN("", '[', dst_ptr, ']'), src_handle.name,
337 src_name, TIMEMORY_JOIN("", '[', src_ptr, ']'), size);
338
339 auto name = TIMEMORY_JOIN('/', "kokkos/deep_copy",
340 TIMEMORY_JOIN('=', dst_handle.name, dst_name),
341 TIMEMORY_JOIN('=', src_handle.name, src_name));
342
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,
346 size);
347 _data.back().start();
348 _data.back().store(std::plus<int64_t>{}, size);
349 }

References TIMEMORY_JOIN.

◆ kokkosp_begin_fence()

void kokkosp_begin_fence ( const char *  name,
uint32_t  devid,
uint64_t *  kernid 
)

Definition at line 241 of file kokkosp.cpp.

242 {
243 auto pname =
244 (devid > std::numeric_limits<uint16_t>::max()) // junk device number
245 ? TIMEMORY_JOIN('/', "kokkos", name)
246 : TIMEMORY_JOIN('/', "kokkos", TIMEMORY_JOIN("", "dev", devid), name);
247 *kernid = kokkosp::get_unique_id();
248 kokkosp::logger_t{}.mark(1, __FUNCTION__, name, *kernid);
249 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
250 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
251 }
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320
uint64_t get_unique_id()
Definition: kokkosp.hpp:121

References tim::kokkosp::get_unique_id(), std::max(), and TIMEMORY_JOIN.

◆ kokkosp_begin_parallel_for()

void kokkosp_begin_parallel_for ( const char *  name,
uint32_t  devid,
uint64_t *  kernid 
)

Definition at line 178 of file kokkosp.cpp.

179 {
180 auto pname =
181 (devid > std::numeric_limits<uint16_t>::max()) // junk device number
182 ? TIMEMORY_JOIN('/', "kokkos", name)
183 : TIMEMORY_JOIN('/', "kokkos", TIMEMORY_JOIN("", "dev", devid), name);
184 *kernid = kokkosp::get_unique_id();
185 kokkosp::logger_t{}.mark(1, __FUNCTION__, name, *kernid);
186 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
187 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
188 }

References tim::kokkosp::get_unique_id(), std::max(), and TIMEMORY_JOIN.

◆ kokkosp_begin_parallel_reduce()

void kokkosp_begin_parallel_reduce ( const char *  name,
uint32_t  devid,
uint64_t *  kernid 
)

Definition at line 199 of file kokkosp.cpp.

200 {
201 auto pname =
202 (devid > std::numeric_limits<uint16_t>::max()) // junk device number
203 ? TIMEMORY_JOIN('/', "kokkos", name)
204 : TIMEMORY_JOIN('/', "kokkos", TIMEMORY_JOIN("", "dev", devid), name);
205 *kernid = kokkosp::get_unique_id();
206 kokkosp::logger_t{}.mark(1, __FUNCTION__, name, *kernid);
207 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
208 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
209 }

References tim::kokkosp::get_unique_id(), std::max(), and TIMEMORY_JOIN.

◆ kokkosp_begin_parallel_scan()

void kokkosp_begin_parallel_scan ( const char *  name,
uint32_t  devid,
uint64_t *  kernid 
)

Definition at line 220 of file kokkosp.cpp.

221 {
222 auto pname =
223 (devid > std::numeric_limits<uint16_t>::max()) // junk device number
224 ? TIMEMORY_JOIN('/', "kokkos", name)
225 : TIMEMORY_JOIN('/', "kokkos", TIMEMORY_JOIN("", "dev", devid), name);
226 *kernid = kokkosp::get_unique_id();
227 kokkosp::logger_t{}.mark(1, __FUNCTION__, name, *kernid);
228 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *kernid);
229 kokkosp::start_profiler<kokkosp::kokkos_bundle>(*kernid);
230 }

References tim::kokkosp::get_unique_id(), std::max(), and TIMEMORY_JOIN.

◆ kokkosp_create_profile_section()

void kokkosp_create_profile_section ( const char *  name,
uint32_t *  secid 
)

Definition at line 281 of file kokkosp.cpp.

282 {
283 *secid = kokkosp::get_unique_id();
284 auto pname = TIMEMORY_JOIN('/', "kokkos", name);
285 kokkosp::create_profiler<kokkosp::kokkos_bundle>(pname, *secid);
286 }

References tim::kokkosp::get_unique_id(), and TIMEMORY_JOIN.

◆ kokkosp_deallocate_data()

void kokkosp_deallocate_data ( const SpaceHandle  space,
const char *  label,
const void *const  ptr,
const uint64_t  size 
)

Definition at line 319 of file kokkosp.cpp.

321 {
322 kokkosp::logger_t{}.mark(0, __FUNCTION__, space.name, label,
323 TIMEMORY_JOIN("", '[', ptr, ']'), size);
324 kokkosp::profiler_alloc_t<>{ TIMEMORY_JOIN('/', "kokkos/deallocate", space.name,
325 label) }
326 .store(std::plus<int64_t>{}, size);
327 }

References TIMEMORY_JOIN.

◆ kokkosp_declare_metadata()

void kokkosp_declare_metadata ( const char *  key,
const char *  value 
)

Definition at line 123 of file kokkosp.cpp.

124 {
125 tim::manager::add_metadata(key, value);
126 }
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...
Definition: manager.hpp:479

References tim::manager::add_metadata().

◆ kokkosp_destroy_profile_section()

void kokkosp_destroy_profile_section ( uint32_t  secid)

Definition at line 288 of file kokkosp.cpp.

289 {
290 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(secid);
291 }

◆ kokkosp_end_deep_copy()

void kokkosp_end_deep_copy ( )

Definition at line 351 of file kokkosp.cpp.

352 {
353 kokkosp::logger_t{}.mark(-1, __FUNCTION__);
354 auto& _data = kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>();
355 if(_data.empty())
356 return;
357 _data.back().store(std::minus<int64_t>{}, 0);
358 _data.back().stop();
359 _data.pop_back();
360 }

◆ kokkosp_end_fence()

void kokkosp_end_fence ( uint64_t  kernid)

Definition at line 253 of file kokkosp.cpp.

254 {
255 kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid);
256 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
257 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
258 }

◆ kokkosp_end_parallel_for()

void kokkosp_end_parallel_for ( uint64_t  kernid)

Definition at line 190 of file kokkosp.cpp.

191 {
192 kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid);
193 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
194 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
195 }

◆ kokkosp_end_parallel_reduce()

void kokkosp_end_parallel_reduce ( uint64_t  kernid)

Definition at line 211 of file kokkosp.cpp.

212 {
213 kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid);
214 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
215 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
216 }

◆ kokkosp_end_parallel_scan()

void kokkosp_end_parallel_scan ( uint64_t  kernid)

Definition at line 232 of file kokkosp.cpp.

233 {
234 kokkosp::logger_t{}.mark(-1, __FUNCTION__, kernid);
235 kokkosp::stop_profiler<kokkosp::kokkos_bundle>(kernid);
236 kokkosp::destroy_profiler<kokkosp::kokkos_bundle>(kernid);
237 }

◆ kokkosp_finalize_library()

void kokkosp_finalize_library ( )

Definition at line 165 of file kokkosp.cpp.

166 {
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());
170
172
174 }
void cleanup()
Definition: kokkosp.hpp:187
void timemory_finalize()
finalization of the specified types

References tim::kokkosp::cleanup(), and tim::timemory_finalize().

◆ kokkosp_init_library()

void kokkosp_init_library ( const int  loadSeq,
const uint64_t  interfaceVer,
const uint32_t  devInfoCount,
void *  deviceInfo 
)

Definition at line 128 of file kokkosp.cpp.

130 {
131 add_kernel_logger();
132
133 tim::consume_parameters(devInfoCount, deviceInfo);
134
135 tim::set_env("TIMEMORY_TIME_OUTPUT", "ON", 0);
136 tim::set_env("TIMEMORY_COUT_OUTPUT", "OFF", 0);
137 tim::set_env("TIMEMORY_ADD_SECONDARY", "OFF", 0);
138
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());
143
144 if(tim::settings::output_path() == "timemory-output")
145 {
146 // timemory_init is expecting some args so generate some
147 std::array<char*, 1> cstr = { { strdup("kokkosp") } };
148 tim::timemory_init(1, cstr.data());
149 free(cstr[0]);
150 }
151 assert(env_configured);
152
153 // search unique and fallback environment variables
154 namespace operation = tim::operation;
155 operation::init<kokkosp::kokkos_bundle>(
156 operation::mode_constant<operation::init_mode::global>{});
157
158 // add at least one
159 if(kokkosp::kokkos_bundle::bundle_size() == 0)
160 kokkosp::kokkos_bundle::configure<tim::component::wall_clock>();
161
162 setup_kernel_logger();
163 }
void set_env(const std::string &env_var, const Tp &_val, int override)
void timemory_init(Args &&... _args)
Definition: config.hpp:49
output_path
Definition: settings.cpp:1661
void consume_parameters(ArgsT &&...)
Definition: types.hpp:285
char * strdup(const char *s)
Definition: timemory_c.c:41

References tim::consume_parameters(), tim::output_path, tim::set_env(), strdup(), and tim::timemory_init().

◆ kokkosp_parse_args()

void kokkosp_parse_args ( int  argc,
char **  argv 
)

Definition at line 107 of file kokkosp.cpp.

108 {
109 add_kernel_logger();
110
112
113 std::vector<std::string> _args{};
114 _args.reserve(argc);
115 for(int i = 0; i < argc; ++i)
116 _args.emplace_back(argv[i]);
117
119
120 setup_kernel_logger();
121 }
std::array< char *, 4 > _args
timemory_argparse(argc, argv)
char ** argv
Definition: config.cpp:55

References tim::_args, tim::argv, tim::timemory_argparse(), and tim::timemory_init().

◆ kokkosp_pop_profile_region()

void kokkosp_pop_profile_region ( )

Definition at line 270 of file kokkosp.cpp.

271 {
272 kokkosp::logger_t{}.mark(-1, __FUNCTION__);
273 if(kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().empty())
274 return;
275 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().back().stop();
276 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().pop_back();
277 }

◆ kokkosp_print_help()

std::true_type void kokkosp_print_help ( char *  argv0)

Definition at line 100 of file kokkosp.cpp.

101 {
102 add_kernel_logger();
103 std::vector<std::string> _args = { argv, "--help" };
105 }

References tim::_args, tim::argv, and tim::timemory_argparse().

◆ kokkosp_profile_event()

void kokkosp_profile_event ( const char *  name)

Definition at line 364 of file kokkosp.cpp.

365 {
367 }
tim::component_bundle_t< project::kokkosp, kokkosp::memory_tracker, Tail... > profiler_t
Definition: kokkosp.hpp:248

◆ kokkosp_push_profile_region()

void kokkosp_push_profile_region ( const char *  name)

Definition at line 262 of file kokkosp.cpp.

263 {
264 kokkosp::logger_t{}.mark(1, __FUNCTION__, name);
265 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().push_back(
267 kokkosp::get_profiler_stack<kokkosp::kokkos_bundle>().back().start();
268 }

◆ kokkosp_start_profile_section()

void kokkosp_start_profile_section ( uint32_t  secid)

Definition at line 295 of file kokkosp.cpp.

296 {
297 kokkosp::logger_t{}.mark(1, __FUNCTION__, secid);
298 kokkosp::start_profiler<kokkosp::kokkos_bundle>(secid);
299 }

◆ kokkosp_stop_profile_section()

void kokkosp_stop_profile_section ( uint32_t  secid)

Definition at line 301 of file kokkosp.cpp.

302 {
303 kokkosp::logger_t{}.mark(-1, __FUNCTION__, secid);
304 kokkosp::start_profiler<kokkosp::kokkos_bundle>(secid);
305 }

◆ TIMEMORY_DEFINE_CONCRETE_TRAIT()

TIMEMORY_DEFINE_CONCRETE_TRAIT ( uses_memory_units  ,
kokkosp::memory_tracker  ,
std::true_type   
)