CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Difference between "ExecutionTime" and "ClockTime"

Register Blogs Community New Posts Updated Threads Search

Like Tree21Likes
  • 1 Post By lakeat
  • 19 Post By Simon Lapointe
  • 1 Post By mathslw

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 24, 2009, 06:44
Default Difference between "ExecutionTime" and "ClockTime"
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Dear all,

A small question, what is the difference between "ExecutionTime" and "ClockTime"?

I can get these lins from icoFoam.C,
Code:
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
someone said:
Quote:
elapsedCPUTime() is the elapsed CPU time.
elapsedClockTime() is the elapsed wall clock time.
  1. Could anyone explain this in detail?
  2. If ClockTime means something, why then that we have to care about ExecutionTime?
  3. Is there any meaning concerning the ratio of ClockTime over ExecutionTime? Latency, or what?
  4. How can I change the writing format of these time, eg. show four decimal places in second.?

Thanks in advance for any reply.
rarnaunot likes this.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   August 24, 2009, 06:56
Default
  #2
Senior Member
 
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18
sandy is on a distinguished road
Look at hani:
http://www.tfd.chalmers.se/~hani/kur...tyTutorial.pdf
in page 43.
sandy is offline   Reply With Quote

Old   August 24, 2009, 21:19
Default
  #3
Member
 
Simon Lapointe
Join Date: May 2009
Location: Québec, Qc, Canada
Posts: 33
Rep Power: 16
Simon Lapointe is on a distinguished road
Hi,

I'm not an expert but here's what I think,

1) There isn't much to add there, the ExecutionTime is the time spent by the processor and the ClockTime is the wall clock time or "real" time if you prefer.

2 & 3) There is an interest because a significative difference between the ExecutionTime and the ClockTime is a sign of a slow calculation. The difference can be explained by the time when a file is being written or when there is communication between processors in a parallel run. Using a computer with a slow interconnect or not enough cells per processor can cause a difference in cpu and clock time.

Hope that helps
Simon Lapointe is offline   Reply With Quote

Old   August 24, 2009, 21:58
Default
  #4
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Quote:
Originally Posted by Simon Lapointe View Post
Hi,

I'm not an expert but here's what I think,

1) There isn't much to add there, the ExecutionTime is the time spent by the processor and the ClockTime is the wall clock time or "real" time if you prefer.

2 & 3) There is an interest because a significative difference between the ExecutionTime and the ClockTime is a sign of a slow calculation. The difference can be explained by the time when a file is being written or when there is communication between processors in a parallel run. Using a computer with a slow interconnect or not enough cells per processor can cause a difference in cpu and clock time.

Hope that helps

I noticed this is your first two posts on the forum, and they are so helpful, thank you.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   September 1, 2014, 10:53
Default
  #5
New Member
 
Wei Liu
Join Date: Apr 2011
Location: West Lafayette, IN
Posts: 29
Rep Power: 15
mathslw is on a distinguished road
Quote:
Originally Posted by lakeat View Post
Dear all,

A small question, what is the difference between "ExecutionTime" and "ClockTime"?

I can get these lins from icoFoam.C,
Code:
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
someone said:

  1. Could anyone explain this in detail?
  2. If ClockTime means something, why then that we have to care about ExecutionTime?
  3. Is there any meaning concerning the ratio of ClockTime over ExecutionTime? Latency, or what?
  4. How can I change the writing format of these time, eg. show four decimal places in second.?

Thanks in advance for any reply.
Hi Daniel,

Have you found the answer to your 4th question? Thanks!

Wei
louisgag likes this.
mathslw is offline   Reply With Quote

Old   September 11, 2020, 09:52
Default
  #6
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Stuttgart, Germany
Posts: 338
Rep Power: 18
louisgag is on a distinguished road
Send a message via ICQ to louisgag
Quote:
Originally Posted by mathslw View Post
Hi Daniel,

Have you found the answer to your 4th question? Thanks!

Wei

I had the same question and search a bit through the code.
It does not seem quite simple to do, or at least if it is I have not found how.
I think you would have to change the main code of OpenFOAM (I've looked at the .com version, pimpleFoam solver) or some of the principal libraries.


Here's my analysis, please jump in if you know more!

In the solver you call
Code:
runTime.printExecutionTime(Info);
and there are both

Code:
elapsedClockTime
Code:
elapsedCpuTime
printed. But both are not printed with the same precision.

elapsedCpuTime relies on the diff function which returns a scalar (double) coming from the C++ difftime function and elapsedClockTime relies directly on the C++ difftime function.


So the difference actually comes from the type of the arguments to the difftime function. For clockTime C++ time_t type is used and is in seconds. For cpuTime the call is to std::clock which returns a "processor time" which is no longer an integer.


The solution would be to somehow modify/rewrite the call from getTime to use chrono, something as what is given in here: https://stackoverflow.com/questions/...d-part-of-time
louisgag is offline   Reply With Quote

Old   September 1, 2023, 02:08
Default improve the precision of the excutive time
  #7
New Member
 
Join Date: Jul 2019
Location: MARS
Posts: 9
Rep Power: 6
lxufeishi is on a distinguished road
Quote:
Originally Posted by mathslw View Post
Hi Daniel,

Have you found the answer to your 4th question? Thanks!

Wei
The "clockTime" Class would help, as its description:
"Starts timing and returns elapsed time from start. Uses std::chrono::high_resolution_clock for better resolution (2uSec instead of ~20mSec) than cpuTime. "

So the code would be like:
Code:
#include "clockTime.H"

Foam::clockTime myTime; 

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
      //<< "  ClockTime = " << runTime.elapsedClockTime() << " s"
      << "  ClockTime = " << myTime.elapsedTime() << " s"
      << endl;
lxufeishi is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:25.