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.
timemory.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to
9// deal in the Software without restriction, including without limitation the
10// rights to use, copy, modify, merge, publish, distribute, sublicense, and
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23// IN THE SOFTWARE.
24
25/** \file timemory/timemory.hpp
26 * \headerfile timemory/timemory.hpp "timemory/timemory.hpp"
27 * All-inclusive timemory header
28 *
29 */
30
31#pragma once
32
33#if defined(DISABLE_TIMEMORY) || defined(TIMEMORY_DISABLED) || \
34 (defined(TIMEMORY_ENABLED) && TIMEMORY_ENABLED == 0)
35
36# include <ostream>
37# include <string>
38
39namespace tim
40{
41template <typename... ArgsT>
42void
43timemory_init(ArgsT...)
44{}
45inline void
47{}
48inline void
50{}
51
52/// this provides "functionality" for *_HANDLE macros
53/// and can be omitted if these macros are not utilized
54struct dummy
55{
56 template <typename... Types, typename... ArgsT>
57 static void configure(ArgsT&&...)
58 {}
59
60 template <typename... ArgsT>
61 dummy(ArgsT&&...)
62 {}
63 ~dummy() = default;
64 dummy(const dummy&) = default;
65 dummy(dummy&&) = default;
66 dummy& operator=(const dummy&) = default;
67 dummy& operator=(dummy&&) = default;
68
69 void start() {}
70 void stop() {}
71 void report_at_exit(bool) {}
72 template <typename... ArgsT>
73 void mark_begin(ArgsT&&...)
74 {}
75 template <typename... ArgsT>
76 void mark_end(ArgsT&&...)
77 {}
78 friend std::ostream& operator<<(std::ostream& os, const dummy&) { return os; }
79};
80} // namespace tim
81
82# if !defined(TIMEMORY_MACROS)
83# define TIMEMORY_MACROS
84# endif
85
86// startup/shutdown/configure
87# if !defined(TIMEMORY_INIT)
88# define TIMEMORY_INIT(...)
89# endif
90
91# if !defined(TIMEMORY_FINALIZE)
92# define TIMEMORY_FINALIZE()
93# endif
94
95# if !defined(TIMEMORY_CONFIGURE)
96# define TIMEMORY_CONFIGURE(...)
97# endif
98
99// label creation
100# if !defined(TIMEMORY_BASIC_LABEL)
101# define TIMEMORY_BASIC_LABEL(...) std::string("")
102# endif
103
104# if !defined(TIMEMORY_LABEL)
105# define TIMEMORY_LABEL(...) std::string("")
106# endif
107
108# if !defined(TIMEMORY_JOIN)
109# define TIMEMORY_JOIN(...) std::string("")
110# endif
111
112// define an object
113# if !defined(TIMEMORY_BLANK_MARKER)
114# define TIMEMORY_BLANK_MARKER(...)
115# endif
116
117# if !defined(TIMEMORY_BASIC_MARKER)
118# define TIMEMORY_BASIC_MARKER(...)
119# endif
120
121# if !defined(TIMEMORY_MARKER)
122# define TIMEMORY_MARKER(...)
123# endif
124
125// define an unique pointer object
126# if !defined(TIMEMORY_BLANK_POINTER)
127# define TIMEMORY_BLANK_POINTER(...)
128# endif
129
130# if !defined(TIMEMORY_BASIC_POINTER)
131# define TIMEMORY_BASIC_POINTER(...)
132# endif
133
134# if !defined(TIMEMORY_POINTER)
135# define TIMEMORY_POINTER(...)
136# endif
137
138// define an object with a caliper reference
139# if !defined(TIMEMORY_BLANK_CALIPER)
140# define TIMEMORY_BLANK_CALIPER(...)
141# endif
142
143# if !defined(TIMEMORY_BASIC_CALIPER)
144# define TIMEMORY_BASIC_CALIPER(...)
145# endif
146
147# if !defined(TIMEMORY_CALIPER)
148# define TIMEMORY_CALIPER(...)
149# endif
150
151// define a static object with a caliper reference
152# if !defined(TIMEMORY_STATIC_BLANK_CALIPER)
153# define TIMEMORY_STATIC_BLANK_CALIPER(...)
154# endif
155
156# if !defined(TIMEMORY_STATIC_BASIC_CALIPER)
157# define TIMEMORY_STATIC_BASIC_CALIPER(...)
158# endif
159
160# if !defined(TIMEMORY_STATIC_CALIPER)
161# define TIMEMORY_STATIC_CALIPER(...)
162# endif
163
164// invoke member function on caliper reference or type within reference
165# if !defined(TIMEMORY_CALIPER_APPLY)
166# define TIMEMORY_CALIPER_APPLY(...)
167# endif
168
169# if !defined(TIMEMORY_CALIPER_TYPE_APPLY)
170# define TIMEMORY_CALIPER_TYPE_APPLY(...)
171# endif
172
173# if !defined(TIMEMORY_CALIPER_APPLY0)
174# define TIMEMORY_CALIPER_APPLY0(...)
175# endif
176
177# if !defined(TIMEMORY_CALIPER_TYPE_APPLY0)
178# define TIMEMORY_CALIPER_TYPE_APPLY0(...)
179# endif
180
181# if !defined(TIMEMORY_CALIPER_LAMBDA)
182# define TIMEMORY_CALIPER_LAMBDA(...)
183# endif
184
185# if !defined(TIMEMORY_CALIPER_TYPE_LAMBDA)
186# define TIMEMORY_CALIPER_TYPE_LAMBDA(...)
187# endif
188
189// get an object
190# if !defined(TIMEMORY_BLANK_HANDLE)
191# define TIMEMORY_BLANK_HANDLE(...) tim::dummy()
192# endif
193
194# if !defined(TIMEMORY_BASIC_HANDLE)
195# define TIMEMORY_BASIC_HANDLE(...) tim::dummy()
196# endif
197
198# if !defined(TIMEMORY_HANDLE)
199# define TIMEMORY_HANDLE(...) tim::dummy()
200# endif
201
202// get a pointer to an object
203# if !defined(TIMEMORY_BLANK_RAW_POINTER)
204# define TIMEMORY_BLANK_RAW_POINTER(...) nullptr
205# endif
206
207# if !defined(TIMEMORY_BASIC_RAW_POINTER)
208# define TIMEMORY_BASIC_RAW_POINTER(...) nullptr
209# endif
210
211# if !defined(TIMEMORY_RAW_POINTER)
212# define TIMEMORY_RAW_POINTER(...) nullptr
213# endif
214
215// debug only
216# if !defined(TIMEMORY_DEBUG_BLANK_MARKER)
217# define TIMEMORY_DEBUG_BLANK_MARKER(...)
218# endif
219
220# if !defined(TIMEMORY_DEBUG_BASIC_MARKER)
221# define TIMEMORY_DEBUG_BASIC_MARKER(...)
222# endif
223
224# if !defined(TIMEMORY_DEBUG_MARKER)
225# define TIMEMORY_DEBUG_MARKER(...)
226# endif
227
228// auto-timers
229# if !defined(TIMEMORY_BLANK_AUTO_TIMER)
230# define TIMEMORY_BLANK_AUTO_TIMER(...)
231# endif
232
233# if !defined(TIMEMORY_BASIC_AUTO_TIMER)
234# define TIMEMORY_BASIC_AUTO_TIMER(...)
235# endif
236
237# if !defined(TIMEMORY_AUTO_TIMER)
238# define TIMEMORY_AUTO_TIMER(...)
239# endif
240
241# if !defined(TIMEMORY_BLANK_AUTO_TIMER_HANDLE)
242# define TIMEMORY_BLANK_AUTO_TIMER_HANDLE(...)
243# endif
244
245# if !defined(TIMEMORY_BASIC_AUTO_TIMER_HANDLE)
246# define TIMEMORY_BASIC_AUTO_TIMER_HANDLE(...)
247# endif
248
249# if !defined(TIMEMORY_AUTO_TIMER_HANDLE)
250# define TIMEMORY_AUTO_TIMER_HANDLE(...)
251# endif
252
253# if !defined(TIMEMORY_DEBUG_BASIC_AUTO_TIMER)
254# define TIMEMORY_DEBUG_BASIC_AUTO_TIMER(...)
255# endif
256
257# if !defined(TIMEMORY_DEBUG_AUTO_TIMER)
258# define TIMEMORY_DEBUG_AUTO_TIMER(...)
259# endif
260
261// auto-bundle (user-bundles)
262# if !defined(TIMEMORY_BLANK_AUTO_BUNDLE)
263# define TIMEMORY_BLANK_AUTO_BUNDLE(...)
264# endif
265
266# if !defined(TIMEMORY_BASIC_AUTO_BUNDLE)
267# define TIMEMORY_BASIC_AUTO_BUNDLE(...)
268# endif
269
270# if !defined(TIMEMORY_AUTO_BUNDLE)
271# define TIMEMORY_AUTO_BUNDLE(...)
272# endif
273
274# if !defined(TIMEMORY_BLANK_AUTO_BUNDLE_HANDLE)
275# define TIMEMORY_BLANK_AUTO_BUNDLE_HANDLE(...)
276# endif
277
278# if !defined(TIMEMORY_BASIC_AUTO_BUNDLE_HANDLE)
279# define TIMEMORY_BASIC_AUTO_BUNDLE_HANDLE(...)
280# endif
281
282# if !defined(TIMEMORY_AUTO_BUNDLE_HANDLE)
283# define TIMEMORY_AUTO_BUNDLE_HANDLE(...)
284# endif
285
286# if !defined(TIMEMORY_DEBUG_BASIC_AUTO_BUNDLE)
287# define TIMEMORY_DEBUG_BASIC_AUTO_BUNDLE(...)
288# endif
289
290# if !defined(TIMEMORY_DEBUG_AUTO_BUNDLE)
291# define TIMEMORY_DEBUG_AUTO_BUNDLE(...)
292# endif
293
294# if !defined(TIMEMORY_TOOLSET_ALIAS)
295# define TIMEMORY_TOOLSET_ALIAS(...)
296# endif
297
298# if !defined(TIMEMORY_DECLARE_COMPONENT)
299# define TIMEMORY_DECLARE_COMPONENT(...)
300# endif
301
302# if !defined(TIMEMORY_STATISTICS_TYPE)
303# define TIMEMORY_STATISTICS_TYPE(...)
304# endif
305
306# if !defined(TIMEMORY_TEMPLATE_STATISTICS_TYPE)
307# define TIMEMORY_TEMPLATE_STATISTICS_TYPE(...)
308# endif
309
310# if !defined(TIMEMORY_VARIADIC_STATISTICS_TYPE)
311# define TIMEMORY_VARIADIC_STATISTICS_TYPE(...)
312# endif
313
314# if !defined(TIMEMORY_DEFINE_CONCRETE_TRAIT)
315# define TIMEMORY_DEFINE_CONCRETE_TRAIT(...)
316# endif
317
318# if !defined(TIMEMORY_DEFINE_TEMPLATE_TRAIT)
319# define TIMEMORY_DEFINE_TEMPLATE_TRAIT(...)
320# endif
321
322# if !defined(TIMEMORY_DEFINE_VARIADIC_TRAIT)
323# define TIMEMORY_DEFINE_VARIADIC_TRAIT(...)
324# endif
325
327
328#else
329
330# if !defined(TIMEMORY_MASTER_HEADER)
331# define TIMEMORY_MASTER_HEADER
332# endif
333
334# if !defined(TIMEMORY_ENABLED)
335# define TIMEMORY_ENABLED 1
336# endif
337
338//
339// versioning header
340//
341# include "timemory/version.h"
342//
343# include "timemory/extern.hpp"
344//
345# include "timemory/api.hpp"
346# include "timemory/config.hpp"
347# include "timemory/enum.h"
348# include "timemory/general.hpp"
349# include "timemory/plotting.hpp"
350# include "timemory/types.hpp"
351# include "timemory/units.hpp"
352//
353# include "timemory/components.hpp"
354# include "timemory/containers.hpp"
355# include "timemory/ert.hpp"
356# include "timemory/settings.hpp"
357# include "timemory/utility.hpp"
358# include "timemory/variadic.hpp"
359//
360# include "timemory/definition.hpp"
361# include "timemory/runtime.hpp"
362//
363//======================================================================================//
364//
365
367#endif // ! defined(DISABLE_TIMEMORY)
void mark_begin(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:492
void stop(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:386
void mark_end(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:528
void start(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:316
std::ostream & operator<<(std::ostream &, const std::pair< T, U > &)
Definition: stl.hpp:80
Definition: kokkosp.cpp:39
void timemory_finalize()
finalization of the specified types
void print_env(std::ostream &os, FuncT &&_filter)
Print all environment queries and their values which satisfy the filter conditions.
void configure(std::initializer_list< EnumT > components, Args &&... args)
Definition: configure.hpp:50
void timemory_init(Args &&... _args)
Definition: config.hpp:49
const std::string std::ostream * os