Created
February 17, 2014 08:45
-
-
Save kaityo256/9046979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
const int N=10000000; | |
double a[N],b[N],c[N],d[N]; | |
double | |
myrand(void){ | |
return (double)rand()/((double)RAND_MAX+1.0); | |
} | |
int | |
main(void){ | |
for(int i=0;i<N;i++){ | |
a[i] = myrand(); | |
b[i] = myrand(); | |
c[i] = myrand(); | |
d[i] = 0.0; | |
} | |
clock_t t1 = clock(); | |
#pragma acc kernels | |
for(int j=0;j<100;j++){ | |
for(int i=0;i<N;i++){ | |
d[i] = a[i] * b[i] + c[i]; | |
} | |
} | |
clock_t t2 = clock(); | |
printf("%d\n",t2-t1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment