Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created Feb 17, 2014
Embed
What would you like to do?
#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