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/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 /**
26  * \file timemory/components/base/types.hpp
27  * \brief Declare the base component types
28  */
29 
30 #pragma once
31 
34 #include "timemory/mpl/math.hpp"
35 #include "timemory/mpl/quirks.hpp"
37 
38 #include <type_traits>
39 
40 //======================================================================================//
41 //
42 namespace tim
43 {
44 namespace trait
45 {
46 template <typename Tp>
47 struct data;
48 
49 template <typename Tp>
50 using data_t = typename data<Tp>::type;
51 } // namespace trait
52 
53 namespace component
54 {
55 //
56 // generic static polymorphic base class
57 template <typename Tp,
58  typename ValueType = conditional_t<concepts::is_empty<trait::data_t<Tp>>::value,
59  int64_t, trait::data_t<Tp>>>
60 struct base;
61 //
62 //--------------------------------------------------------------------------------------//
63 //
64 namespace operators
65 {
66 //
67 //--------------------------------------------------------------------------------------//
68 //
69 // the operator- is used very, very often in stop() of components
70 //
71 //--------------------------------------------------------------------------------------//
72 //
73 template <typename Tp>
74 Tp
75 operator-(Tp lhs, const Tp& rhs)
76 {
77  math::minus(lhs, rhs);
78  return lhs;
79 }
80 //
81 //--------------------------------------------------------------------------------------//
82 //
83 } // namespace operators
84 //
85 //--------------------------------------------------------------------------------------//
86 //
87 struct empty_base;
88 //
89 struct dynamic_base;
90 //
91 template <typename Tp, typename Value>
92 struct base;
93 //
94 //--------------------------------------------------------------------------------------//
95 //
96 template <typename Tp>
97 struct base<Tp, void>;
98 //
99 //--------------------------------------------------------------------------------------//
100 //
101 } // namespace component
102 //
103 //----------------------------------------------------------------------------------//
104 //
105 namespace trait
106 {
107 /// \struct tim::trait::dynamic_base
108 /// \brief trait that designates the type the static polymorphic base class
109 /// (\ref tim::component::base) inherit from.
110 ///
111 template <typename Tp>
112 struct dynamic_base : std::false_type
113 {
115 };
116 //
117 } // namespace trait
118 //
119 //----------------------------------------------------------------------------------//
120 //
121 } // namespace tim
122 //
123 //======================================================================================//
124 
125 namespace tim
126 {
127 namespace cereal
128 {
129 namespace detail
130 {
131 template <typename Tp, typename Vp>
132 struct StaticVersion<tim::component::base<Tp, Vp>>
133 {
134  static constexpr uint32_t version = 0;
135 };
136 } // namespace detail
137 } // namespace cereal
138 } // namespace tim
Tp operator-(Tp lhs, const Tp &rhs)
Definition: types.hpp:75
Tp & minus(Tp &, const Up &)
Definition: math.hpp:633
typename data< Tp >::type data_t
Definition: types.hpp:50
Definition: kokkosp.cpp:38
typename std::conditional< B, Lhs, Rhs >::type conditional_t
Definition: types.hpp:197
lightweight tuple-alternative for meta-programming logic
Definition: types.hpp:233
The default base class for timemory components.
Definition: declaration.hpp:50
trait that designates the type the static polymorphic base class (tim::component::base) inherit from.
Definition: types.hpp:113