How can I make this code cuda (cpu code to cuda code) -
i have programme in c++ , want create code cuda, looking way assumption is: 1-global variable 2-global array
question #1: need define device array host array in global?
question #2: can utilize device array only?
question #3: want optimize code,where utilize loop in parallel better?
func_2() hard part converting cuda me,please show simplified code
the code simplified is:
#define r 16 #define c 32 #define run_t 60 #define max 3000 double array1 [r][c]; double array2 [r]; double array3 [r]; double array4 [c]; double r; double min; int main() { int iter,run,j; double mean; srand(time(null)); (run=0;run<run_t;run++)// 60 loop { func_1(); func_2(); (iter=0;iter< max ;iter++)//3000 loop { func_3(); func_4(); func_5(); func_6(); func_7(); } } } double func_00(array4[c]) { double top=0; for(int j=0;j<c;j++) top=array4[j]*array4[j] homecoming top; } void func_0(int index) { for(int j=0;j<c;j++) { r= rand()+1/2+index;//for illustration } array2[index]= func_00(array4[]); } void fun_1() { int i; for(i=0;i<r;i++) { func_0(i); } for(i=0;i<c;i++) { array4 = array1[0][i]; } } void fun_2() { int i,j; for(i=0;i<r;i++) { if(array2[r]<min) { min=array2[i]; for(j=0;j<c;j++) array4[j]=array1[i][j]; } } } void func_3(){} void func_4(){} void func_5(){} void func_6(){} void func_7(){}
a great place start learning cuda nvidia's cuda education website
porting cuda depends on exact needs , complex reply concisely.
cuda
No comments:
Post a Comment