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.
types.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/// \file timemory/components/user_bundle/types.hpp
26/// \brief Forward declaration of user_bundle components. User-bundles are similar to the
27/// classical profiling interface where the interface is fixed.
28
29#pragma once
30
31#include "timemory/api.hpp"
34#include "timemory/enum.h"
38
39#if defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_USER_BUNDLE_EXTERN)
40# define TIMEMORY_USE_USER_BUNDLE_EXTERN
41#endif
42
43#if !defined(TIMEMORY_USE_USER_BUNDLE_EXTERN) && \
44 !defined(TIMEMORY_USER_BUNDLE_SOURCE) && !defined(TIMEMORY_USER_BUNDLE_HEADER_MODE)
45# define TIMEMORY_USER_BUNDLE_HEADER_MODE
46#endif
47
48//======================================================================================//
49//
50TIMEMORY_DECLARE_TEMPLATE_COMPONENT(user_bundle, size_t Idx, typename Tag)
51//
52TIMEMORY_BUNDLE_INDEX(global_bundle_idx, 10000)
53// TIMEMORY_BUNDLE_INDEX(ompt_bundle_idx, 11110)
54TIMEMORY_BUNDLE_INDEX(mpip_bundle_idx, 11111)
55TIMEMORY_BUNDLE_INDEX(ncclp_bundle_idx, 11112)
56TIMEMORY_BUNDLE_INDEX(trace_bundle_idx, 20000)
57TIMEMORY_BUNDLE_INDEX(profiler_bundle_idx, 22000)
58TIMEMORY_BUNDLE_INDEX(kokkosp_bundle_idx, 0)
59
60namespace tim
61{
62namespace component
63{
64/// \typedef tim::component::user_bundle<global_bundle_idx, project::timemory>
65/// tim::component::user_global_bundle
66///
67/// \brief A specification of components which is used by multiple variadic bundlers and
68/// user_bundles as the fall-back set of components if their specific variable is
69/// not set. E.g. user_mpip_bundle will use this if TIMEMORY_MPIP_COMPONENTS is not
70/// specified
71using user_global_bundle = user_bundle<global_bundle_idx, project::timemory>;
72
73// these were deprecated
74using user_tuple_bundle = user_global_bundle;
75using user_list_bundle = user_global_bundle;
76
77/// \typedef tim::component::user_bundle<ompt_bundle_idx, project::timemory>
78/// tim::component::user_ompt_bundle
79///
80/// \brief Generic bundle for inserting components at runtime into OMPT call-back system.
81/// Configure via TIMEMORY_OMPT_COMPONENTS [environment], settings::ompt_components()
82/// [string], or direct insertion
83using user_ompt_bundle = user_bundle<ompt_bundle_idx, project::timemory>;
84
85/// \typedef tim::component::user_bundle<mpip_bundle_idx, project::timemory>
86/// tim::component::user_mpip_bundle
87///
88/// \brief Generic bundle for inserting components at runtime around MPI calls. Configure
89/// via TIMEMORY_MPIP_COMPONENTS [environment], settings::mpip_components() [string], or
90/// direct insertion
91using user_mpip_bundle = user_bundle<mpip_bundle_idx, project::timemory>;
92
93/// \typedef tim::component::user_bundle<ncclp_bundle_idx, project::timemory>
94/// tim::component::user_ncclp_bundle
95///
96/// \brief Generic bundle for inserting components at runtime around NCCL calls. Configure
97/// via TIMEMORY_NCCLP_COMPONENTS [environment], settings::ncclp_components() [string], or
98/// direct insertion
99using user_ncclp_bundle = user_bundle<ncclp_bundle_idx, project::timemory>;
100
101/// \typedef tim::component::user_bundle<trace_bundle_idx, project::timemory>
102/// tim::component::user_trace_bundle
103///
104/// \brief Used by `timemory-run` instrumentation tool for dynamic instrumentation
105/// at runtime and re-writing binaries with instrumentation. See `timemory-run`
106/// documentation for instructions about using this type to insert custom components.
107/// This component is also used by the Python line-tracing profiler (i.e. `python -m
108/// timemory.trace <OPTIONS> -- <CMD>`
109/// Environment variable: `TIMEMORY_TRACE_COMPONENTS`
110using user_trace_bundle = user_bundle<trace_bundle_idx, project::timemory>;
111
112/// \typedef tim::component::user_bundle<profiler_bundle_idx, project::timemory>
113/// tim::component::user_profiler_bundle
114///
115/// \brief Used by the Python function profiler, e.g. `python -m timemory.profiler
116/// <OPTIONS> -- <CMD>`
117/// Environment variable: `TIMEMORY_PROFILER_COMPONENTS`
118using user_profiler_bundle = user_bundle<profiler_bundle_idx, project::timemory>;
119
120/// \typedef tim::component::user_bundle<kokkosp_bundle_idx, project::timemory>
121/// tim::component::user_kokkosp_bundle
122///
123/// \brief Bundle used for Kokkos runtime callbacks that are built into the core library.
124/// Environment variable: `TIMEMORY_KOKKOS_COMPONENTS`
125using user_kokkosp_bundle = user_bundle<kokkosp_bundle_idx, project::kokkosp>;
126
127//
128} // namespace component
129} // namespace tim
130//
131#if defined(TIMEMORY_COMPILER_INSTRUMENTATION)
132//
133namespace tim
134{
135namespace trait
136{
137//
138template <size_t Idx, typename Tag>
139struct is_available<component::user_bundle<Idx, Tag>> : std::false_type
140{};
141//
142} // namespace trait
143} // namespace tim
144//
145#else
146//
147# if !defined(TIMEMORY_USE_OMPT)
148TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, component::user_ompt_bundle, false_type)
149# endif
150//
151# if !defined(TIMEMORY_USE_MPI) || !defined(TIMEMORY_USE_GOTCHA)
152TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, component::user_mpip_bundle, false_type)
153# endif
154//
155# if !defined(TIMEMORY_USE_NCCL) || !defined(TIMEMORY_USE_GOTCHA)
156TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, component::user_ncclp_bundle, false_type)
157# endif
158//
159#endif
160//
161//--------------------------------------------------------------------------------------//
162//
163// IS USER BUNDLE
164// REQUIRES PREFIX
165//
166//--------------------------------------------------------------------------------------//
167//
168TIMEMORY_SET_COMPONENT_API(component::user_global_bundle, project::timemory, os::agnostic)
169TIMEMORY_SET_COMPONENT_API(component::user_mpip_bundle, project::timemory,
170 os::supports_linux)
171TIMEMORY_SET_COMPONENT_API(component::user_ncclp_bundle, project::timemory,
172 os::supports_linux)
173TIMEMORY_SET_COMPONENT_API(component::user_trace_bundle, project::timemory, os::agnostic)
174TIMEMORY_SET_COMPONENT_API(component::user_profiler_bundle, project::timemory,
175 os::agnostic)
176//
177namespace tim
178{
179namespace trait
180{
181//
182template <size_t Idx, typename Type>
183struct is_user_bundle<component::user_bundle<Idx, Type>> : true_type
184{};
185//
186} // namespace trait
187//
188//--------------------------------------------------------------------------------------//
189//
190namespace concepts
191{
192//
193//--------------------------------------------------------------------------------------//
194//
195template <template <typename...> class Tuple, typename... T>
196struct has_user_bundle<Tuple<T...>>
197{
198 using type = typename mpl::get_true_types<trait::is_user_bundle, Tuple<T...>>::type;
199 static constexpr bool value = (mpl::get_tuple_size<type>::value != 0);
200};
201//
202//--------------------------------------------------------------------------------------//
203//
204} // namespace concepts
205//
206//--------------------------------------------------------------------------------------//
207//
208namespace operation
209{
210template <typename T>
211struct reset;
212//
213template <size_t Idx, typename Type>
214struct reset<component::user_bundle<Idx, Type>>
215{
216 using type = component::user_bundle<Idx, Type>;
217
219
220 template <typename... Args>
221 explicit reset(type&, Args&&...)
222 {}
223};
224} // namespace operation
225//
226//--------------------------------------------------------------------------------------//
227//
228} // namespace tim
229//
230//======================================================================================//
231//
233 "user_global_bundle", "global_bundle",
234 "user_tuple_bundle", "tuple_bundle", "user_list_bundle",
235 "list_bundle")
236//
238 "user_ompt_bundle", "ompt_bundle")
239//
241 "user_mpip_bundle", "mpip", "mpi_tools", "mpi")
242//
244 "user_ncclp_bundle", "ncclp", "nccl_tools", "nccl")
245//
247 "user_trace_bundle", "trace_bundle")
248//
250 "user_profiler_bundle", "profiler_bundle")
251//
253 "user_kokkos_bundle", "kokkos_bundle",
254 "user_kokkosp_bundle", "kokkosp_bundle")
255//
257 user_global_bundle, "user_global_bundle",
258 "Generic bundle for inserting components at runtime",
259 "Configure via TIMEMORY_GLOBAL_COMPONENTS [environment], "
260 "settings::global_components() [string], or direct insertion")
261//
263 user_ompt_bundle, "user_ompt_bundle",
264 "Generic bundle for inserting components at runtime into OMPT call-back system",
265 "Configure via TIMEMORY_OMPT_COMPONENTS [environment], "
266 "settings::ompt_components() [string], or direct insertion")
267//
269 user_mpip_bundle, "user_mpip_bundle",
270 "Generic bundle for inserting components at runtime around MPI calls",
271 "Configure via TIMEMORY_MPIP_COMPONENTS [environment], "
272 "settings::mpip_components() [string], or direct insertion")
273//
275 user_ncclp_bundle, "user_ncclp_bundle",
276 "Generic bundle for inserting components at runtime around NCCL calls",
277 "Configure via TIMEMORY_NCCLP_COMPONENTS [environment], "
278 "settings::ncclp_components() [string], or direct insertion")
279//
281 user_profiler_bundle, "user_profiler_bundle",
282 "Generic bundle for inserting components at runtime around calls when profiling (via "
283 "Python)",
284 "Configure via TIMEMORY_PROFILER_COMPONENTS [environment], "
285 "settings::profiler_components() [string], or direct insertion")
286//
288 user_trace_bundle, "user_trace_bundle",
289 "Generic bundle for inserting components at runtime around calls when tracing (via "
290 "Python or Dyninst)",
291 "Configure via TIMEMORY_TRACE_COMPONENTS [environment], "
292 "settings::trace_components() [string], or direct insertion")
293//
295 user_kokkosp_bundle, "user_kokkosp_bundle",
296 "Generic bundle for inserting components into Kokkos profiling API",
297 "Configure via TIMEMORY_KOKKOS_COMPONENTS [environment], "
298 "settings::kokkos_components() [string], or direct insertion")
#define TIMEMORY_METADATA_SPECIALIZATION(TYPE, LABEL, BASIC_DESC,...)
Specialization of the property specialization.
Definition: macros.hpp:288
#define TIMEMORY_PROPERTY_SPECIALIZATION(TYPE, ENUM, ID,...)
Specialization of the property specialization.
Definition: macros.hpp:223
TIMEMORY_DECLARE_TEMPLATE_COMPONENT(user_bundle, size_t Idx, typename Tag=TIMEMORY_API) TIMEMORY_BUNDLE_INDEX(ompt_bundle_idx
int EventTypes int EventTypes papi_array< 16 > papi_array< 8 > TIMEMORY_SET_COMPONENT_API(component::papi_vector, tpls::papi, category::external, category::hardware_counter, os::supports_linux) TIMEMORY_SET_TEMPLATE_COMPONENT_API(TIMEMORY_ESC(size_t MaxNumEvents)
false_type TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, component::perfetto_trace, false_type) TIMEMORY_PROPERTY_SPECIALIZATION(perfetto_trace
TIMEMORY_BUNDLE_INDEX(mpip_bundle_idx, 11111) TIMEMORY_BUNDLE_INDEX(ncclp_bundle_idx
#define TIMEMORY_USER_OMPT_BUNDLE
Definition: enum.h:605
#define TIMEMORY_USER_PROFILER_BUNDLE
Definition: enum.h:611
#define TIMEMORY_USER_NCCLP_BUNDLE
Definition: enum.h:602
#define TIMEMORY_USER_KOKKOSP_BUNDLE
Definition: enum.h:593
#define TIMEMORY_USER_MPIP_BUNDLE
Definition: enum.h:599
#define TIMEMORY_USER_GLOBAL_BUNDLE
Definition: enum.h:590
#define TIMEMORY_USER_TRACE_BUNDLE
Definition: enum.h:614
void reset(TupleT< Tp... > &obj, Args &&... args)
Definition: functional.cpp:599
tim::component::user_kokkosp_bundle kokkos_bundle
Definition: kokkosp.hpp:242
Definition: kokkosp.cpp:39
mpip_components
Definition: settings.cpp:1690
profiler_components
Definition: settings.cpp:1696
ompt_components
Definition: settings.cpp:1688
ncclp_components
Definition: settings.cpp:1692
for(const auto &ext :_exe_suffixes)
Definition: config.cpp:86
_args at(0)
trace_components
Definition: settings.cpp:1694
global_components
Definition: settings.cpp:1682
components
Definition: settings.cpp:1700
kokkos_components
Definition: settings.cpp:1698
static constexpr size_t value
Definition: types.hpp:922
TIMEMORY_DELETED_OBJECT(reset) template< typename... Args > explicit reset(type &obj