/**************************************************************** C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example : PrefixSumGlobalMemDP.c Objective : Calcualte prefix sum of an array of N elements using global memory (Double precision) Input : None Output : Execution time in seconds, gflops achieved Created : August-2013 E-mail : hpcfte@cdac.in *************************************************************/ /*source code for Prefix sum*/ #include #include #include #include #include #include #define EPS 1.0e-8f /* threshhold aprrox epsilion value */ #define SIZE 128 // change this to run for different sizes /* opencl check status mecro*/ #define OPENCL_CHECK_STATUS(NAME,ERR) {\ const char *name=NAME;\ cl_int Terr=ERR;\ if (Terr != CL_SUCCESS) {\ printf("\n\t\t Error: %s (%d) \n",name, Terr);\ exit(-1);} }\ const char * kernelSourcePath = "PrefixSumGlobalMemDP_kernel.cl"; int prefixSumCheckResultGMDP(double *inputArray,double *output,int arrayLength); /* * Fill in the vector with single precision values */ void fill_dp_vector(double* vec,int size) { int ind; for(ind=0;ind fabs(output[j])) relativeError = fabs((temp_out[j] - output[j]) / temp_out[j]); else relativeError = fabs((output[j] - temp_out[j]) / output[j]); if (relativeError > eps && relativeError != 0.0e+00 ) { if(errorNorm < relativeError) { errorNorm = relativeError; flag=1; } } } if( flag == 1) { printf(" \n Results verfication : Failed"); printf(" \n Considered machine precision : %e", eps); printf(" \n Relative Error : %e \n", errorNorm); } if(flag==0) { printf("\n\n\t Result Varification success:\n"); } // printf("\n"); free(temp_out); return 0; }