Geant4-11
G4TiMemory.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4TiMemory
27//
28// Description:
29//
30// Provides empty macros when Geant4 is compiled with TiMemory disabled
31
32// Author: Jonathan R. Madsen, 25 April 2019
33// --------------------------------------------------------------------
34#ifndef g4timemory_hh
35#define g4timemory_hh 1
36
37// Fundamental definitions
38#ifndef G4GMAKE
39# include "G4GlobalConfig.hh"
40#endif
41
42#include "globals.hh"
43
44#include <cstddef>
45#include <functional>
46#include <string>
47#include <utility>
48
49//----------------------------------------------------------------------------//
50
51#ifdef GEANT4_USE_TIMEMORY
52
53# include <timemory/timemory.hpp>
54
55namespace g4tim
56{
57using namespace tim;
58} // namespace g4tim
59
60using G4AutoTimer = g4tim::auto_timer;
61
62#else
63
64# include <ostream>
65# include <string>
66
67namespace g4tim
68{
69
72 struct dummy
73 {
74 template <typename... _Types, typename... _Args>
75 static void configure(_Args&&...)
76 {}
77 template <typename... _Args>
78 dummy(_Args&&...)
79 {}
80 ~dummy() = default;
81 dummy(const dummy&) = default;
82 dummy(dummy&&) = default;
83 dummy& operator=(const dummy&) = default;
84 dummy& operator=(dummy&&) = default;
85
86 void record() {}
87 void start() {}
88 void stop() {}
89 void push() {}
90 void pop() {}
91 void reset() {}
92 void report_at_exit(bool) {}
93 template <typename... _Args>
94 void mark_begin(_Args&&...)
95 {}
96 template <typename... _Args>
97 void mark_end(_Args&&...)
98 {}
99 friend std::ostream& operator<<(std::ostream& os, const dummy&)
100 {
101 return os;
102 }
103 };
104
105} // namespace g4tim
106
107// startup/shutdown/configure
108# define TIMEMORY_INIT(...)
109# define TIMEMORY_FINALIZE()
110# define TIMEMORY_CONFIGURE(...)
111
112// label creation
113# define TIMEMORY_BASIC_LABEL(...) std::string("")
114# define TIMEMORY_LABEL(...) std::string("")
115# define TIMEMORY_JOIN(...) std::string("")
116
117// define an object
118# define TIMEMORY_BLANK_MARKER(...)
119# define TIMEMORY_BASIC_MARKER(...)
120# define TIMEMORY_MARKER(...)
121
122// define an unique pointer object
123# define TIMEMORY_BLANK_POINTER(...)
124# define TIMEMORY_BASIC_POINTER(...)
125# define TIMEMORY_POINTER(...)
126
127// define an object with a caliper reference
128# define TIMEMORY_BLANK_CALIPER(...)
129# define TIMEMORY_BASIC_CALIPER(...)
130# define TIMEMORY_CALIPER(...)
131
132// define a static object with a caliper reference
133# define TIMEMORY_STATIC_BLANK_CALIPER(...)
134# define TIMEMORY_STATIC_BASIC_CALIPER(...)
135# define TIMEMORY_STATIC_CALIPER(...)
136
137// invoke member function on caliper reference or type within reference
138# define TIMEMORY_CALIPER_APPLY(...)
139# define TIMEMORY_CALIPER_TYPE_APPLY(...)
140
141// get an object
142# define TIMEMORY_BLANK_HANDLE(...) g4tim::dummy()
143# define TIMEMORY_BASIC_HANDLE(...) g4tim::dummy()
144# define TIMEMORY_HANDLE(...) tim::dummy()
145
146// get a pointer to an object
147# define TIMEMORY_BLANK_POINTER_HANDLE(...) nullptr
148# define TIMEMORY_BASIC_POINTER_HANDLE(...) nullptr
149# define TIMEMORY_POINTER_HANDLE(...) nullptr
150
151// debug only
152# define TIMEMORY_DEBUG_BLANK_MARKER(...)
153# define TIMEMORY_DEBUG_BASIC_MARKER(...)
154# define TIMEMORY_DEBUG_MARKER(...)
155
156// auto-timers
157# define TIMEMORY_BLANK_AUTO_TIMER(...)
158# define TIMEMORY_BASIC_AUTO_TIMER(...)
159# define TIMEMORY_AUTO_TIMER(...)
160# define TIMEMORY_BLANK_AUTO_TIMER_HANDLE(...)
161# define TIMEMORY_BASIC_AUTO_TIMER_HANDLE(...)
162# define TIMEMORY_AUTO_TIMER_HANDLE(...)
163# define TIMEMORY_DEBUG_BASIC_AUTO_TIMER(...)
164# define TIMEMORY_DEBUG_AUTO_TIMER(...)
165
167
168#endif
169
170//----------------------------------------------------------------------------//
171
172#endif
void mark_end(_Args &&...)
Definition: G4TiMemory.hh:97
void record()
Definition: G4TiMemory.hh:86
dummy(_Args &&...)
Definition: G4TiMemory.hh:78
dummy & operator=(const dummy &)=default
void stop()
Definition: G4TiMemory.hh:88
void report_at_exit(bool)
Definition: G4TiMemory.hh:92
dummy(dummy &&)=default
dummy(const dummy &)=default
~dummy()=default
void start()
Definition: G4TiMemory.hh:87
void mark_begin(_Args &&...)
Definition: G4TiMemory.hh:94
friend std::ostream & operator<<(std::ostream &os, const dummy &)
Definition: G4TiMemory.hh:99
dummy & operator=(dummy &&)=default
void reset()
Definition: G4TiMemory.hh:91
void push()
Definition: G4TiMemory.hh:89
static void configure(_Args &&...)
Definition: G4TiMemory.hh:75
void pop()
Definition: G4TiMemory.hh:90