
Hello, I would like to calculate the runtime of my algorithms. I have written a MPI based algorithms and must determine the duration of the algorithm on each CPU. I would like to show the really duration, which is based on Amdahls law, so I need a "exactly" timer. Can I use the Boost Timer / Boost MPI Timer to calculate the duration between start and end of my algorithm? On large datasets I think the timer is a good choice. Is the resolution of the timer object just enough for small amounts of data? I would like to do this: timer t; run_algorithm; std::cout << t.elapsed << std::endl; Is a timer object a good choice to determine runtime structure or do you a better structure? Thanks Phil

On Aug 14, 2011, at 3:40 PM, Kraus Philipp
timer t; run_algorithm; std::cout << t.elapsed << std::endl;
Boost.Timer has some problems, I've seen it measure CPU time instead of wall time on some platforms and I'm not sure about the accuracy. I don't know about the MPI timer, but I would go with Chrono until Stopwatches is out. Cheers Gordon

On 2011-08-14 23:22:38 +0200, Gordon Woodhull said:
On Aug 14, 2011, at 3:40 PM, Kraus Philipp
wrote: timer t; run_algorithm; std::cout << t.elapsed << std::endl;
Boost.Timer has some problems, I've seen it measure CPU time instead of wall time on some platforms and I'm not sure about the accuracy.
I don't know about the MPI timer, but I would go with Chrono until Stopwatches is out.
Do you know anything about "CPU cycling"? Can I detect the CPU cycles which are elapsed during runtime? I need a "time value" for detecting runtime only. Thanks Phil

On Aug 14, 2011, at 5:26 PM, Philipp Kraus
Do you know anything about "CPU cycling"? Can I detect the CPU cycles which are elapsed during runtime? I need a "time value" for detecting runtime only.
Hmm, sorry I've only heard of low level assembly ways of doing that. Doesn't sound very platform-independent! ;-) Cheers Gordon

On 08/14/2011 04:45 PM, Gordon Woodhull wrote:
On Aug 14, 2011, at 5:26 PM, Philipp Kraus
wrote: Do you know anything about "CPU cycling"? Can I detect the CPU cycles which are elapsed during runtime? I need a "time value" for detecting runtime only.
Hmm, sorry I've only heard of low level assembly ways of doing that. Doesn't sound very platform-independent! ;-)
Cheers Gordon
It's not Boost, but you can have a look at PAPI ( http://icl.cs.utk.edu/papi/ )

Am 15.08.2011 um 01:19 schrieb Ioannis Papadopoulos:
On 08/14/2011 04:45 PM, Gordon Woodhull wrote:
On Aug 14, 2011, at 5:26 PM, Philipp Kraus
wrote: Do you know anything about "CPU cycling"? Can I detect the CPU cycles which are elapsed during runtime? I need a "time value" for detecting runtime only.
Hmm, sorry I've only heard of low level assembly ways of doing that. Doesn't sound very platform-independent! ;-)
Cheers Gordon
It's not Boost, but you can have a look at PAPI ( http://icl.cs.utk.edu/papi/ )
Thanks a lot, the API should be nice, but a lot of documentation for reading Phil

If you are on an x86 platform, you can use the "rdtsc" assembly instruction to obtain processor tick counts. When I needed accurate timing, I created a function to wrap around "rdtsc", a Timer class with an API something like class Timer { public: void start(); void stop(); ulonglong elapsed(); }; Then created class using the Guard idiom around that: class AutoTimer { public: AutoTimer(Timer& t) : t_(t) { t_.start(); } ~AutoTimer() { t_.stop(); } private: Timer& t_; }; Becomes very easy to time segments of code: ... Timer t1; ... { AutoTimer a(t1); ...do stuff... } One can also continue to start/stop a Timer, thus accumulating total tick counts. Conversion of tick counts back to real time is done external to any of these classes.

On Mon, Aug 15, 2011 at 08:54:09AM -0500, Chris Cleeland wrote:
If you are on an x86 platform, you can use the "rdtsc" assembly instruction to obtain processor tick counts.
Note that many processors do not synchronize such low-level tickcounts between cores or packages, so unless you have thread affinity for a single particular one, you're in deep water unless you know your hardware does not exhibit these kinds of behaviours. -- Lars Viklund | zao@acc.umu.se

On Mon, Aug 15, 2011 at 9:07 AM, Lars Viklund
On Mon, Aug 15, 2011 at 08:54:09AM -0500, Chris Cleeland wrote:
If you are on an x86 platform, you can use the "rdtsc" assembly instruction to obtain processor tick counts.
Note that many processors do not synchronize such low-level tickcounts between cores or packages, so unless you have thread affinity for a single particular one, you're in deep water unless you know your hardware does not exhibit these kinds of behaviours.
Good point; thanks for pointing that out. In my case, I have thread affinity, guaranteed by other software requirements that pre-date the timing, so I'd forgotten.
participants (6)
-
Chris Cleeland
-
Gordon Woodhull
-
Ioannis Papadopoulos
-
Kraus Philipp
-
Lars Viklund
-
Philipp Kraus