36Timer<T>::Timer(
int maxTimeSteps,
size_t numFluidCells,
unsigned int printModeSummary)
37 : clout(std::cout,
"Timer"),
38 deltaTS(0), curTS(0), maxTS(maxTimeSteps),
39 numFC(numFluidCells), rtRemMs(1)
43 this->_printModeSummary = printModeSummary;
49 const T msDiff ( 1000*(end.tv_sec - start.tv_sec)
50 +(end.tv_usec-start.tv_usec)/1000 );
51 return util::max<T>(msDiff, 1.0);
57 T mlups = (numFC * deltaTS) / (timevalDiffTimeMs(msTimeCur, msTimeLast)*1000);
65#ifdef PARALLEL_MODE_OMP
74 T tmlups = (numFC * curTS) /
double(timevalDiffTimeMs(msTimeEnd, msTimeStart)*1000);
82#ifdef PARALLEL_MODE_OMP
92 sTimeStart = time(tp);
93 gettimeofday(&msTimeStart,
nullptr);
94 gettimeofday(&msTimeCur,
nullptr);
95 cpuTimeStart = clock();
102 cpuTimeCur = clock();
104 msTimeLast = msTimeCur;
105 gettimeofday(&msTimeCur,
nullptr);
108 deltaTS = currentTimeStep - curTS;
109 curTS = currentTimeStep;
111 rtPas = difftime(sTimeCur,sTimeStart);
112 rtTot = rtPas*maxTS/util::max<int>(curTS, 1);
115 rtPasMs = timevalDiffTimeMs(msTimeCur, msTimeStart);
116 rtTotMs = rtPasMs*maxTS/util::max<int>(curTS, 1);
117 rtRemMs = rtTotMs-rtPasMs;
119 ctPas = (cpuTimeCur-cpuTimeStart)/CLOCKS_PER_SEC;
120 ctTot = ctPas*maxTS/util::max<int>(curTS, 1);
128 cpuTimeEnd = clock();
130 gettimeofday(&msTimeEnd,
nullptr);
136 return (cpuTimeEnd-cpuTimeStart)/CLOCKS_PER_SEC;
142 return difftime(sTimeEnd,sTimeStart);
148 return timevalDiffTimeMs(msTimeEnd, msTimeStart);
154 if (currentTimeStep!=curTS) {
155 update(currentTimeStep);
157 printStep(printMode);
163 printStep(clout, printMode);
172 <<
"step=" << curTS <<
"; "
174 <<
"percent=" << 100.0*curTS/maxTS <<
"; "
175 <<
"passedTime=" << (double)rtPasMs/1000 <<
"; "
177 <<
"remTime=" << rtRemMs/1000 <<
"; "
178 <<
"MLUPs=" << getMLUPs()
185 << curTS <<
"/" << maxTS <<
" (" << 100*curTS/maxTS <<
"%); "
187 << std::setprecision(2) << std::fixed << (double)rtPasMs/1000 <<
"/"
188 << std::setprecision(1) << std::fixed << (double)rtTotMs/1000 <<
"s; "
190 << std::setw(2) << (int)((
double)rtRemMs/1000)/60 <<
"m " << std::setfill(
'0') << std::setw(4) << (double)((
int)((double)rtRemMs/100)%600)/10 <<
"s; "
192 <<
"MLUPs: " << getMLUPs()
198 << std::setw(21) << std::left <<
"Lattice-Timesteps"
199 << std::setw(17) << std::left <<
"| CPU time/estim"
200 << std::setw(18) << std::left <<
"| REAL time/estim"
201 << std::setw(6) << std::left <<
"| ETA"
202 << std::setw(6) << std::left <<
"| MLUPs"
203 << std::endl << std::right
204 << std::setw(6) << std::setprecision(2) << std::fixed << curTS <<
"/" << std::setw(6) << maxTS <<
" (" << std::setw(3) << 100*curTS/maxTS <<
"%) |"
205 << std::setw(7) << ctPas <<
"/" << std::setw(7) << ctTot <<
" |"
206 << std::setw(8) << (double)rtPasMs/1000 <<
"/" << std::setw(7) << (double)rtTotMs/1000 <<
" |"
207 << std::setw(4) << (int)rtRemMs/1000+1 <<
" |"
208 << std::setw(6) << getMLUPs()
214 <<
"step " << curTS <<
"; "
215 <<
"MLUPs=" << std::setw(8) << getMLUPs() <<
", MLUPps=" << std::setw(8) << getMLUPps() << std::endl;
219 fout <<
"Error in function printStep in class_timer.h: printMode="<<printMode<<
" not found" << std::endl << std::flush;
233 fout <<
"----------------Summary:Timer----------------" << std::endl;
234 fout <<
"measured time (rt) : " << (int)getTotalRealTimeMs()/1000 <<
"." << (int)getTotalRealTimeMs()-(int)getTotalRealTimeMs()/1000*1000 <<
"s" << std::endl;
235 fout <<
"measured time (cpu): " << std::setprecision(3) << std::fixed << getTotalCpuTime() <<
"s" << std::endl;
236 if (numFC > 0 && curTS > 0) {
237 fout <<
"average MLUPs : " << getTotalMLUPs() << std::endl;
238 fout <<
"average MLUPps: " << getTotalMLUPps() << std::endl;
240 fout <<
"---------------------------------------------" << std::endl;
246 printShortSummary(clout);
252 fout <<
"realTime=" << (int)getTotalRealTimeMs()/1000 <<
"." << (int)getTotalRealTimeMs()-(int)getTotalRealTimeMs()/1000*1000
253 <<
"; cpuTime=" << std::setprecision(3) << std::fixed << getTotalCpuTime() << std::endl;
259template<
typename T,
typename DESCRIPTOR>
267 int printModeSummary = 0;
270 if ( ! param[
"Application"][
"PhysParameters"][
"PhysMaxTime"].read(physMaxT) ) {
271 if ( ! param[
"Application"][
"PhysParam"][
"MaxTime"].read(physStartT) ) {
272 clout <<
"PhysMaxTime not found" << std::endl;
275 clout <<
"Application::PhysParam::MaxTime needs to be renamed to Application::PhysParameters::PhysMaxTime" << std::endl;
279 param.
readOrWarn<
int>(
"Output",
"Timer",
"PrintModeSummary", printModeSummary,
true,
false,
false);
290 return new Timer<T>(maxT, numLatticePoints, printModeSummary);
class for marking output with some text
Conversion between physical and lattice units, as well as discretization.
constexpr size_t getLatticeTime(T physTime) const
conversion from physical to lattice time
bool readOrWarn(std::string name_parameter_1, std::string name_parameter_2, std::string name_parameter_3, ParameterType &var, bool defaultAvailable=true, bool exitIfMissing=false, bool showWarning=true) const
This wrapper function reads the given parameter from the "type_parameter" and "name_parameter_1" or "...
int getSize() const
Returns the number of processes.
Timer(int maxTimeSteps, std::size_t numFluidCells=1, unsigned int printModeSummary=0)
initializes timer with the given values, abbreviation to Timer() + initialize(int,...
void printStep(int printMode=0)
Prints a one-line-summary of the values calculated in update() for use during computation.
void printShortSummary()
Prints a short summary containing only time consumptions (real and cpu time)
T getMLUPs()
returns Million DESCRIPTOR Site Updates per second (all processes together)
T getTotalRealTime()
Returns the total measured time between start() and stop() in seconds.
void update(int currentTimeStep)
Updates all time values of interest during computation.
void print(std::size_t currentTimeStep, int printMode=0)
Performs an update() followed by a printStep().
T getTotalMLUPps()
returns average Million DESCRIPTOR Site Updates per second and process between start() and stop()
T getTotalMLUPs()
returns average Million DESCRIPTOR Site Updates per second between start() and stop()
double getTotalCpuTime()
Returns the total cpu time in seconds between start() and stop().
T getMLUPps()
returns Million DESCRIPTOR Site Updates per second and process
T getTotalRealTimeMs()
Returns the total measured time between start() and stop() in ms.
void start()
(Re-)sets start value for time measurement.
T timevalDiffTimeMs(timeval end, timeval start)
returns the time difference between two timeval objects in ms
void stop()
Terminates time measurement and sets end value.
void printSummary()
Prints a (short) summary containing the overall time consumption in real and in cpu time for use afte...
Wrapper functions that simplify the use of MPI.
Timer< T > * createTimer(XMLreader ¶m, const UnitConverter< T, DESCRIPTOR > &converter, size_t numLatticePoints)
Top level namespace for all of OpenLB.
This class allows calculation and display of various time data including remaining runtime data in cp...