HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
do not block execution of the thread.For a simple lock, the omp_test_lock function
returns non-zero if the lock is successfully set; otherwise, it returns zero.
For a nestable lock, the omp_test_nest_lock function returns the new nesting count
if the lock is successfully set; otherwise, it returns zero.
Timing Functions
The functions described in this section support a portable wall-clock timer:
• omp_get_wtime
• omp_get_wtick
omp_get_wtime
#include <omp.h>
double omp_get_wtime(void);
The omp_get_wtime function returns a double-precision floating-point value equal to
the elapsed wall clock time in seconds since some time in the past. The actual time in
the past is arbitrary, but it is guaranteed not to change during the execution of the
application program.
The function may be used to measure elapsed times as shown in the following example:
double start;
double end;
start = omp_get_wtime();
... work to be timed ...
end = omp_get_wtime();
printf(“Work took %f sec. time.\n”, end-start);
The time returned is per-thread times. They are not required to be globally consistent
across all the threads participating in an application.
omp_get_wtick
#include <omp.h>
double omp_get_wtick(void);
The omp_get_wtick function returns a double-precision floating-point value equal to
the number of seconds between successive clock ticks.
Parallel Programming Using OpenMP 217