// #ifdef __cplusplus // extern "C" { // #endif //========================================================================================================================================================================================================200 //======================================================================================================================================================150 //====================================================================================================100 //==================================================50 //========================================================================================================================================================================================================200 // INCLUDE/DEFINE //========================================================================================================================================================================================================200 //======================================================================================================================================================150 // LIBRARIES //======================================================================================================================================================150 #include // (in path known to compiler) needed by printf #include // (in path known to compiler) needed by malloc, free //======================================================================================================================================================150 // HEADER //======================================================================================================================================================150 #include "./main.h" // (in current path) //======================================================================================================================================================150 // UTILITIES //======================================================================================================================================================150 #include "./util/graphics/graphics.h" // (in specified path) #include "./util/graphics/resize.h" // (in specified path) #include "./util/timer/timer.h" // (in specified path) //======================================================================================================================================================150 // KERNEL //======================================================================================================================================================150 #include "./kernel/kernel_gpu_opencl_wrapper.h" //======================================================================================================================================================150 // End //======================================================================================================================================================150 //========================================================================================================================================================================================================200 // MAIN FUNCTION //========================================================================================================================================================================================================200 int main( int argc, char* argv []){ printf("WG size of kernel = %d \n", NUMBER_THREADS); //======================================================================================================================================================150 // VARIABLES //======================================================================================================================================================150 // time long long time0; long long time1; long long time2; long long time3; long long time4; long long time5; long long time6; // inputs image, input paramenters fp* image_ori; // originalinput image int image_ori_rows; int image_ori_cols; long image_ori_elem; // inputs image, input paramenters fp* image; // input image int Nr,Nc; // IMAGE nbr of rows/cols/elements long Ne; // algorithm parameters int niter; // nbr of iterations fp lambda; // update step size // size of IMAGE int r1,r2,c1,c2; // row/col coordinates of uniform ROI long NeROI; // ROI nbr of elements // surrounding pixel indicies int* iN; int* iS; int* jE; int* jW; // counters int iter; // primary loop long i; // image row long j; // image col // memory sizes int mem_size_i; int mem_size_j; time0 = get_time(); //======================================================================================================================================================150 // INPUT ARGUMENTS //======================================================================================================================================================150 // Rewritten parameters parsing for selecting platform and device and old // parameters // Additional variables for platform and device selection int platform_idx = 0; int device_idx = 0; int use_gpu = 0; int opt; extern char *optarg; while ((opt = getopt(argc, argv, "i:l:r:c:p:d:g:")) != -1 ) { switch(opt){ case 'i': niter = atoi(optarg); break; case 'l': lambda = atoi(optarg); break; case 'r': Nr = atoi(optarg); break; case 'c': Nc = atoi(optarg); break; case 'p': platform_idx = atoi(optarg); break; case 'd': device_idx = atoi(optarg); break; case 'g': use_gpu = atoi(optarg); break; case ':': fprintf(stderr, "missing argument\n"); break; default: fprintf(stderr, "Usage: %s - -l -r -c -p -d -g \n", argv[0]); exit(EXIT_FAILURE); } } time1 = get_time(); //======================================================================================================================================================150 // READ INPUT FROM FILE //======================================================================================================================================================150 //====================================================================================================100 // READ IMAGE (SIZE OF IMAGE HAS TO BE KNOWN) //====================================================================================================100 image_ori_rows = 502; image_ori_cols = 458; image_ori_elem = image_ori_rows * image_ori_cols; image_ori = (fp*)malloc(sizeof(fp) * image_ori_elem); read_graphics( "../../data/srad/image.pgm", image_ori, image_ori_rows, image_ori_cols, 1); //====================================================================================================100 // RESIZE IMAGE (ASSUMING COLUMN MAJOR STORAGE OF image_orig) //====================================================================================================100 Ne = Nr*Nc; image = (fp*)malloc(sizeof(fp) * Ne); resize( image_ori, image_ori_rows, image_ori_cols, image, Nr, Nc, 1); //====================================================================================================100 // End //====================================================================================================100 time2 = get_time(); //======================================================================================================================================================150 // SETUP //======================================================================================================================================================150 // variables r1 = 0; // top row index of ROI r2 = Nr - 1; // bottom row index of ROI c1 = 0; // left column index of ROI c2 = Nc - 1; // right column index of ROI // ROI image size NeROI = (r2-r1+1)*(c2-c1+1); // number of elements in ROI, ROI size // allocate variables for surrounding pixels mem_size_i = sizeof(int) * Nr; // iN = (int *)malloc(mem_size_i) ; // north surrounding element iS = (int *)malloc(mem_size_i) ; // south surrounding element mem_size_j = sizeof(int) * Nc; // jW = (int *)malloc(mem_size_j) ; // west surrounding element jE = (int *)malloc(mem_size_j) ; // east surrounding element // N/S/W/E indices of surrounding pixels (every element of IMAGE) for (i=0; i