Testing13/prisoner.cpp
/* OpenCL Functions */
/* Find a GPU or CPU associated with the first available platform */
OpenCL Functions
Find a GPU or CPU associated with the first available platform
OpenCL Functions Find a GPU or CPU associated with the first available platform
cl_device_id create_device() {
	   cl_platform_id platform;
	   cl_device_id dev;
	   int err;
	   err = clGetPlatformIDs(1, &platform, NULL);
	   if(err < 0) {
		  perror("Couldn't identify a platform");
		  exit(1);
	   } 
	   err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &dev, NULL);
	   if(err == CL_DEVICE_NOT_FOUND) {
		  err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &dev, NULL);
	   }
	   if(err < 0) {
		  perror("Couldn't access any devices");
		  exit(1);   
	   }
	   return dev;
	}
cl_device_id create_device ( ) { cl_platform_id platform ; cl_device_id dev ; int err ; err = clGetPlatformIDs ( 1 , & platform , NULL ) ; if ( err < 0 ) { perror ( " " ) ; exit ( 1 ) ; } err = clGetDeviceIDs ( platform , CL_DEVICE_TYPE_GPU , 1 , & dev , NULL ) ; if ( err == CL_DEVICE_NOT_FOUND ) { err = clGetDeviceIDs ( platform , CL_DEVICE_TYPE_CPU , 1 , & dev , NULL ) ; } if ( err < 0 ) { perror ( " " ) ; exit ( 1 ) ; } return dev ; }
OpenCL Functions
Find a GPU or CPU associated with the first available platform
OpenCL Functions Find a GPU or CPU associated with the first available platform
/* Identify a platform */ /* Access a device */