Currently I'm trying to time a process to compare with a sample program I found online that used opencl. Yet when I try to time this process I'll get very strange values as shown below.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <CL/cl.h>
#include <time.h>
int main(void) {
int n = 100000;
size_t bytes = n * sizeof(double);
double *h_a;
double *h_b;
double *h_c;
h_a = (double*)malloc(bytes);
h_b = (double*)malloc(bytes);
h_c = (double*)malloc(bytes);
int i;
for(i = 0; i < n; i++)
{
h_a[i] = sinf(i)*sinf(i);
h_b[i] = cosf(i)*cosf(i);
}
clock_t start = clock();
for(i = 0; i < n; i++)
h_c[i] = h_a[i] + h_b[i];
clock_t stop = clock();
double time = (stop - start) / CLOCKS_PER_SEC;
printf("Clocks per Second: %E\n", CLOCKS_PER_SEC);
printf("Clocks Taken: %E\n", stop - start);
printf("Time Taken: %E\n", time);
free(h_a);
free(h_b);
free(h_c);
system("PAUSE");
return 0;
}
Results:
C:\MinGW\Work>systesttime
Clocks per Second: 1.788208E-307
Clocks Taken: 1.788208E-307
Time Taken: 0.000000E+000
Press any key to continue . . .
Its giving very strange values for everything there. I understand that it must be around 1,000,000 and I don't know why its doing this. It used to give values around 6E+256 for everything which was equally concerning.