求救,急!! 求大神帮我用cuda并行化一下这个求Pi 的程序
cuda吧
全部回复
仅看楼主
level 1
heavenqwx 楼主
#include<stdio.h>
#include<time.h>
#define N 1000000
main(){
double local,pi=0.0,w;
long i;
w=1.0/N;
clock_t t1=clock();
for(i=0;i<N;i++){
local=(i+0.5)*w;
pi=pi+4.0/(1.0+local*local);
}
clock_t t2=clock();
printf("PI is %.20f\n",pi*w);
printf("Time: %.2f seconds\n",(float)(t2-t1)/CLOCKS_PER_SEC);
}
2017年06月20日 07点06分 1
level 1
heavenqwx 楼主
最好进程数设为6
2017年06月20日 07点06分 2
level 1
heavenqwx 楼主
急求!
2017年06月20日 07点06分 3
level 1
heavenqwx 楼主
没人吗[泪]
2017年06月20日 07点06分 4
level 1
heavenqwx 楼主
人呢
2017年06月21日 12点06分 5
1