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.
components.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/**
26 * \file timemory/components/likwid/components.hpp
27 * \brief Implementation of the likwid component(s)
28 */
29
30#pragma once
31
33#include "timemory/components/likwid/backends.hpp"
37#include "timemory/units.hpp"
38
39//======================================================================================//
40//
41namespace tim
42{
43namespace component
44{
45//
46//======================================================================================//
47//
48// perfmon marker (CPU)
49//
50//======================================================================================//
51//
52/// \struct tim::component::likwid_marker
53/// \brief Provides likwid perfmon marker forwarding. Requires \def LIKWID_PERFMON to
54/// be defined before including <likwid-marker.h>
55struct likwid_marker : public base<likwid_marker, void>
56{
57 // timemory component api
58 using value_type = void;
61
62 static std::string label() { return "likwid_marker"; }
63 static std::string description() { return "LIKWID perfmon (CPU) marker forwarding"; }
64 static value_type record() {}
65
66 static void global_init()
67 {
68#if defined(TIMEMORY_USE_LIKWID_PERFMON)
69 likwid_markerInit();
70#endif
71 }
72
73 static void thread_init()
74 {
75#if defined(TIMEMORY_USE_LIKWID_PERFMON)
76 likwid_markerThreadInit();
77#endif
78 }
79
80 static void global_finalize()
81 {
82#if defined(TIMEMORY_USE_LIKWID_PERFMON)
83 likwid_markerClose();
84#endif
85 }
86
87 static void next()
88 {
89#if defined(TIMEMORY_USE_LIKWID_PERFMON)
90 likwid_markerNextGroup();
91#endif
92 }
93
94 TIMEMORY_DEFAULT_OBJECT(likwid_marker)
95
96 void start()
97 {
98#if defined(TIMEMORY_USE_LIKWID_PERFMON)
99 likwid_markerStartRegion(m_prefix);
100#endif
101 }
102
103 void stop()
104 {
105#if defined(TIMEMORY_USE_LIKWID_PERFMON)
106 likwid_markerStopRegion(m_prefix);
107#endif
108 }
109
111 {
112#if defined(TIMEMORY_USE_LIKWID_PERFMON)
113 likwid_markerResetRegion(m_prefix);
114#endif
115 }
116
118 {
119#if defined(TIMEMORY_USE_LIKWID_PERFMON)
120 likwid_markerRegisterRegion(m_prefix);
121#endif
122 }
123
124 likwid_data get() const // NOLINT
125 {
126 likwid_data _data{};
127#if defined(TIMEMORY_USE_LIKWID_PERFMON)
128 likwid_markerGetRegion(m_prefix, &_data.nevents, _data.events.data(), &_data.time,
129 &_data.count);
130 _data.events.resize(_data.nevents);
131#endif
132 return _data;
133 }
134
135 void set_prefix(const char* _prefix)
136 {
137 m_prefix = _prefix;
139 }
140
141private:
142 //----------------------------------------------------------------------------------//
143 //
144 // Member Variables
145 //
146 //----------------------------------------------------------------------------------//
147 const char* m_prefix = nullptr;
148};
149//
150//======================================================================================//
151//
152// nvmon marker (GPU)
153//
154//======================================================================================//
155//
156/// \struct tim::component::likwid_nvmarker
157/// \brief Provides likwid nvmon marker forwarding. Requires \def LIKWID_NVMON to
158/// be defined before including <likwid-marker.h>
159struct likwid_nvmarker : public base<likwid_nvmarker, void>
160{
161 // timemory component api
162 using value_type = void;
165
166 static std::string label() { return "likwid_nvmarker"; }
167 static std::string description() { return "LIKWID nvmon (GPU) marker forwarding"; }
168 static value_type record() {}
169
170 static void global_init()
171 {
172#if defined(TIMEMORY_USE_LIKWID_NVMON)
173 likwid_gpuMarkerInit();
174#endif
175 }
176
177 static void global_finalize()
178 {
179#if defined(TIMEMORY_USE_LIKWID_NVMON)
180 likwid_gpuMarkerClose();
181#endif
182 }
183
184 TIMEMORY_DEFAULT_OBJECT(likwid_nvmarker)
185
186 void start()
187 {
188#if defined(TIMEMORY_USE_LIKWID_NVMON)
189 likwid_gpuMarkerStartRegion(m_prefix);
190#endif
191 }
192
193 void stop()
194 {
195#if defined(TIMEMORY_USE_LIKWID_NVMON)
196 likwid_gpuMarkerStopRegion(m_prefix);
197#endif
198 }
199
200 void reset()
201 {
202#if defined(TIMEMORY_USE_LIKWID_NVMON)
203 likwid_gpuMarkerResetRegion(m_prefix);
204#endif
205 }
206
208 {
209#if defined(TIMEMORY_USE_LIKWID_NVMON)
210 likwid_gpuMarkerRegisterRegion(m_prefix);
211#endif
212 }
213
214 /*likwid_nvdata get() const
215 {
216 likwid_nvdata _data{};
217#if defined(TIMEMORY_USE_LIKWID_NVMON)
218 likwid_gpuMarkerGetRegion(m_prefix, &_data.ndevices, &_data.nevents,
219 &_data.events[0]), &_data.time[0],
220 &_data.count[0]);
221 _data.time.resize(_data.ndevices);
222 _data.count.resize(_data.ndevices);
223 _data.events.resize(_data.ndevices * _data.nevents);
224#endif
225 return _data;
226 }*/
227
228 void set_prefix(const char* _prefix)
229 {
230 m_prefix = _prefix;
232 }
233
234private:
235 //----------------------------------------------------------------------------------//
236 //
237 // Member Variables
238 //
239 //----------------------------------------------------------------------------------//
240 const char* m_prefix = nullptr;
241};
242//
243} // namespace component
244} // namespace tim
245//
246//======================================================================================//
Declare the likwid component types.
Definition: kokkosp.cpp:39
char const std::string & _prefix
Definition: config.cpp:55
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
Provides likwid perfmon marker forwarding. Requires.
Definition: components.hpp:56
static value_type record()
Definition: components.hpp:64
void set_prefix(const char *_prefix)
Definition: components.hpp:135
likwid_data get() const
Definition: components.hpp:124
static std::string label()
Definition: components.hpp:62
static std::string description()
Definition: components.hpp:63
Provides likwid nvmon marker forwarding. Requires.
Definition: components.hpp:160
void set_prefix(const char *_prefix)
Definition: components.hpp:228
static value_type record()
Definition: components.hpp:168
static std::string label()
Definition: components.hpp:166
static std::string description()
Definition: components.hpp:167