// main() for simple buffer and sub-buffer example // int main(int argc, char** argv) { cl_int errNum; cl_uint numPlatforms; cl_uint numDevices; cl_platform_id * platformIDs; cl_device_id * deviceIDs; cl_context context; cl_program program; std::vector<cl_kernel> kernels; std::vector<cl_command_queue> queues; std::vector<cl_mem> buffers; int * inputOutput; std::cout << "Simple buffer and sub-buffer Example" << std::endl; // First, select an OpenCL platform to run on. errNum = clGetPlatformIDs(0, NULL, &numPlatforms); checkErr( (errNum != CL_SUCCESS) ? errNum : (numPlatforms <= 0 ? -1 : CL_SUCCESS), "clGetPlatformIDs"); platformIDs = (cl_platform_id *)alloca(sizeof(cl_platform_id) * numPlatforms); std::cout << "Number of platforms: \t" << numPlatforms << std::endl; errNum = clGetPlatformIDs(numPlatforms, platformIDs, NULL); checkErr( (errNum != CL_SUCCESS) ? errNum : (numPlatforms <= 0 ? -1 : CL_SUCCESS), "clGetPlatformIDs"); std::ifstream srcFile("simple.cl"); checkErr(srcFile.is_open() ? CL_SUCCESS : -1, "reading simple.cl"); std::string srcProg( std::istreambuf_iterator<char>(srcFile), (std::istreambuf_iterator<char>())); const char * src = srcProg.c_str(); size_t length = srcProg.length(); deviceIDs = NULL; DisplayPlatformInfo( platformIDs[PLATFORM_INDEX], CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR"); errNum = clGetDeviceIDs( platformIDs[PLATFORM_INDEX], CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices); if (errNum != CL_SUCCESS && errNum != CL_DEVICE_NOT_FOUND){ checkErr(errNum, "clGetDeviceIDs"); } deviceIDs = (cl_device_id *)alloca( sizeof(cl_device_id) * numDevices); errNum = clGetDeviceIDs( platformIDs[PLATFORM_INDEX], CL_DEVICE_TYPE_ALL, numDevices, &deviceIDs[0], NULL); checkErr(errNum, "clGetDeviceIDs"); cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platformIDs[PLATFORM_INDEX], 0 }; context = clCreateContext( contextProperties, numDevices, deviceIDs, NULL, NULL, &errNum); checkErr(errNum, "clCreateContext"); // Create program from source program = clCreateProgramWithSource( context, 1, &src, &length, &errNum); checkErr(errNum, "clCreateProgramWithSource"); // Build program errNum = clBuildProgram( program, numDevices, deviceIDs, "-I.", NULL, NULL); if (errNum != CL_SUCCESS){ // Determine the reason for the error char buildLog[16384]; clGetProgramBuildInfo( program, deviceIDs[0], CL_PROGRAM_BUILD_LOG, sizeof(buildLog), buildLog, NULL); std::cerr << "Error in OpenCL C source: " << std::endl; std::cerr << buildLog; checkErr(errNum, "clBuildProgram"); } // create buffers and sub-buffers inputOutput = new int[NUM_BUFFER_ELEMENTS * numDevices]; for (unsigned int i = 0; i < NUM_BUFFER_ELEMENTS * numDevices; i++) { inputOutput[i] = i; } // create a single buffer to cover all the input data cl_mem buffer = clCreateBuffer( context, CL_MEM_READ_WRITE, sizeof(int) * NUM_BUFFER_ELEMENTS * numDevices, NULL, &errNum); checkErr(errNum, "clCreateBuffer"); buffers.push_back(buffer); // now for all devices other than the first create a sub-buffer for (unsigned int i = 1; i < numDevices; i++) { cl_buffer_region region = { NUM_BUFFER_ELEMENTS * i * sizeof(int), NUM_BUFFER_ELEMENTS * sizeof(int) }; buffer = clCreateSubBuffer( buffers[0], CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, ®ion, &errNum); checkErr(errNum, "clCreateSubBuffer"); buffers.push_back(buffer); } // Create command queues for (int i = 0; i < numDevices; i++) { InfoDevice<cl_device_type>::display(deviceIDs[i], CL_DEVICE_TYPE, "CL_DEVICE_TYPE"); cl_command_queue queue = clCreateCommandQueue( context, deviceIDs[i], 0, &errNum); checkErr(errNum, "clCreateCommandQueue"); queues.push_back(queue); cl_kernel kernel = clCreateKernel( program, "square", &errNum); checkErr(errNum, "clCreateKernel(square)"); errNum = clSetKernelArg( kernel, 0, sizeof(cl_mem), (void *)&buffers[i]); checkErr(errNum, "clSetKernelArg(square)"); kernels.push_back(kernel); // Write input data clEnqueueWriteBuffer( queues[0], buffers[0], CL_TRUE, 0, sizeof(int) * NUM_BUFFER_ELEMENTS * numDevices, (void*)inputOutput, 0, NULL, NULL); std::vector<cl_event> events; // call kernel for each device for (int i = 0; i < queues.size(); i++) { cl_event event; size_t gWI = NUM_BUFFER_ELEMENTS; errNum = clEnqueueNDRangeKernel( queues[i], kernels[i], 1, NULL, (const size_t*)&gWI, (const size_t*)NULL, 0, 0, &event); events.push_back(event); } // Technically don't need this as we are doing a blocking read // with in-order queue. clWaitForEvents(events.size(), events.data()); // Read back computed data clEnqueueReadBuffer( queues[0], buffers[0], CL_TRUE, 0, sizeof(int) * NUM_BUFFER_ELEMENTS * numDevices, (void*)inputOutput, 0, NULL, NULL); // Display output in rows for (unsigned i = 0; i < numDevices; i++) { for (unsigned elems = i * NUM_BUFFER_ELEMENTS; elems < ((i+1) * NUM_BUFFER_ELEMENTS); elems++) { std::cout << " " << inputOutput[elems]; } std::cout << std::endl; } std::cout << "Program completed successfully" << std::endl; return 0; } }
// main() for simple buffer and sub-buffer example // int main(int argc, char** argv) { std::cout << "Simple Image Processing Example" << std::endl; // First, select an OpenCL platform to run on. errNum = clGetPlatformIDs(0, NULL, &numPlatforms); checkErr( (errNum != CL_SUCCESS) ? errNum : (numPlatforms <= 0 ? -1 : CL_SUCCESS), "clGetPlatformIDs"); platformIDs = (cl_platform_id *)alloca(sizeof(cl_platform_id) * numPlatforms); std::cout << "Number of platforms: \t" << numPlatforms << std::endl; errNum = clGetPlatformIDs(numPlatforms, platformIDs, NULL); checkErr( (errNum != CL_SUCCESS) ? errNum : (numPlatforms <= 0 ? -1 : CL_SUCCESS), "clGetPlatformIDs"); std::ifstream srcFile("gaussian_filter.cl"); checkErr(srcFile.is_open() ? CL_SUCCESS : -1, "reading simple.cl"); std::string srcProg( std::istreambuf_iterator<char>(srcFile), (std::istreambuf_iterator<char>())); const char * src = srcProg.c_str(); size_t length = srcProg.length(); deviceIDs = NULL; DisplayPlatformInfo( platformIDs[PLATFORM_INDEX], CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR"); errNum = clGetDeviceIDs( platformIDs[PLATFORM_INDEX], CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices); if (errNum != CL_SUCCESS && errNum != CL_DEVICE_NOT_FOUND){ checkErr(errNum, "clGetDeviceIDs"); } deviceIDs = (cl_device_id *)alloca(sizeof(cl_device_id) * numDevices); errNum = clGetDeviceIDs( platformIDs[PLATFORM_INDEX], CL_DEVICE_TYPE_ALL, numDevices, &deviceIDs[0], NULL); checkErr(errNum, "clGetDeviceIDs"); cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platformIDs[PLATFORM_INDEX], 0 }; context = clCreateContext( contextProperties, numDevices, deviceIDs, NULL, NULL, &errNum); checkErr(errNum, "clCreateContext"); // Create program from source program = clCreateProgramWithSource( context, 1, &src, &length, &errNum); checkErr(errNum, "clCreateProgramWithSource"); // Build program errNum = clBuildProgram( program, numDevices, deviceIDs, "-I.", NULL, NULL); if (errNum != CL_SUCCESS){ // Determine the reason for the error char buildLog[16384]; clGetProgramBuildInfo( program, deviceIDs[0], CL_PROGRAM_BUILD_LOG, sizeof(buildLog), buildLog, NULL); std::cerr << "Error in OpenCL C source: " << std::endl; std::cerr << buildLog; checkErr(errNum, "clBuildProgram"); } // Create a command commands // if(!(commands = clCreateCommandQueue(context, deviceIDs[0], 0, &errNum))) { std::cout << "Failed to create a command commands!" << std::endl; cleanKill(EXIT_FAILURE); } cl_kernel kernel = clCreateKernel(program, "gaussian_filter", &errNum); checkErr(errNum, "clCreateKernel(gaussian_filter)"); if(!doesGPUSupportImageObjects){ cleanKill(EXIT_FAILURE); } inputImage = LoadImage(context, (char*)"rgba.png", width, height); cl_image_format format; format.image_channel_order = CL_RGBA; format.image_channel_data_type = CL_UNORM_INT8; outputImage = clCreateImage2D(context, CL_MEM_WRITE_ONLY, &format, width, height, 0, NULL, &errNum); if(there_was_an_error(errNum)){ std::cout << "Output Image Buffer creation error!" << std::endl; cleanKill(EXIT_FAILURE); } if (!inputImage || !outputImage ){ std::cout << "Failed to allocate device memory!" << std::endl; cleanKill(EXIT_FAILURE); } char *buffer = new char [width * height * 4]; size_t origin[3] = { 0, 0, 0 }; size_t region[3] = { width, height, 1}; sampler = clCreateSampler(context, CL_FALSE, // Non-normalized coordinates CL_ADDRESS_CLAMP_TO_EDGE, CL_FILTER_NEAREST, &errNum); if(there_was_an_error(errNum)){ std::cout << "Error creating CL sampler object." << std::endl; cleanKill(EXIT_FAILURE); } // Set the kernel arguments errNum = clSetKernelArg(kernel, 0, sizeof(cl_mem), &inputImage); errNum |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &outputImage); errNum |= clSetKernelArg(kernel, 2, sizeof(cl_sampler), &sampler); errNum |= clSetKernelArg(kernel, 3, sizeof(cl_int), &width); errNum |= clSetKernelArg(kernel, 4, sizeof(cl_int), &height); if (errNum != CL_SUCCESS) { std::cerr << "Error setting kernel arguments." << std::endl; std::cerr << print_cl_errstring(errNum) << std::endl; cleanKill(EXIT_FAILURE); } //errNum = clGetKernelWorkGroupInfo(kernel, deviceIDs, CL_KERNEL_WORK_GROUP_SIZE, sizeof(unsigned short)* height*width*4, &local, NULL); // if (errNum != CL_SUCCESS) // { // cout << print_cl_errstring(err) << endl; // if(err == CL_INVALID_VALUE){ // cout << "if param_name is not valid, or if size in bytes specified by param_value_size " // << "is less than the size of return type as described in the table above and " // << "param_value is not NULL." << endl; // } // cout << "Error: Failed to retrieve kernel work group info!" << err << endl; // cleanKill(EXIT_FAILURE); // } std::cout << "Max work group size is " << CL_DEVICE_MAX_WORK_GROUP_SIZE << std::endl; std::cout << "Max work item size is " << CL_DEVICE_MAX_WORK_ITEM_SIZES << std::endl; size_t localWorkSize[2]; size_t globalWorkSize[2]; localWorkSize[0] = 1; localWorkSize[1] = localWorkSize[0]; globalWorkSize[0] = width*height; globalWorkSize[1] = globalWorkSize[0]; //CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and number of work-items specified by global_work_size is not evenly divisable by size of work-group given by local_work_size //size_t globalWorkSize[2] = { RoundUp(localWorkSize[0], width), RoundUp(localWorkSize[1], height)}; // size_t globalWorkSize[1] = {sizeof(unsigned short)* height * width}; // size_t localWorkSize[1] = {64}; // Queue the kernel up for execution errNum = clEnqueueNDRangeKernel(commands, kernel, 2, NULL, globalWorkSize, localWorkSize, 0, NULL, NULL); if (errNum != CL_SUCCESS){ std::cerr << "Error queuing kernel for execution." << std::endl; std::cerr << print_cl_errstring(errNum) << std::endl; cleanKill(EXIT_FAILURE); } // Wait for the command commands to get serviced before reading back results // clFinish(commands); // Read back computed data errNum = clEnqueueReadImage(commands, outputImage, CL_TRUE, origin, region, 0, 0, buffer, 0, NULL, NULL); SaveImage((char*)"outRGBA.png", (char*)buffer, width, height); std::cout << "Program completed successfully" << std::endl; return 0; }
/*--------------------------------------------------------- // tmr_ocl_create_contexts - to create OpenCL contexts on a selected platform ---------------------------------------------------------*/ int tmr_ocl_create_contexts( FILE *Interactive_output, /* file or stdout to write messages */ int Platform_id_in, int Monitor ) { cl_int retval; cl_uint numPlatforms; cl_platform_id * platformIds; cl_context context = NULL; cl_uint iplat, jdev, k; // First, query the total number of platforms retval = clGetPlatformIDs(0, (cl_platform_id *) NULL, &numPlatforms); // allocate memory for local platform structures tmv_ocl_struct.number_of_platforms = numPlatforms; tmv_ocl_struct.list_of_platforms = (tmt_ocl_platform_struct *) malloc( sizeof(tmt_ocl_platform_struct) * numPlatforms); // Next, allocate memory for the installed platforms, and qeury // to get the list. platformIds = (cl_platform_id *)malloc(sizeof(cl_platform_id) * numPlatforms); retval = clGetPlatformIDs(numPlatforms, platformIds, NULL); if(Monitor>=TMC_PRINT_INFO){ fprintf(Interactive_output,"\nNumber of OpenCL platforms: \t%d\n", numPlatforms); } // Iterate through the list of platforms displaying associated information for (iplat = 0; iplat < numPlatforms; iplat++) { if(Monitor>TMC_PRINT_INFO){ fprintf(Interactive_output,"\n"); fprintf(Interactive_output,"Platform %d:\n", iplat); } tmv_ocl_struct.list_of_platforms[iplat].id = platformIds[iplat]; //clGetPlatformInfo(platformIds[iplat], CL_PLATFORM_NAME, size_of_name???, // tmv_ocl_struct.list_of_platforms[iplat].name, (size_t *) NULL); if(Monitor>TMC_PRINT_INFO){ // First we display information associated with the platform DisplayPlatformInfo(Interactive_output, platformIds[iplat], CL_PLATFORM_NAME, "CL_PLATFORM_NAME"); DisplayPlatformInfo(Interactive_output, platformIds[iplat], CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE"); DisplayPlatformInfo(Interactive_output, platformIds[iplat], CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION"); DisplayPlatformInfo(Interactive_output, platformIds[iplat], CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR"); } // Now query the set of devices associated with the platform cl_uint numDevices; retval = clGetDeviceIDs( platformIds[iplat], CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices); tmv_ocl_struct.list_of_platforms[iplat].number_of_devices = numDevices; tmv_ocl_struct.list_of_platforms[iplat].list_of_devices = (tmt_ocl_device_struct *) malloc( sizeof(tmt_ocl_device_struct) * numDevices); cl_device_id * devices = (cl_device_id *) malloc (sizeof(cl_device_id) * numDevices); retval = clGetDeviceIDs( platformIds[iplat], CL_DEVICE_TYPE_ALL, numDevices, devices, NULL); if(Monitor>=TMC_PRINT_INFO){ fprintf(Interactive_output,"\n\tNumber of devices: \t%d\n", numDevices); } // Iterate through each device, displaying associated information for (jdev = 0; jdev < numDevices; jdev++) { if(Monitor>TMC_PRINT_INFO){ fprintf(Interactive_output,"\tDevice %d:\n", jdev); } tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].id = devices[jdev]; clGetDeviceInfo(devices[jdev], CL_DEVICE_TYPE, sizeof(cl_device_type), &tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].type, NULL); if(tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].type == CL_DEVICE_TYPE_CPU){ tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].tmc_type = TMC_OCL_DEVICE_CPU; } if(tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].type == CL_DEVICE_TYPE_GPU){ tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].tmc_type = TMC_OCL_DEVICE_GPU; } if(tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].type == CL_DEVICE_TYPE_ACCELERATOR){ tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].tmc_type = TMC_OCL_DEVICE_ACCELERATOR; } cl_ulong mem_size_ulong = 0; int err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &mem_size_ulong, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].global_mem_bytes = (double)mem_size_ulong; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &mem_size_ulong, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].global_max_alloc= (double)mem_size_ulong; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &mem_size_ulong, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].shared_mem_bytes = (double)mem_size_ulong; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof(cl_ulong), &mem_size_ulong, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].cache_bytes = (double)mem_size_ulong; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(cl_ulong), &mem_size_ulong, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].constant_mem_bytes = (double)mem_size_ulong; cl_uint cache_line_size = 0; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof(cl_uint), &cache_line_size, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].cache_line_bytes = (int) cache_line_size; cl_uint max_num_comp_units = 0; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), &max_num_comp_units, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].max_num_comp_units = (int) max_num_comp_units; size_t max_work_group_size =0; err_num = clGetDeviceInfo(devices[jdev], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &max_work_group_size, NULL); tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].max_work_group_size = (int) max_work_group_size; // possible further inquires: //CL_DEVICE_MAX_WORK_GROUP_SIZE, //CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, CL_DEVICE_MAX_WORK_ITEM_SIZES //CL_DEVICE_MAX_CONSTANT_ARGS //CL_DEVICE_MAX_PARAMETER_SIZE //CL_DEVICE_PREFERRED_VECTOR_WIDTH_ - char, int, float, double etc. //CL_DEVICE_MEM_BASE_ADDR_ALIGN, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].command_queue = 0; for(k=0;k<TMC_OCL_MAX_NUM_KERNELS;k++){ tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].program[k]=0; tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].kernel[k]=0; } //clGetDeviceInfo(devices[jdev], CL_DEVICE_NAME, sizeof(device_name?), //&tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].name, NULL); if(Monitor>TMC_PRINT_INFO){ DisplayDeviceInfo(Interactive_output, devices[jdev], CL_DEVICE_NAME, "CL_DEVICE_NAME"); DisplayDeviceInfo(Interactive_output, devices[jdev], CL_DEVICE_VENDOR, "CL_DEVICE_VENDOR"); DisplayDeviceInfo(Interactive_output, devices[jdev], CL_DEVICE_VERSION, "CL_DEVICE_VERSION"); fprintf(Interactive_output,"\t\tdevice global memory size (MB) = %lf\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].global_mem_bytes/1024/1024); fprintf(Interactive_output,"\t\tdevice global max alloc size (MB) = %lf\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].global_max_alloc/1024/1024); fprintf(Interactive_output,"\t\tdevice local memory size (kB) = %lf\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].shared_mem_bytes/1024); fprintf(Interactive_output,"\t\tdevice constant memory size (kB) = %lf\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].constant_mem_bytes/1024); fprintf(Interactive_output,"\t\tdevice cache memory size (kB) = %lf\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].cache_bytes/1024); fprintf(Interactive_output,"\t\tdevice cache line size (B) = %d\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].cache_line_bytes); fprintf(Interactive_output,"\t\tdevice maximal number of comptme units = %d\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].max_num_comp_units); fprintf(Interactive_output,"\t\tdevice maximal number of work units in work group = %d\n", tmv_ocl_struct.list_of_platforms[iplat].list_of_devices[jdev].max_work_group_size); fprintf(Interactive_output,"\n"); } } free(devices); // Next, create OpenCL contexts on platforms cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platformIds[iplat], 0 }; if(Platform_id_in == TMC_OCL_ALL_PLATFORMS || Platform_id_in == iplat){ if(Monitor>TMC_PRINT_INFO){ fprintf(Interactive_output,"\tCreating CPU context (index=0) on platform %d\n", iplat); } tmv_ocl_struct.list_of_platforms[iplat].list_of_contexts[0] = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_CPU, NULL, NULL, &retval); if(Monitor>=TMC_PRINT_INFO && retval != CL_SUCCESS){ fprintf(Interactive_output,"\tCould not create CPU context on platform %d\n", iplat); } if(Monitor>TMC_PRINT_INFO){ fprintf(Interactive_output,"\tCreating GPU context (index=1) on platform %d\n", iplat); } tmv_ocl_struct.list_of_platforms[iplat].list_of_contexts[1] = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &retval); if(Monitor>=TMC_PRINT_INFO && retval != CL_SUCCESS){ fprintf(Interactive_output,"\tCould not create GPU context on platform %d\n", iplat); } if(Monitor>TMC_PRINT_INFO){ fprintf(Interactive_output,"\tCreating ACCELERATOR context (index=2) on platform %d\n", iplat); } tmv_ocl_struct.list_of_platforms[iplat].list_of_contexts[2] = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_ACCELERATOR, NULL, NULL, &retval); if(Monitor>=TMC_PRINT_INFO && retval != CL_SUCCESS){ fprintf(Interactive_output,"\tCould not create ACCELERATOR context on platform %d\n", iplat); } } } free(platformIds); return numPlatforms; }