C++ main module for emicrom Package  1.0
CORE_Thread.h
Go to the documentation of this file.
1 #ifndef CORE_Thread_H
2 #define CORE_Thread_H
3 
4 #include "CORE_Object.h"
5 
6 #include "CORE_Time.h"
7 
8 
9 
20 class CORE_Thread : public CORE_Object {
22  // ATTRIBUTES
23 
24 private:
25 
28 
29  //for each processor:
30 
31  //time manager
33 
34  //array of size nThreads id -> map<methods,chrono time>
35  map<tString,tULLInt> *mTimes;
36 
37  //array of size nThreads id -> map<methods,chrono time>
38  map<tString,tULLInt> *mStepTimes;
39 
40  //method -> number of calls
41  map<tString,tUInteger> *mCallsNumber;
42 
43 
44 
45  // ASSOCIATIONS
46 
47 
48 protected:
49  // METHODS
50 
51  // CONSTRUCTORS
52 
54  CORE_Thread(void);
55 
56 
57 
58  // DESTRUCTORS
59 
60 
63  virtual ~CORE_Thread(void);
64 
65 
66 public:
67  // NEW methods
71  static inline SP::CORE_Thread New() {
72  SP::CORE_Thread p(new CORE_Thread(),CORE_Thread::Delete());
73  p->setThis(p);
74  return p;
75  }
76 
77 
78  // THREADS Methods
79  //================
83  virtual tBoolean isOpenMPMultiThreaded() const {
84  return false;
85  }
89  virtual tUInteger getThreadId() const {
90  return 0;
91  }
96  virtual void setThreadsNumber(const tUIndex& nThreads,
97  const tBoolean& isProfiling);
98 
99 
100 
101 
105  virtual tUInteger getThreadsNumber() const {
106  return mThreadsNumber;
107  }
111  virtual tUInteger getMaxThreadsNumber() const {
112  return 1;
113  }
117  inline const tBoolean& isProfiling() const {
118  return mIsProfiling;
119  }
120 
121 
122  //time methods
123  //===========
124 
125 
129  virtual tULLInt getTime() const {
130  return mTime.getClockTime();
131  }
135  virtual tULLInt getDuration(const tULLInt& startChrono) const {
136  return mTime.getClockDuration(startChrono);
137  }
138 
144  inline void startChrono(const tString& method) {
145  startChrono(0,method);
146  }
147 
154  void startChrono(const tUIndex& id,const tString& method);
155 
162  inline void stopChrono(const tString& method) {
163  stopChrono(0,method,true);
164  }
165 
173  inline void stopChrono(const tUIndex& id,const tString& method) {
174  stopChrono(id,method,true);
175  }
184  void stopChrono(const tUIndex& id,
185  const tString& method,
186  const tBoolean& isCallsNumberIncremented);
187 
188 
189 
194  tLDouble getChrono(const tString& method);
195 
200  tUInteger getCallsNumber(const tString& method);
201 
205  tString profiling();
206 
207 
208 
209  // OTHERS methods
210 
211 };
212 
213 #endif
virtual tUInteger getMaxThreadsNumber() const
get the max number of threads
Definition: CORE_Thread.h:111
map< tString, tULLInt > * mTimes
Definition: CORE_Thread.h:35
CORE_Thread(void)
create an object
Definition: CORE_Thread.cpp:4
This class describes a program routine analyser.
Definition: CORE_Thread.h:20
#define tLDouble
Definition: types.h:54
#define tUInteger
Definition: types.h:91
this class describes a time class
Definition: CORE_Time.h:64
virtual tULLInt getDuration(const tULLInt &startChrono) const
get duration in milliseconds
Definition: CORE_Thread.h:135
#define tBoolean
Definition: types.h:139
void stopChrono(const tString &method)
stop the chrono in the method
Definition: CORE_Thread.h:162
tLDouble getChrono(const tString &method)
get the time spent in the method
Definition: CORE_Thread.cpp:127
void startChrono(const tString &method)
start chrono at the method method
Definition: CORE_Thread.h:144
static SP::CORE_Thread New()
create an instance of thread
Definition: CORE_Thread.h:71
map< tString, tUInteger > * mCallsNumber
Definition: CORE_Thread.h:41
map< tString, tULLInt > * mStepTimes
Definition: CORE_Thread.h:38
tString profiling()
make the profiling
Definition: CORE_Thread.cpp:152
tUInteger mThreadsNumber
Definition: CORE_Thread.h:27
void stopChrono(const tUIndex &id, const tString &method)
stop chrono of the method name in process id
Definition: CORE_Thread.h:173
virtual ~CORE_Thread(void)
destroy an object.
Definition: CORE_Thread.cpp:15
#define tUIndex
Definition: types.h:126
tBoolean mIsProfiling
Definition: CORE_Thread.h:26
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
virtual tULLInt getTime() const
get time
Definition: CORE_Thread.h:129
tUInteger getCallsNumber(const tString &method)
get the number of calls of method
Definition: CORE_Thread.cpp:140
const tBoolean & isProfiling() const
return true if the code is profiling
Definition: CORE_Thread.h:117
virtual tBoolean isOpenMPMultiThreaded() const
return true if the program is multithreaded by OpenMP
Definition: CORE_Thread.h:83
virtual tUInteger getThreadsNumber() const
get the threads number
Definition: CORE_Thread.h:105
static tULLInt getClockTime()
Definition: CORE_Time.h:621
virtual void setThreadsNumber(const tUIndex &nThreads, const tBoolean &isProfiling)
set the number of threads
Definition: CORE_Thread.cpp:26
SP_OBJECT(CORE_Thread)
virtual tUInteger getThreadId() const
get the thread id
Definition: CORE_Thread.h:89
#define tULLInt
Definition: types.h:45
DEFINE_SPTR(CORE_Thread)
CORE_Time mTime
Definition: CORE_Thread.h:32
static tULLInt getClockDuration(const tULLInt &startTime)
Definition: CORE_Time.h:628
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141