CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
include/management/sChronoManager.hh
Go to the documentation of this file.
1 
8 #ifndef SCHRONOMANAGER_HH
9 #define SCHRONOMANAGER_HH 1
10 
11 #include "gVariables.hh"
12 #include "sOutputManager.hh"
13 
14 // Typedef for times and durations
15 typedef std::chrono::time_point<std::chrono::system_clock> ChronoTime;
16 typedef std::chrono::duration<int64_t,std::nano> DurationNano;
17 typedef std::chrono::milliseconds Ms;
18 typedef std::chrono::seconds Secs;
19 typedef std::chrono::minutes Mins;
20 typedef std::chrono::hours Hs;
21 
27 class sChronoManager
28 {
29  // -----------------------------------------------------------------------------------------
30  // Constructor & Destructor
31  public :
38  {
39  if (mp_Instance == NULL) mp_Instance = new sChronoManager;
40  return mp_Instance;
41  };
48 
49  // -----------------------------------------------------------------------------------------
50  // Public functions
51  public:
57  int CheckParameters();
63  int Initialize();
68  void Display();
69 
70  // -----------------------------------------------------------------------------------------
71  // Public inline functions for updating timers
72  public:
78  inline void StartIterativeDataUpdateStep1(int a_thread)
79  {mp_startIterativeDataUpdateStep1[a_thread] = std::chrono::system_clock::now();}
85  inline void StopIterativeDataUpdateStep1(int a_thread)
86  {mp_durationIterativeDataUpdateStep1[a_thread] += std::chrono::system_clock::now() - mp_startIterativeDataUpdateStep1[a_thread];}
92  inline void StartIterativeDataUpdateStep2(int a_thread)
93  {mp_startIterativeDataUpdateStep2[a_thread] = std::chrono::system_clock::now();}
99  inline void StopIterativeDataUpdateStep2(int a_thread)
100  {mp_durationIterativeDataUpdateStep2[a_thread] += std::chrono::system_clock::now() - mp_startIterativeDataUpdateStep2[a_thread];}
106  inline void StartIterativeDataUpdateStep3(int a_thread)
107  {mp_startIterativeDataUpdateStep3[a_thread] = std::chrono::system_clock::now();}
113  inline void StopIterativeDataUpdateStep3(int a_thread)
114  {mp_durationIterativeDataUpdateStep3[a_thread] += std::chrono::system_clock::now() - mp_startIterativeDataUpdateStep3[a_thread];}
120  inline void StartIterativeDataUpdateStep4(int a_thread)
121  {mp_startIterativeDataUpdateStep4[a_thread] = std::chrono::system_clock::now();}
127  inline void StopIterativeDataUpdateStep4(int a_thread)
128  {mp_durationIterativeDataUpdateStep4[a_thread] += std::chrono::system_clock::now() - mp_startIterativeDataUpdateStep4[a_thread];}
133  inline void StartConvolution()
134  {m_startConvolution = std::chrono::system_clock::now();}
139  inline void StopConvolution()
140  {m_durationConvolution += std::chrono::system_clock::now() - m_startConvolution;}
147  inline void StartCustomStep(int a_thread, int a_step)
148  {mpp_startCustomSteps[a_step][a_thread] = std::chrono::system_clock::now();}
153  inline void StopCustomStep(int a_thread, int a_step)
154  {mpp_durationCustomSteps[a_step][a_thread] += std::chrono::system_clock::now() - mpp_startCustomSteps[a_step][a_thread];}
155 
156  // -----------------------------------------------------------------------------------------
157  // Public Get & Set functions
158  public:
165  inline void SetNbThreads(int a_nbThreadsForProjection, int a_nbThreadsForImageComputation)
166  {m_nbThreadsForProjection = a_nbThreadsForProjection; m_nbThreadsForImageComputation = a_nbThreadsForImageComputation;
173  inline void SetNbCustomSteps(int a_nbCustomSteps)
174  {m_nbCustomSteps = a_nbCustomSteps;}
180  inline void SetVerbose(int a_verbose)
181  {m_verbose = a_verbose;}
182 
183  // -------------------------------------------------------------------
184  // Private constructor
185  private:
191  sChronoManager();
192  // Prevent the compiler to generate methods to copy the object
194  void operator=(sChronoManager const&){};
195 
196  // -------------------------------------------------------------------
197  // Private data members
198  private:
199  static sChronoManager *mp_Instance;
200  // Number of threads
203  int m_nbThreadsMax;
204  // Permanent profiled steps
215  // Custom profiled steps
216  int m_nbCustomSteps;
219  // Verbose
220  int m_verbose;
221 };
222 
223 #endif
void StopCustomStep(int a_thread, int a_step)
int CheckParameters()
Check validity of all parameters.
void StartIterativeDataUpdateStep4(int a_thread)
static sChronoManager * GetInstance()
std::chrono::time_point< std::chrono::system_clock > ChronoTime
sChronoManager()
The constructor of sChronoManager.
void StartIterativeDataUpdateStep3(int a_thread)
void StartIterativeDataUpdateStep2(int a_thread)
void StartIterativeDataUpdateStep1(int a_thread)
std::chrono::seconds Secs
void SetNbCustomSteps(int a_nbCustomSteps)
void StopIterativeDataUpdateStep2(int a_thread)
void StopIterativeDataUpdateStep1(int a_thread)
Declaration of class sOutputManager.
std::chrono::hours Hs
void SetNbThreads(int a_nbThreadsForProjection, int a_nbThreadsForImageComputation)
void StopIterativeDataUpdateStep3(int a_thread)
void StopIterativeDataUpdateStep4(int a_thread)
std::chrono::duration< int64_t, std::nano > DurationNano
void StartCustomStep(int a_thread, int a_step)
int Initialize()
Initialize all thread-safe buffers for profiling.
std::chrono::minutes Mins
std::chrono::duration< int64_t, std::nano > DurationNano
This header file is mainly used to declare some macro definitions and all includes needed from the st...
std::chrono::milliseconds Ms
std::chrono::time_point< std::chrono::system_clock > ChronoTime
This class is designed to manage some profiling of the code.
sChronoManager(sChronoManager const &)
void operator=(sChronoManager const &)
void Display()
Display the results of the duration buffers.