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.
tim::kokkosp Namespace Reference

Classes

struct  kernel_logger
 

Typedefs

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

Enumerations

enum  Space {
  SPACE_HOST ,
  SPACE_CUDA
}
 
enum  { NSPACES = 2 }
 

Functions

Space get_space (const SpaceHandle &handle)
 
const char * get_space_name (int space)
 
uint64_t get_unique_id ()
 
std::mutex & get_cleanup_mutex ()
 
auto & get_cleanup ()
 
template<typename Tp >
Tp & get_tl_static ()
 
template<typename Tp >
Tp & get_static ()
 
void cleanup ()
 
template<typename... Tail>
profiler_index_map_t< Tail... > & get_profiler_index_map ()
 
template<typename... Tail>
profiler_section_map_t< Tail... > & get_profiler_section_map ()
 
template<typename... Tail>
profiler_memory_map_t< Tail... > & get_profiler_memory_map ()
 
template<typename... Tail>
auto & get_profiler_memory_map (SpaceHandle _space)
 
template<typename... Tail>
profiler_stack_t< Tail... > & get_profiler_stack ()
 
template<typename... Tail>
void create_profiler (const std::string &pname, uint64_t kernid)
 
template<typename... Tail>
void destroy_profiler (uint64_t kernid)
 
template<typename... Tail>
void start_profiler (uint64_t kernid)
 
template<typename... Tail>
void stop_profiler (uint64_t kernid)
 

Typedef Documentation

◆ kokkos_bundle

using tim::kokkosp::kokkos_bundle = typedef tim::component::user_kokkosp_bundle

Definition at line 242 of file kokkosp.hpp.

◆ logger_t

Definition at line 244 of file kokkosp.hpp.

◆ memory_tracker

using tim::kokkosp::memory_tracker = typedef tim::component::data_tracker<int64_t, tim::project::kokkosp>

Definition at line 241 of file kokkosp.hpp.

◆ profiler_alloc_t

template<typename... Tail>
using tim::kokkosp::profiler_alloc_t = typedef tim::auto_tuple<kokkosp::memory_tracker, Tail...>

Definition at line 254 of file kokkosp.hpp.

◆ profiler_index_map_t

template<typename... Tail>
using tim::kokkosp::profiler_index_map_t = typedef std::unordered_map<uint64_t, profiler_t<Tail...> >

Definition at line 266 of file kokkosp.hpp.

◆ profiler_memory_map_t

template<typename... Tail>
using tim::kokkosp::profiler_memory_map_t = typedef std::unordered_map<string_view_t, std::unordered_map<string_view_t, profiler_t<Tail...> >>

Definition at line 261 of file kokkosp.hpp.

◆ profiler_section_map_t

template<typename... Tail>
using tim::kokkosp::profiler_section_map_t = typedef std::unordered_map<uint64_t, profiler_section_t<Tail...> >

Definition at line 269 of file kokkosp.hpp.

◆ profiler_section_t

template<typename... Tail>
using tim::kokkosp::profiler_section_t = typedef std::tuple<std::string, profiler_t<Tail...> >

Definition at line 251 of file kokkosp.hpp.

◆ profiler_stack_t

template<typename... Tail>
using tim::kokkosp::profiler_stack_t = typedef std::vector<profiler_t<Tail...> >

Definition at line 258 of file kokkosp.hpp.

◆ profiler_t

template<typename... Tail>
using tim::kokkosp::profiler_t = typedef tim::component_bundle_t<project::kokkosp, kokkosp::memory_tracker, Tail...>

Definition at line 247 of file kokkosp.hpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NSPACES 

Definition at line 85 of file kokkosp.hpp.

86{
87 NSPACES = 2
88};

◆ Space

Enumerator
SPACE_HOST 
SPACE_CUDA 

Definition at line 77 of file kokkosp.hpp.

78{
81};

Function Documentation

◆ cleanup()

void tim::kokkosp::cleanup ( )
inline

Definition at line 187 of file kokkosp.hpp.

188{
189 get_cleanup_mutex().lock();
190 for(auto& itr : get_cleanup())
191 itr();
192 get_cleanup_mutex().unlock();
193}
auto & get_cleanup()
Definition: kokkosp.hpp:139
std::mutex & get_cleanup_mutex()
Definition: kokkosp.hpp:130

References get_cleanup(), and get_cleanup_mutex().

Referenced by kokkosp_finalize_library().

◆ create_profiler()

template<typename... Tail>
void tim::kokkosp::create_profiler ( const std::string &  pname,
uint64_t  kernid 
)
inline

Definition at line 320 of file kokkosp.hpp.

321{
322 get_profiler_index_map<Tail...>().insert({ kernid, profiler_t<Tail...>(pname) });
323}
_reported insert(_hash_id)
profiler_index_map_t< Tail... > & get_profiler_index_map()
Definition: kokkosp.hpp:275
tim::component_bundle_t< project::kokkosp, kokkosp::memory_tracker, Tail... > profiler_t
Definition: kokkosp.hpp:248

References get_profiler_index_map().

◆ destroy_profiler()

template<typename... Tail>
void tim::kokkosp::destroy_profiler ( uint64_t  kernid)
inline

Definition at line 329 of file kokkosp.hpp.

330{
331 if(get_profiler_index_map<Tail...>().find(kernid) !=
332 get_profiler_index_map<Tail...>().end())
333 get_profiler_index_map<Tail...>().erase(kernid);
334}
return _hash_map end()

References get_profiler_index_map().

◆ get_cleanup()

auto & tim::kokkosp::get_cleanup ( )
inline

Definition at line 139 of file kokkosp.hpp.

140{
141 static std::vector<std::function<void()>> _instance{};
142 return _instance;
143}

Referenced by cleanup(), get_static(), and get_tl_static().

◆ get_cleanup_mutex()

std::mutex & tim::kokkosp::get_cleanup_mutex ( )
inline

Definition at line 130 of file kokkosp.hpp.

131{
132 static std::mutex _instance;
133 return _instance;
134}

Referenced by cleanup(), get_static(), and get_tl_static().

◆ get_profiler_index_map()

template<typename... Tail>
profiler_index_map_t< Tail... > & tim::kokkosp::get_profiler_index_map ( )
inline

Definition at line 275 of file kokkosp.hpp.

276{
277 return get_tl_static<profiler_index_map_t<Tail...>>();
278}
Tp & get_tl_static()
Definition: kokkosp.hpp:149
std::unordered_map< uint64_t, profiler_t< Tail... > > profiler_index_map_t
Definition: kokkosp.hpp:266

References get_tl_static().

Referenced by create_profiler(), destroy_profiler(), start_profiler(), and stop_profiler().

◆ get_profiler_memory_map() [1/2]

template<typename... Tail>
profiler_memory_map_t< Tail... > & tim::kokkosp::get_profiler_memory_map ( )
inline

Definition at line 293 of file kokkosp.hpp.

294{
295 return get_tl_static<profiler_memory_map_t<Tail...>>();
296}
std::unordered_map< string_view_t, std::unordered_map< string_view_t, profiler_t< Tail... > > > profiler_memory_map_t
Definition: kokkosp.hpp:263

References get_tl_static().

Referenced by get_profiler_memory_map().

◆ get_profiler_memory_map() [2/2]

template<typename... Tail>
auto & tim::kokkosp::get_profiler_memory_map ( SpaceHandle  _space)
inline

Definition at line 302 of file kokkosp.hpp.

303{
304 return get_profiler_memory_map<Tail...>()[tim::string_view_t{ _space.name }];
305}
auto & get_profiler_memory_map(SpaceHandle _space)
Definition: kokkosp.hpp:302
std::string string_view_t
Definition: language.hpp:102

References get_profiler_memory_map().

◆ get_profiler_section_map()

template<typename... Tail>
profiler_section_map_t< Tail... > & tim::kokkosp::get_profiler_section_map ( )
inline

Definition at line 284 of file kokkosp.hpp.

285{
286 return get_tl_static<profiler_section_map_t<Tail...>>();
287}
std::unordered_map< uint64_t, profiler_section_t< Tail... > > profiler_section_map_t
Definition: kokkosp.hpp:269

References get_tl_static().

◆ get_profiler_stack()

template<typename... Tail>
profiler_stack_t< Tail... > & tim::kokkosp::get_profiler_stack ( )
inline

Definition at line 311 of file kokkosp.hpp.

312{
313 return get_tl_static<profiler_stack_t<Tail...>>();
314}
std::vector< profiler_t< Tail... > > profiler_stack_t
Definition: kokkosp.hpp:258

References get_tl_static().

◆ get_space()

Space tim::kokkosp::get_space ( const SpaceHandle &  handle)
inline

Definition at line 93 of file kokkosp.hpp.

94{
95 switch(handle.name[0])
96 {
97 case 'H': return SPACE_HOST;
98 case 'C': return SPACE_CUDA;
99 }
100 abort();
101 return SPACE_HOST;
102}

References SPACE_CUDA, and SPACE_HOST.

◆ get_space_name()

const char * tim::kokkosp::get_space_name ( int  space)
inline

Definition at line 107 of file kokkosp.hpp.

108{
109 switch(space)
110 {
111 case SPACE_HOST: return "HOST";
112 case SPACE_CUDA: return "CUDA";
113 }
114 abort();
115 return nullptr;
116}

References SPACE_CUDA, and SPACE_HOST.

◆ get_static()

template<typename Tp >
Tp & tim::kokkosp::get_static ( )
inline

Definition at line 169 of file kokkosp.hpp.

170{
171 // create a thread-local instance
172 static Tp _instance{};
173 // on first pass, add to cleanup
174 static bool _init = [&]() {
175 get_cleanup_mutex().lock();
176 get_cleanup().push_back([&]() { _instance.clear(); });
177 get_cleanup_mutex().unlock();
178 }();
179 consume_parameters(_init);
180
181 return _instance;
182}
void consume_parameters(ArgsT &&...)
Definition: types.hpp:285

References tim::consume_parameters(), get_cleanup(), and get_cleanup_mutex().

◆ get_tl_static()

template<typename Tp >
Tp & tim::kokkosp::get_tl_static ( )
inline

Definition at line 149 of file kokkosp.hpp.

150{
151 // create a thread-local instance
152 static thread_local Tp _instance{};
153 // on first pass, add to cleanup
154 static thread_local bool _init = [&]() {
155 get_cleanup_mutex().lock();
156 get_cleanup().push_back([&]() { _instance.clear(); });
157 get_cleanup_mutex().unlock();
158 return true;
159 }();
160 consume_parameters(_init);
161
162 return _instance;
163}

References tim::consume_parameters(), get_cleanup(), and get_cleanup_mutex().

Referenced by get_profiler_index_map(), get_profiler_memory_map(), get_profiler_section_map(), and get_profiler_stack().

◆ get_unique_id()

uint64_t tim::kokkosp::get_unique_id ( )
inline

Definition at line 121 of file kokkosp.hpp.

122{
123 static thread_local uint64_t _instance = 0;
124 return _instance++;
125}

Referenced by kokkosp_begin_fence(), kokkosp_begin_parallel_for(), kokkosp_begin_parallel_reduce(), kokkosp_begin_parallel_scan(), and kokkosp_create_profile_section().

◆ start_profiler()

template<typename... Tail>
void tim::kokkosp::start_profiler ( uint64_t  kernid)
inline

Definition at line 340 of file kokkosp.hpp.

341{
342 if(get_profiler_index_map<Tail...>().find(kernid) !=
343 get_profiler_index_map<Tail...>().end())
344 get_profiler_index_map<Tail...>().at(kernid).start();
345}
_args at(0)

References tim::at(), and get_profiler_index_map().

◆ stop_profiler()

template<typename... Tail>
void tim::kokkosp::stop_profiler ( uint64_t  kernid)
inline

Definition at line 351 of file kokkosp.hpp.

352{
353 if(get_profiler_index_map<Tail...>().find(kernid) !=
354 get_profiler_index_map<Tail...>().end())
355 get_profiler_index_map<Tail...>().at(kernid).stop();
356}

References tim::at(), and get_profiler_index_map().