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