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.
macros.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/containers/macros.hpp
27 * \brief Include the macros for containers
28 */
29
30#pragma once
31
32#include "timemory/dll.hpp"
33
34//======================================================================================//
35//
36// Define macros for containers
37//
38//======================================================================================//
39//
40#if defined(TIMEMORY_USE_EXTERN) && !defined(TIMEMORY_USE_CONTAINERS_EXTERN)
41# define TIMEMORY_USE_CONTAINERS_EXTERN
42#endif
43//
44#if defined(TIMEMORY_CONTAINERS_SOURCE)
45# define TIMEMORY_CONTAINERS_LINKAGE(...) __VA_ARGS__
46#elif defined(TIMEMORY_USE_CONTAINERS_EXTERN)
47# define TIMEMORY_CONTAINERS_LINKAGE(...) extern __VA_ARGS__
48#else
49# define TIMEMORY_CONTAINERS_LINKAGE(...) inline __VA_ARGS__
50#endif
51//
52//--------------------------------------------------------------------------------------//
53//
54#if !defined(TIMEMORY_DECLARE_EXTERN_BUNDLE)
55# define TIMEMORY_DECLARE_EXTERN_BUNDLE(TYPE, ...) \
56 namespace tim \
57 { \
58 extern template class TYPE<__VA_ARGS__>; \
59 }
60#endif
61//
62//--------------------------------------------------------------------------------------//
63//
64#if !defined(TIMEMORY_INSTANTIATE_EXTERN_BUNDLE)
65# define TIMEMORY_INSTANTIATE_EXTERN_BUNDLE(TYPE, ...) \
66 namespace tim \
67 { \
68 template class TYPE<__VA_ARGS__>; \
69 }
70#endif
71//
72//--------------------------------------------------------------------------------------//
73//
74// generic for build
75//
76//--------------------------------------------------------------------------------------//
77//
78#if defined(TIMEMORY_WINDOWS)
79//
80# if !defined(TIMEMORY_EXTERN_BUNDLE)
81# define TIMEMORY_EXTERN_BUNDLE(...)
82# endif
83//
84#else
85//
86# if defined(TIMEMORY_CONTAINERS_SOURCE)
87//
88# if !defined(TIMEMORY_EXTERN_BUNDLE)
89# define TIMEMORY_EXTERN_BUNDLE(...) \
90 TIMEMORY_INSTANTIATE_EXTERN_BUNDLE(__VA_ARGS__)
91# endif
92//
93# elif defined(TIMEMORY_USE_CONTAINERS_EXTERN)
94//
95# if !defined(TIMEMORY_EXTERN_BUNDLE)
96# define TIMEMORY_EXTERN_BUNDLE(...) \
97 TIMEMORY_DECLARE_EXTERN_BUNDLE(__VA_ARGS__)
98# endif
99//
100# else
101//
102# if !defined(TIMEMORY_EXTERN_BUNDLE)
103# define TIMEMORY_EXTERN_BUNDLE(...)
104# endif
105//
106# endif
107//
108#endif
109//
110//--------------------------------------------------------------------------------------//
111//
112// AUTO_BUNDLE macros
113//
114//--------------------------------------------------------------------------------------//
115//
116#if !defined(TIMEMORY_BLANK_AUTO_BUNDLE)
117# define TIMEMORY_BLANK_AUTO_BUNDLE(...) \
118 TIMEMORY_BLANK_POINTER(::tim::auto_bundle, __VA_ARGS__)
119#endif
120//
121#if !defined(TIMEMORY_BASIC_AUTO_BUNDLE)
122# define TIMEMORY_BASIC_AUTO_BUNDLE(...) \
123 TIMEMORY_BASIC_POINTER(::tim::auto_bundle, __VA_ARGS__)
124#endif
125//
126#if !defined(TIMEMORY_AUTO_BUNDLE)
127# define TIMEMORY_AUTO_BUNDLE(...) TIMEMORY_POINTER(::tim::auto_bundle, __VA_ARGS__)
128#endif
129//
130//--------------------------------------------------------------------------------------//
131// instance versions
132//
133#if !defined(TIMEMORY_BLANK_AUTO_BUNDLE_HANDLE)
134# define TIMEMORY_BLANK_AUTO_BUNDLE_HANDLE(...) \
135 TIMEMORY_BLANK_HANDLE(::tim::auto_bundle, __VA_ARGS__)
136#endif
137//
138#if !defined(TIMEMORY_BASIC_AUTO_BUNDLE_HANDLE)
139# define TIMEMORY_BASIC_AUTO_BUNDLE_HANDLE(...) \
140 TIMEMORY_BASIC_HANDLE(::tim::auto_bundle, __VA_ARGS__)
141#endif
142//
143#if !defined(TIMEMORY_AUTO_BUNDLE_HANDLE)
144# define TIMEMORY_AUTO_BUNDLE_HANDLE(...) \
145 TIMEMORY_HANDLE(::tim::auto_bundle, __VA_ARGS__)
146#endif
147//
148//--------------------------------------------------------------------------------------//
149// debug versions
150//
151#if !defined(TIMEMORY_DEBUG_BASIC_AUTO_BUNDLE)
152# define TIMEMORY_DEBUG_BASIC_AUTO_BUNDLE(...) \
153 TIMEMORY_DEBUG_BASIC_MARKER(::tim::auto_bundle, __VA_ARGS__)
154#endif
155//
156#if !defined(TIMEMORY_DEBUG_AUTO_BUNDLE)
157# define TIMEMORY_DEBUG_AUTO_BUNDLE(...) \
158 TIMEMORY_DEBUG_MARKER(::tim::auto_bundle, __VA_ARGS__)
159#endif
160//
161//--------------------------------------------------------------------------------------//
162//
163// AUTO_TIMER macros
164//
165//--------------------------------------------------------------------------------------//
166//
167#if !defined(TIMEMORY_BLANK_AUTO_TIMER)
168# define TIMEMORY_BLANK_AUTO_TIMER(...) \
169 TIMEMORY_BLANK_POINTER(::tim::auto_timer, __VA_ARGS__)
170#endif
171//
172#if !defined(TIMEMORY_BASIC_AUTO_TIMER)
173# define TIMEMORY_BASIC_AUTO_TIMER(...) \
174 TIMEMORY_BASIC_POINTER(::tim::auto_timer, __VA_ARGS__)
175#endif
176//
177#if !defined(TIMEMORY_AUTO_TIMER)
178# define TIMEMORY_AUTO_TIMER(...) TIMEMORY_POINTER(::tim::auto_timer, __VA_ARGS__)
179#endif
180//
181//--------------------------------------------------------------------------------------//
182// instance versions
183//
184#if !defined(TIMEMORY_BLANK_AUTO_TIMER_HANDLE)
185# define TIMEMORY_BLANK_AUTO_TIMER_HANDLE(...) \
186 TIMEMORY_BLANK_HANDLE(::tim::auto_timer, __VA_ARGS__)
187#endif
188//
189#if !defined(TIMEMORY_BASIC_AUTO_TIMER_HANDLE)
190# define TIMEMORY_BASIC_AUTO_TIMER_HANDLE(...) \
191 TIMEMORY_BASIC_HANDLE(::tim::auto_timer, __VA_ARGS__)
192#endif
193//
194#if !defined(TIMEMORY_AUTO_TIMER_HANDLE)
195# define TIMEMORY_AUTO_TIMER_HANDLE(...) \
196 TIMEMORY_HANDLE(::tim::auto_timer, __VA_ARGS__)
197#endif
198//
199//--------------------------------------------------------------------------------------//
200// debug versions
201//
202#if !defined(TIMEMORY_DEBUG_BASIC_AUTO_TIMER)
203# define TIMEMORY_DEBUG_BASIC_AUTO_TIMER(...) \
204 TIMEMORY_DEBUG_BASIC_MARKER(::tim::auto_timer, __VA_ARGS__)
205#endif
206//
207#if !defined(TIMEMORY_DEBUG_AUTO_TIMER)
208# define TIMEMORY_DEBUG_AUTO_TIMER(...) \
209 TIMEMORY_DEBUG_MARKER(::tim::auto_timer, __VA_ARGS__)
210#endif
211//
212//--------------------------------------------------------------------------------------//