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.
api.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 deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
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 all
15// 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 FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25#pragma once
26
28#include "timemory/defines.h"
31
32#include <type_traits>
33
34//
35// General APIs
36//
37TIMEMORY_DEFINE_NS_API(project, none) // dummy type
38TIMEMORY_DEFINE_NS_API(project, timemory) // provided by timemory API exclusively
39TIMEMORY_DEFINE_NS_API(project, python) // provided by timemory python interface
40TIMEMORY_DEFINE_NS_API(project, kokkosp) // kokkos profiling API
41//
42// Device APIs
43//
44TIMEMORY_DECLARE_NS_API(device, cpu) // collects data on CPU
45TIMEMORY_DECLARE_NS_API(device, gpu) // collects data on GPU
46//
47// Category APIs
48//
49TIMEMORY_DEFINE_NS_API(category, debugger) // provided debugging utilities
50TIMEMORY_DEFINE_NS_API(category, decorator) // decorates external profiler
51TIMEMORY_DEFINE_NS_API(category, external) // relies on external package
52TIMEMORY_DEFINE_NS_API(category, io) // collects I/O data
53TIMEMORY_DEFINE_NS_API(category, logger) // logs generic data or messages
54TIMEMORY_DEFINE_NS_API(category, hardware_counter) // collects HW counter data
55TIMEMORY_DEFINE_NS_API(category, memory) // collects memory data
56TIMEMORY_DEFINE_NS_API(category, resource_usage) // collects resource usage data
57TIMEMORY_DEFINE_NS_API(category, timing) // collects timing data
58TIMEMORY_DEFINE_NS_API(category, visualization) // related to viz (currently unused)
59//
60// External Third-party library APIs
61//
63TIMEMORY_DEFINE_NS_API(tpls, caliper)
65TIMEMORY_DEFINE_NS_API(tpls, gotcha)
66TIMEMORY_DEFINE_NS_API(tpls, gperftools)
67TIMEMORY_DEFINE_NS_API(tpls, intel)
69TIMEMORY_DEFINE_NS_API(tpls, nvidia)
71TIMEMORY_DEFINE_NS_API(tpls, rocm)
74//
75// OS-specific APIs
76//
78TIMEMORY_DEFINE_NS_API(os, supports_unix)
79TIMEMORY_DEFINE_NS_API(os, supports_linux)
80TIMEMORY_DEFINE_NS_API(os, supports_darwin)
81TIMEMORY_DEFINE_NS_API(os, supports_windows)
82//
83//--------------------------------------------------------------------------------------//
84//
85TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, project::timemory, true_type)
86TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, project::python, true_type)
87//
88TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::debugger, true_type)
89TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::decorator, true_type)
90TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::external, true_type)
91TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::io, true_type)
92TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::logger, true_type)
93TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::hardware_counter,
94 true_type)
95TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::resource_usage,
96 true_type)
97TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::timing, true_type)
98TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, category::visualization,
99 true_type)
100//
101TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::allinea, true_type)
102TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::caliper, true_type)
103TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::craypat, true_type)
104TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::gotcha, true_type)
105TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::gperftools, true_type)
106TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::intel, true_type)
107TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::likwid, true_type)
108TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::nvidia, true_type)
109TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::openmp, true_type)
110TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::papi, true_type)
111TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, tpls::tau, true_type)
112//
113namespace tim
114{
115namespace api
116{
117using native_tag = project::timemory;
118}
119//
120namespace trait
121{
122//
123#if !defined(TIMEMORY_UNIX)
124template <>
125struct is_available<os::supports_unix> : false_type
126{};
127#endif
128//
129#if !defined(TIMEMORY_LINUX)
130template <>
131struct is_available<os::supports_linux> : false_type
132{};
133#endif
134//
135#if !defined(TIMEMORY_MACOS)
136template <>
137struct is_available<os::supports_darwin> : false_type
138{};
139#endif
140//
141#if !defined(TIMEMORY_WINDOWS)
142template <>
143struct is_available<os::supports_windows> : false_type
144{};
145#endif
146//
147} // namespace trait
148//
149} // namespace tim
150//
151//--------------------------------------------------------------------------------------//
152//
153namespace tim
154{
155namespace cereal
156{
157class JSONInputArchive;
158class XMLInputArchive;
159class XMLOutputArchive;
160} // namespace cereal
161} // namespace tim
162//
163//--------------------------------------------------------------------------------------//
164//
165// Default pre-processor settings
166//
167//--------------------------------------------------------------------------------------//
168//
169
170#if !defined(TIMEMORY_DEFAULT_API)
171# define TIMEMORY_DEFAULT_API ::tim::project::timemory
172#endif
173
174#if !defined(TIMEMORY_API)
175# define TIMEMORY_API TIMEMORY_DEFAULT_API
176#endif
177
178#if defined(DISABLE_TIMEMORY) || defined(TIMEMORY_DISABLED)
179# if !defined(TIMEMORY_DEFAULT_AVAILABLE)
180# define TIMEMORY_DEFAULT_AVAILABLE false_type
181# endif
182#else
183# if !defined(TIMEMORY_DEFAULT_AVAILABLE)
184# define TIMEMORY_DEFAULT_AVAILABLE true_type
185# endif
186#endif
187
188#if !defined(TIMEMORY_DEFAULT_STATISTICS_TYPE)
189# if defined(TIMEMORY_USE_STATISTICS)
190# define TIMEMORY_DEFAULT_STATISTICS_TYPE true_type
191# else
192# define TIMEMORY_DEFAULT_STATISTICS_TYPE false_type
193# endif
194#endif
195
196#if !defined(TIMEMORY_DEFAULT_PLOTTING)
197# define TIMEMORY_DEFAULT_PLOTTING false
198#endif
199
200#if !defined(TIMEMORY_DEFAULT_ENABLED)
201# define TIMEMORY_DEFAULT_ENABLED true
202#endif
203
204#if !defined(TIMEMORY_PYTHON_PLOTTER)
205# define TIMEMORY_PYTHON_PLOTTER "python"
206#endif
207
208#if !defined(TIMEMORY_DEFAULT_INPUT_ARCHIVE)
209# define TIMEMORY_DEFAULT_INPUT_ARCHIVE cereal::JSONInputArchive
210#endif
211
212#if !defined(TIMEMORY_DEFAULT_OUTPUT_ARCHIVE)
213# define TIMEMORY_DEFAULT_OUTPUT_ARCHIVE ::tim::type_list<>
214#endif
215
216#if !defined(TIMEMORY_INPUT_ARCHIVE)
217# define TIMEMORY_INPUT_ARCHIVE TIMEMORY_DEFAULT_INPUT_ARCHIVE
218#endif
219
220#if !defined(TIMEMORY_OUTPUT_ARCHIVE)
221# define TIMEMORY_OUTPUT_ARCHIVE TIMEMORY_DEFAULT_OUTPUT_ARCHIVE
222#endif
timemory kokkosp gpu decorator io hardware_counter resource_usage visualization caliper gotcha intel nvidia rocm tau supports_unix supports_darwin true_type TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable, project::python, true_type) TIMEMORY_DEFINE_CONCRETE_CONCEPT(is_runtime_configurable
TIMEMORY_DEFINE_NS_API(project, none) TIMEMORY_DEFINE_NS_API(project
timemory kokkosp TIMEMORY_DECLARE_NS_API(device, cpu) TIMEMORY_DECLARE_NS_API(device
Definition: kokkosp.cpp:39
const std::string std::ostream * os