Last change
on this file since 2120 was
1661,
checked in by yushan, 5 years ago
|
MARK: branch merged with trunk @1660. Test (test_complete, test_remap) on ADA with IntelMPI and _usingEP/_usingMPI as switch.
|
File size:
1.1 KB
|
Line | |
---|
1 | #include "timerRemap.hpp" |
---|
2 | #include "mpi.hpp" |
---|
3 | #include <string> |
---|
4 | #include <map> |
---|
5 | #include <iostream> |
---|
6 | #ifdef _usingEP |
---|
7 | using namespace ep_lib; |
---|
8 | #endif |
---|
9 | |
---|
10 | namespace sphereRemap { |
---|
11 | |
---|
12 | using namespace std; |
---|
13 | |
---|
14 | map<string,CTimer*> *CTimer::allTimer_ptr = 0; |
---|
15 | |
---|
16 | CTimer::CTimer(const string& name_) : name(name_) |
---|
17 | { |
---|
18 | reset(); |
---|
19 | } |
---|
20 | |
---|
21 | double CTimer::getTime(void) |
---|
22 | { |
---|
23 | return MPI_Wtime(); |
---|
24 | } |
---|
25 | |
---|
26 | void CTimer::suspend(void) |
---|
27 | { |
---|
28 | if (!suspended) |
---|
29 | cumulatedTime+=getTime()-lastTime; |
---|
30 | suspended=true; |
---|
31 | } |
---|
32 | |
---|
33 | void CTimer::resume(void) |
---|
34 | { |
---|
35 | if (suspended) |
---|
36 | lastTime=getTime(); |
---|
37 | suspended=false; |
---|
38 | } |
---|
39 | |
---|
40 | void CTimer::reset(void) |
---|
41 | { |
---|
42 | cumulatedTime=0.; |
---|
43 | suspended=true; |
---|
44 | } |
---|
45 | |
---|
46 | double CTimer::getCumulatedTime(void) |
---|
47 | { |
---|
48 | return cumulatedTime; |
---|
49 | } |
---|
50 | |
---|
51 | void CTimer::print(void) |
---|
52 | { |
---|
53 | #ifdef TIMEIT |
---|
54 | cout << " Time for "<<name<<" : "<<getCumulatedTime() <<" s"<<endl; |
---|
55 | #endif |
---|
56 | } |
---|
57 | |
---|
58 | CTimer& CTimer::get(const string name) |
---|
59 | { |
---|
60 | map<string,CTimer*>::iterator it; |
---|
61 | if(allTimer_ptr == 0) allTimer_ptr = new map<string,CTimer*>; |
---|
62 | it=allTimer_ptr->find(name); |
---|
63 | if (it==allTimer_ptr->end()) it=allTimer_ptr->insert(pair<string,CTimer*>(name,new CTimer(name))).first; |
---|
64 | return *(it->second); |
---|
65 | } |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.