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
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 components/types.hpp
26 * \headerfile components/types.hpp "timemory/components/types.hpp"
27 *
28 * This is a declaration of all the component structs.
29 * Care should be taken to make sure that this includes a minimal
30 * number of additional headers.
31 *
32 */
33
34#pragma once
35
36#include "timemory/api.hpp"
41
42#include <cstdint>
43#include <iostream>
44#include <string>
45#include <type_traits>
46
47//======================================================================================//
48//
49namespace tim
50{
51//======================================================================================//
52// components that provide implementations (i.e. HOW to record a component)
53//
54namespace component
55{
56// define this short-hand from C++14 for C++11
57template <bool B, typename T = int>
58using enable_if_t = typename std::enable_if<B, T>::type;
59
60// holder that provides nothing
61template <typename... Types>
62struct placeholder;
63
64struct nothing : base<nothing, skeleton::base>
65{};
66
67} // namespace component
68} // namespace tim
69
70//======================================================================================//
71
97
98//======================================================================================//
99
100TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::explicit_start, false_type)
101TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::explicit_stop, false_type)
102TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::no_init, false_type)
103
104//======================================================================================//
105//
106// Define tuple_size now that all type-traits have been declared
107//
108//======================================================================================//
109
110#include "timemory/mpl/available.hpp"
111
112namespace std
113{
114//
115//--------------------------------------------------------------------------------------//
116//
117template <typename... Types>
118TSTAG(struct)
119tuple_size<tim::lightweight_tuple<Types...>>
120{
121private:
122 using type = tim::stl_tuple_t<Types...>;
123
124public:
125 static constexpr size_t value = tuple_size<type>::value;
126};
127//
128//--------------------------------------------------------------------------------------//
129//
130template <typename Tag, typename... Types>
131TSTAG(struct)
132tuple_size<tim::component_bundle<Tag, Types...>>
133{
134private:
135 // component_bundle does not apply concat
136 using type = tim::convert_t<tim::mpl::available_t<tuple<Types...>>, tuple<>>;
137
138public:
139 static constexpr size_t value = tuple_size<type>::value;
140};
141//
142//--------------------------------------------------------------------------------------//
143//
144template <typename... Types>
145TSTAG(struct)
146tuple_size<tim::component_tuple<Types...>>
147{
148private:
149 using type = tim::stl_tuple_t<Types...>;
150
151public:
152 static constexpr size_t value = tuple_size<type>::value;
153};
154//
155//--------------------------------------------------------------------------------------//
156//
157template <typename... Types>
158TSTAG(struct)
159tuple_size<tim::component_list<Types...>>
160{
161private:
162 using type = tim::stl_tuple_t<Types...>;
163
164public:
165 static constexpr size_t value = tuple_size<type>::value;
166};
167//
168//--------------------------------------------------------------------------------------//
169//
170template <typename Tag, typename... Types>
171TSTAG(struct)
172tuple_size<tim::auto_bundle<Tag, Types...>>
173{
174private:
175 // auto_bundle does not apply concat
176 using type = tim::convert_t<tim::mpl::available_t<tuple<Types...>>, tuple<>>;
177
178public:
179 static constexpr size_t value = tuple_size<type>::value;
180};
181//
182//--------------------------------------------------------------------------------------//
183//
184template <typename... Types>
185TSTAG(struct)
186tuple_size<tim::auto_tuple<Types...>>
187{
188private:
189 using type = tim::stl_tuple_t<Types...>;
190
191public:
192 static constexpr size_t value = tuple_size<type>::value;
193};
194//
195//--------------------------------------------------------------------------------------//
196//
197template <typename... Types>
198TSTAG(struct)
199tuple_size<tim::auto_list<Types...>>
200{
201private:
202 using type = tim::stl_tuple_t<Types...>;
203
204public:
205 static constexpr size_t value = tuple_size<type>::value;
206};
207//
208//--------------------------------------------------------------------------------------//
209//
210#if defined(TIMEMORY_USE_DEPRECATED)
211//
212template <typename Tuple, typename List>
213TSTAG(struct)
214tuple_size<tim::component_hybrid<Tuple, List>>
215{
216public:
217 static constexpr auto value = tuple_size<Tuple>::value + tuple_size<List>::value;
218};
219//
220//--------------------------------------------------------------------------------------//
221//
222template <typename Tuple, typename List>
223TSTAG(struct)
224tuple_size<tim::auto_hybrid<Tuple, List>>
225{
226public:
227 using value_type = size_t;
228 static constexpr auto value = tuple_size<Tuple>::value + tuple_size<List>::value;
229};
230//
231#endif
232//
233} // namespace std
234
235//======================================================================================//
This is a variadic component wrapper where all components are optional at runtime....
Definition: auto_list.hpp:91
This is a variadic component wrapper where all components are allocated on the stack and cannot be di...
Definition: auto_tuple.hpp:65
This is a variadic component wrapper where all components are optional at runtime....
This is a variadic component wrapper where all components are allocated on the stack and cannot be di...
This is a variadic component wrapper which provides the least amount of runtime and compilation overh...
Declare the allinea component types.
Declare the base component types.
Declare the caliper component types.
Declare the craypat component types.
Declare the cuda component types.
Declare the gperftools component types.
Declare the hip component types.
Declare the io component types.
Declare the likwid component types.
Declare the papi component types.
false_type TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, component::perfetto_trace, false_type) TIMEMORY_PROPERTY_SPECIALIZATION(perfetto_trace
Forward declaration of user_bundle components. User-bundles are similar to the classical profiling in...
STL namespace.
typename std::enable_if< B, T >::type enable_if_t
Definition: types.hpp:58
impl::filter_false< trait::is_available, T > available_t
Definition: available.hpp:324
Definition: kokkosp.cpp:39
convert_t< mpl::available_t< concat< T... > >, std::tuple<> > stl_tuple_t
Definition: available.hpp:330
typename impl::convert< T, U >::type convert_t
Definition: types.hpp:855
This is a variadic component wrapper which combines the features of tim::component_tuple<T....
Definition: types.hpp:63
This is a variadic component wrapper which combines the features of tim::auto_tuple<T....
Definition: types.hpp:75
provides nothing, used for dummy types in enum
Definition: placeholder.hpp:44
#define TSTAG(X)
\macro TSTAG
Definition: types.hpp:45