Timers
From ScorecWiki
(Difference between revisions)
Revision as of 13:33, 21 October 2010 Cwsmith (Talk | contribs) ← Previous diff |
Revision as of 14:57, 7 August 2011 Cwsmith (Talk | contribs) Next diff → |
||
Line 5: | Line 5: | ||
1- cycle counting (rdtsc cycle counter) - [http://www.mcs.anl.gov/~kazutomo/rdtsc.html source code] | 1- cycle counting (rdtsc cycle counter) - [http://www.mcs.anl.gov/~kazutomo/rdtsc.html source code] | ||
* precise (CS) | * precise (CS) | ||
- | * cpu frequency required | + | * cpu frequency required |
+ | ** get the cpu frequency with <code> | ||
+ | cat /proc/cpuinfo | grep -i "cpu MHZ" -m 1 | awk '{print $4}'</code> | ||
+ | ** sample code <code> | ||
+ | #define CPUFREQ <INSERT FREQUENCY IN Hz HERE> | ||
+ | total_time = finish_time - start_time; | ||
+ | printf ("It took %.8lf seconds.\n", total_time / CPUFREQ );</code> | ||
* low cost and resolution (OS) | * low cost and resolution (OS) | ||
Revision as of 14:57, 7 August 2011
This page serves as a gateway for information related to computing the elapsed time between two positions in your software.
C/C++
1- cycle counting (rdtsc cycle counter) - source code
- precise (CS)
- cpu frequency required
- get the cpu frequency with
- get the cpu frequency with
cat /proc/cpuinfo | grep -i "cpu MHZ" -m 1 | awk '{print $4}'
- sample code
- sample code
#define CPUFREQ <INSERT FREQUENCY IN Hz HERE> total_time = finish_time - start_time; printf ("It took %.8lf seconds.\n", total_time / CPUFREQ );
- low cost and resolution (OS)
2- MPI_WTime()
- May offer a high resolution than 1 second.(CS)
3- MPI_WTick()
- can be queried to determine resolution. (CS)
4- getTimeOfDay() and friends (sys/time.h)
- portable (BM)
- not always precise or accurate (BM)
- may be relatively expensive on IBM BG (compared to cycle counting) (OS)
5- time.h/ctime.h functions (Reference : http://www.cppreference.com/wiki/c/date/start )
- Have a higher resolution than 1 second (CS)
- clock function returns elapsed CPU cycles (CS)
- Needs cpu frequency which may be inaccurate on POSIX compilers (CS)
Note: Feel free to make corrections -- MM