OpenMP time and clock() give two different results

The clock() function returns CPU time, not wall time. Instead, use gettimeofday().


The clock function measures cpu time, the time you spend actively on the CPU, the OMP function measures the time as it has passed during execution, two completely different things.

Your process seems to be blocked in waiting somewhere.


What you observe is a perfectly valid result for any parallel application - the combined CPU time of all threads as returned by clock() is usually more than the wallclock time measured by omp_get_wtime() except if your application mostly sleeps or waits.

Tags:

C

Openmp