Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created February 17, 2014 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaityo256/9046979 to your computer and use it in GitHub Desktop.
Save kaityo256/9046979 to your computer and use it in GitHub Desktop.
#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