//========================================================================================================================================================================================================200 //======================================================================================================================================================150 //====================================================================================================100 //==================================================50 //========================================================================================================================================================================================================200 // UPDATE //========================================================================================================================================================================================================200 // 14 APR 2011 Lukasz G. Szafaryn //========================================================================================================================================================================================================200 // DEFINE/INCLUDE //========================================================================================================================================================================================================200 //======================================================================================================================================================150 // LIBRARIES //======================================================================================================================================================150 #include "golden.h" //float golden [1000][4]; #include // (in path known to compiler) needed by printf #include // (in path known to compiler) needed by malloc #include // (in path known to compiler) needed by true/false #include //======================================================================================================================================================150 // UTILITIES //======================================================================================================================================================150 #include "./util/timer/timer.h" // (in path specified here) #include "./util/num/num.h" // (in path specified here) //======================================================================================================================================================150 // MAIN FUNCTION HEADER //======================================================================================================================================================150 #include "./main.h" // (in the current directory) //======================================================================================================================================================150 // KERNEL //======================================================================================================================================================150 #include "./kernel/kernel_gpu_cuda_wrapper.h" // (in library path specified here) //========================================================================================================================================================================================================200 // MAIN FUNCTION //========================================================================================================================================================================================================200 int main( int argc, char *argv []) { printf("thread block size of kernel = %d \n", NUMBER_THREADS); //======================================================================================================================================================150 // CPU/MCPU VARIABLES //======================================================================================================================================================150 // timer long long time0; time0 = get_time(); // timer long long time1; long long time2; long long time3; long long time4; long long time5; long long time6; long long time7; // counters int i, j, k, l, m, n; // system memory par_str par_cpu; dim_str dim_cpu; box_str* box_cpu; FOUR_VECTOR* rv_cpu; fp* qv_cpu; FOUR_VECTOR* fv_cpu; int nh; time1 = get_time(); //======================================================================================================================================================150 // CHECK INPUT ARGUMENTS //======================================================================================================================================================150 // assing default values dim_cpu.boxes1d_arg = 1; // go through arguments for(dim_cpu.cur_arg=1; dim_cpu.cur_arg=dim_cpu.cur_arg+1){ // check if value is a number if(isInteger(argv[dim_cpu.cur_arg+1])==1){ dim_cpu.boxes1d_arg = atoi(argv[dim_cpu.cur_arg+1]); if(dim_cpu.boxes1d_arg<0){ printf("ERROR: Wrong value to -boxes1d parameter, cannot be <=0\n"); return 0; } dim_cpu.cur_arg = dim_cpu.cur_arg+1; } // value is not a number else{ printf("ERROR: Value to -boxes1d parameter in not a number\n"); return 0; } } // value not provided else{ printf("ERROR: Missing value to -boxes1d parameter\n"); return 0; } } // unknown else{ printf("ERROR: Unknown parameter\n"); return 0; } } // Print configuration printf("Configuration used: boxes1d = %d\n", dim_cpu.boxes1d_arg); time2 = get_time(); //======================================================================================================================================================150 // INPUTS //======================================================================================================================================================150 par_cpu.alpha = 0.5; time3 = get_time(); //======================================================================================================================================================150 // DIMENSIONS //======================================================================================================================================================150 // total number of boxes dim_cpu.number_boxes = dim_cpu.boxes1d_arg * dim_cpu.boxes1d_arg * dim_cpu.boxes1d_arg; // how many particles space has in each direction dim_cpu.space_elem = dim_cpu.number_boxes * NUMBER_PAR_PER_BOX; dim_cpu.space_mem = dim_cpu.space_elem * sizeof(FOUR_VECTOR); dim_cpu.space_mem2 = dim_cpu.space_elem * sizeof(fp); // box array dim_cpu.box_mem = dim_cpu.number_boxes * sizeof(box_str); time4 = get_time(); //======================================================================================================================================================150 // SYSTEM MEMORY //======================================================================================================================================================150 //====================================================================================================100 // BOX //====================================================================================================100 // allocate boxes box_cpu = (box_str*)malloc(dim_cpu.box_mem); // initialize number of home boxes nh = 0; // home boxes in z direction for(i=0; i=0 && (j+m)>=0 && (k+n)>=0)==true && ((i+l)