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.
declaration.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
15// all 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#pragma once
27
34
35#include <cstdint>
36#include <functional>
37#include <string>
38
39namespace tim
40{
41namespace component
42{
43//
44//--------------------------------------------------------------------------------------//
45//
46template <typename InitF, typename StartF, typename StopF, typename GetF, typename DelF,
47 typename SetupF, typename PushF, typename PopF, typename SampleF,
48 typename UpdateStatsF>
49opaque::opaque(bool _valid, size_t _typeid, InitF&& _init, StartF&& _start, StopF&& _stop,
50 GetF&& _get, DelF&& _del, SetupF&& _setup, PushF&& _push, PopF&& _pop,
51 SampleF&& _sample, UpdateStatsF&& _update_stats)
52: m_valid(_valid)
53, m_typeid(_typeid)
54, m_init(std::move(_init))
55, m_setup(std::move(_setup))
56, m_push(std::move(_push))
57, m_start(std::move(_start))
58, m_stop(std::move(_stop))
59, m_pop(std::move(_pop))
60, m_get(std::move(_get))
61, m_del(std::move(_del))
62, m_sample(std::move(_sample))
63, m_update_stats(std::move(_update_stats))
64{}
65//
66//--------------------------------------------------------------------------------------//
67//
69{
70 if(m_data)
71 {
74 }
75}
76//
77//--------------------------------------------------------------------------------------//
78//
79inline void
81{
82 m_init();
83}
84//
85//--------------------------------------------------------------------------------------//
86//
87inline void
89{
90 if(m_data)
91 {
92 stop();
93 cleanup();
94 }
95 m_data = m_setup(m_data, _prefix, _scope);
96 m_valid = (m_data != nullptr);
97}
98//
99//--------------------------------------------------------------------------------------//
100//
101inline void
103{
104 if(m_data)
105 m_push(m_data, _prefix, _scope);
106}
107//
108//--------------------------------------------------------------------------------------//
109//
110inline void
112{
113 if(m_data)
115}
116//
117//--------------------------------------------------------------------------------------//
118//
119inline void
121{
122 if(m_data)
124}
125//
126//--------------------------------------------------------------------------------------//
127//
128inline void
130{
131 if(m_data)
132 m_stop(m_data);
133}
134//
135//--------------------------------------------------------------------------------------//
136//
137inline void
139{
140 if(m_data)
141 m_pop(m_data);
142}
143//
144//--------------------------------------------------------------------------------------//
145//
146inline void
148{
149 if(m_data && !m_copy)
150 m_del(m_data);
151 m_data = nullptr;
152}
153//
154//--------------------------------------------------------------------------------------//
155//
156inline void
157opaque::get(void*& ptr, size_t _hash) const
158{
159 if(m_data)
160 m_get(m_data, ptr, _hash);
161}
162//
163//--------------------------------------------------------------------------------------//
164//
165inline void
167{
168 if(m_data)
170}
171//
172//--------------------------------------------------------------------------------------//
173//
174inline void
176{
177 m_copy = val;
178}
179//
180//--------------------------------------------------------------------------------------//
181//
182} // namespace component
183} // namespace tim
STL namespace.
Definition: kokkosp.cpp:39
char const std::string & _prefix
Definition: config.cpp:55
const std::string & string_view_cref_t
Definition: language.hpp:103
init_func_t m_init
Definition: types.hpp:90
void get(void *&ptr, size_t _hash) const
delete_func_t m_del
Definition: types.hpp:99
stats_func_t m_update_stats
Definition: types.hpp:101
sample_func_t m_sample
Definition: types.hpp:100
stop_func_t m_stop
Definition: types.hpp:96
void update_statistics(bool) const
setup_func_t m_setup
Definition: types.hpp:91
void push(string_view_cref_t _prefix, scope::config _scope)
push_func_t m_push
Definition: types.hpp:94
void setup(string_view_cref_t _prefix, scope::config _scope)
Definition: declaration.hpp:88
get_func_t m_get
Definition: types.hpp:98
void set_copy(bool val)
start_func_t m_start
Definition: types.hpp:95
pop_func_t m_pop
Definition: types.hpp:97
this data type encodes the options of storage scope. The default is hierarchical (tree) scope....
Definition: types.hpp:453