timemory  3.2.1
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"
39 #include "timemory/mpl/quirks.hpp"
41 
42 #include <cstdint>
43 #include <iostream>
44 #include <string>
45 #include <type_traits>
46 
47 //======================================================================================//
48 //
49 namespace tim
50 {
51 //======================================================================================//
52 // components that provide implementations (i.e. HOW to record a component)
53 //
54 namespace component
55 {
56 // define this short-hand from C++14 for C++11
57 template <bool B, typename T = int>
58 using enable_if_t = typename std::enable_if<B, T>::type;
59 
60 // holder that provides nothing
61 template <typename... Types>
62 struct placeholder;
63 
64 struct nothing : base<nothing, skeleton::base>
65 {};
66 
67 } // namespace component
68 } // namespace tim
69 
70 //======================================================================================//
71 
93 
94 //======================================================================================//
95 
96 TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::explicit_start, false_type)
97 TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::explicit_stop, false_type)
98 TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::no_init, false_type)
99 
100 //======================================================================================//
101 //
102 // Define tuple_size now that all type-traits have been declared
103 //
104 //======================================================================================//
105 
106 #include "timemory/mpl/available.hpp"
107 
108 namespace std
109 {
110 //
111 //--------------------------------------------------------------------------------------//
112 //
113 template <typename... Types>
114 TSTAG(struct)
115 tuple_size<tim::lightweight_tuple<Types...>>
116 {
117 private:
118  using type = tim::stl_tuple_t<Types...>;
119 
120 public:
121  static constexpr size_t value = tuple_size<type>::value;
122 };
123 //
124 //--------------------------------------------------------------------------------------//
125 //
126 template <typename Tag, typename... Types>
127 TSTAG(struct)
128 tuple_size<tim::component_bundle<Tag, Types...>>
129 {
130 private:
131  // component_bundle does not apply concat
132  using type = tim::convert_t<tim::mpl::available_t<tuple<Types...>>, tuple<>>;
133 
134 public:
135  static constexpr size_t value = tuple_size<type>::value;
136 };
137 //
138 //--------------------------------------------------------------------------------------//
139 //
140 template <typename... Types>
141 TSTAG(struct)
142 tuple_size<tim::component_tuple<Types...>>
143 {
144 private:
145  using type = tim::stl_tuple_t<Types...>;
146 
147 public:
148  static constexpr size_t value = tuple_size<type>::value;
149 };
150 //
151 //--------------------------------------------------------------------------------------//
152 //
153 template <typename... Types>
154 TSTAG(struct)
155 tuple_size<tim::component_list<Types...>>
156 {
157 private:
158  using type = tim::stl_tuple_t<Types...>;
159 
160 public:
161  static constexpr size_t value = tuple_size<type>::value;
162 };
163 //
164 //--------------------------------------------------------------------------------------//
165 //
166 template <typename Tag, typename... Types>
167 TSTAG(struct)
168 tuple_size<tim::auto_bundle<Tag, Types...>>
169 {
170 private:
171  // auto_bundle does not apply concat
172  using type = tim::convert_t<tim::mpl::available_t<tuple<Types...>>, tuple<>>;
173 
174 public:
175  static constexpr size_t value = tuple_size<type>::value;
176 };
177 //
178 //--------------------------------------------------------------------------------------//
179 //
180 template <typename... Types>
181 TSTAG(struct)
182 tuple_size<tim::auto_tuple<Types...>>
183 {
184 private:
185  using type = tim::stl_tuple_t<Types...>;
186 
187 public:
188  static constexpr size_t value = tuple_size<type>::value;
189 };
190 //
191 //--------------------------------------------------------------------------------------//
192 //
193 template <typename... Types>
194 TSTAG(struct)
195 tuple_size<tim::auto_list<Types...>>
196 {
197 private:
198  using type = tim::stl_tuple_t<Types...>;
199 
200 public:
201  static constexpr size_t value = tuple_size<type>::value;
202 };
203 //
204 //--------------------------------------------------------------------------------------//
205 //
206 #if defined(TIMEMORY_USE_DEPRECATED)
207 //
208 template <typename Tuple, typename List>
209 TSTAG(struct)
210 tuple_size<tim::component_hybrid<Tuple, List>>
211 {
212 public:
213  static constexpr auto value = tuple_size<Tuple>::value + tuple_size<List>::value;
214 };
215 //
216 //--------------------------------------------------------------------------------------//
217 //
218 template <typename Tuple, typename List>
219 TSTAG(struct)
220 tuple_size<tim::auto_hybrid<Tuple, List>>
221 {
222 public:
223  using value_type = size_t;
224  static constexpr auto value = tuple_size<Tuple>::value + tuple_size<List>::value;
225 };
226 //
227 #endif
228 //
229 } // namespace std
230 
231 //======================================================================================//
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 io component types.
Declare the likwid component types.
Declare the papi component types.
TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available, quirk::explicit_start, false_type) TIMEMORY_DEFINE_CONCRETE_TRAIT(is_available
Forward declaration of user_bundle components. User-bundles are similar to the classical profiling in...
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:38
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:816
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