- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried calling CPU_TIME(T) before and after code and got zero difference on frequent occasions. I could expect this if there is more than one cpu and the timer gets time from one of them only. When you have a multi-core CPU, what is the best way to get correct timing information about code execution that may be parallelised to run on more than one cpu using xmm registers?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
cpu_time usually has a resolution of 0.01 seconds, so will be unable to resolve smaller time intervals. When running multiple threads on any current OS, cpu_time attempts to add up the time spent by all threads on the associated process. You don't normally expect to reduce the total cpu time of all threads; usually you are interested in overall elapsed time. Only on Win9x did cpu_time measure elapsed time.
As Windows has equally poor resolution in system_clock, you should consider elapsed time timers such as omp_get_wtime, if using OpenMP or auto-parallel.
Windows performance timers or _rdtsc() may be useful, but require you to make a C wrapper, unless you figure out how to access the Windows timers via USE iso_c_binding. With _rdtsc, in principle, you must assure that you compare times taken only on the same CPU.
As Windows has equally poor resolution in system_clock, you should consider elapsed time timers such as omp_get_wtime, if using OpenMP or auto-parallel.
Windows performance timers or _rdtsc() may be useful, but require you to make a C wrapper, unless you figure out how to access the Windows timers via USE iso_c_binding. With _rdtsc, in principle, you must assure that you compare times taken only on the same CPU.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As TimP suggests, using omp_get_wtime can be used even for code that is not parallel, as well as code that is parallelwithout OpenMP. You just have to link in the appropriate OpenMP library (easiest way is to declare program is OpenMP but not use OpenMP parallelization in your code). Of course, if your program is already using OpenMP, there is nothing to doother than calling the function.
An alternate method is to use the Windows functions QueryPerformanceCounterand QueryPerformanceCounterFrequency. These functions are available to IVF (interfaces can be found in the IVF include folder).
Jim Dempsey
An alternate method is to use the Windows functions QueryPerformanceCounterand QueryPerformanceCounterFrequency. These functions are available to IVF (interfaces can be found in the IVF include folder).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the info. I will try the omp routine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page