Last change
on this file since 2146 was
694,
checked in by rlacroix, 9 years ago
|
Fix compilation issues caused by the new "remap" library.
Use our MPI header so that C++ bindings are always disabled.
|
File size:
972 bytes
|
Rev | Line | |
---|
[688] | 1 | #include "timerRemap.hpp" |
---|
[694] | 2 | #include "mpi.hpp" |
---|
[688] | 3 | #include <string> |
---|
| 4 | #include <map> |
---|
| 5 | #include <iostream> |
---|
| 6 | |
---|
| 7 | namespace sphereRemap { |
---|
| 8 | |
---|
| 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | map<string,CTimer*> CTimer::allTimer; |
---|
| 12 | |
---|
| 13 | CTimer::CTimer(const string& name_) : name(name_) |
---|
| 14 | { |
---|
| 15 | reset(); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | double CTimer::getTime(void) |
---|
| 19 | { |
---|
| 20 | return MPI_Wtime(); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | void CTimer::suspend(void) |
---|
| 24 | { |
---|
| 25 | if (!suspended) |
---|
| 26 | cumulatedTime+=getTime()-lastTime; |
---|
| 27 | suspended=true; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | void CTimer::resume(void) |
---|
| 31 | { |
---|
| 32 | if (suspended) |
---|
| 33 | lastTime=getTime(); |
---|
| 34 | suspended=false; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | void CTimer::reset(void) |
---|
| 38 | { |
---|
| 39 | cumulatedTime=0.; |
---|
| 40 | suspended=true; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | double CTimer::getCumulatedTime(void) |
---|
| 44 | { |
---|
| 45 | return cumulatedTime; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | void CTimer::print(void) |
---|
| 49 | { |
---|
| 50 | #ifdef TIMEIT |
---|
| 51 | cout << " Time for "<<name<<" : "<<getCumulatedTime() <<" s"<<endl; |
---|
| 52 | #endif |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | CTimer& CTimer::get(const string name) |
---|
| 56 | { |
---|
| 57 | map<string,CTimer*>::iterator it; |
---|
| 58 | it=allTimer.find(name); |
---|
| 59 | if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first; |
---|
| 60 | return *(it->second); |
---|
| 61 | } |
---|
| 62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.