I'm having issues with execution times of C OpenMP scripts.
Timing within the script is done on a block of code using the gettimeofday() function:
gettimeofday(&tim, NULL);
double t1=tim.tv_sec+(tim.tv_usec/1000000.0);
.. Timed Code Here
gettimeofday(&tim, NULL);
double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
printf("%.6lf seconds elapsed\n", t2-t1);
However when I run the scripts successively the time for each execution increases:
The script has not been edited since yesterday where I did not have this issue. Also, I found that when leaving some time (say 10-20 seconds) then rerunning the program execution the time starts to decrease.
My only guess is that it is something to to with the process itself. I am using GCC version 4.8.2 to compile on Linux Mint 17 Using XFCE (gcc 4.8.2-19ubuntu1):
gcc bluromp.c -fopenmp -o bluromp.out
Any ideas?
EDIT: Added clock() from time.h for testing:
start_t = clock();
.. Timed Code Here
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
printf("Time.h clock result: %ld\n", total_t);
Results:
Clock is also increasing although workload is in program is the same (as said previously, if I wait ~20 seconds execution time is less
EDIT 2:
When running on another machine the results for successive runs of the program are correct, so the problem lies on my system somewhere.
EDIT 3:
Using Sync does not help, this morning my timings seem to jump rather than simply increase, I think it must be a cache or memory issue somewhere:
EDIT 4:
Used vmstat to get memory/cpu info: