I have serial code to parallelize through OpenMP. I put the appropriate pragmas and tested it. During testing, I interpret performance by checking the time spent in the main function. The strangest thing is the elapsed time, calculated through cpu_time() , and omp_get_wtime() returns two different results. What do you think is the reason?
The elapsed time calculated using the cpu_time() function is like sequential time.
Before you start computing
 ctime1_ = cpu_time(); #ifdef _OPENMP ctime1 = omp_get_wtime(); #endif 
After completing the calculations
 ctime2_ = cpu_time(); #ifdef _OPENMP ctime2 = omp_get_wtime(); #endif 
Cpu_time () function definition
 double cpu_time(void) { double value; value = (double) clock () / (double) CLOCKS_PER_SEC; return value; } 
Print result
 printf("%f - %f seconds.\n", ctime2 - ctime1, ctime2_ - ctime1_); 
Result Example
 7.009537 - 11.575277 seconds. 
mert  source share