Hi, I read document by AMD which describes how to create Offline Binary Kernel Generation. There is this written:
Setup the OpenCL™ platform with the CL_CONTEXT_OFFLINE_DEVICES_AMD property set to 1. This gives you the ability to build OpenCL™ C kernels for OpenCL™ devices which may not necessarily be installed or accessible in your build system.
Example:
#define CL_CONTEXT_OFFLINE_DEVICES_AMD 0x403F
cl_platform_id platform; /* you must find the appropriate platform. */
cl_context_properties cprops[5];cprops[0] = CL_CONTEXT_PLATFORM;
cprops[1] = (cl_context_properties)platform;
cprops[2] = CL_CONTEXT_OFFLINE_DEVICES_AMD;
cprops[3] = (cl_context_properties)1;
cprops[4] = (cl_context_properties)NULL;
Problem is that I dont know what is cprops.
In my code, this is what I have:
char pna_blur_gpu(char* imgname,uint32_t size,float sigma)
{
uint32_t imgSize;
float* matrix;
cl_int ret;//the openCL error code/s
//get the image
ME_ImageBMP bmp;
meImageBMP_Init(&bmp,imgname);
imgSize = bmp.imgWidth*bmp.imgHeight*3;
//create the gaussian kernel
matrix = createGaussianKernel(size,sigma);
//create the pointer that will hold the new (blurred) image data
unsigned char* newData;
newData = malloc(imgSize);
// Read in the kernel code into a c string
FILE* f;
char* kernelSource;
size_t kernelSrcSize;
if( (f = fopen("kernel.cl", "r")) == NULL)
{
fprintf(stderr, "Failed to load OpenCL kernel code.
");
return false;
}
kernelSource = malloc(MAX_SOURCE_SIZE);
kernelSrcSize = fread( kernelSource, 1, MAX_SOURCE_SIZE, f);
fclose(f);
//Get platform and device information
cl_platform_id platformID;//will hold the ID of the openCL available platform
cl_uint platformsN;//will hold the number of openCL available platforms on the machine
cl_device_id deviceID;//will hold the ID of the openCL device
cl_uint devicesN; //will hold the number of OpenCL devices in the system
if(clGetPlatformIDs(1, &platformID, &platformsN) != CL_SUCCESS)
{
printf("Could not get the OpenCL Platform IDs
");
return false;
}
if(clGetDeviceIDs(platformID, CL_DEVICE_TYPE_DEFAULT, 1,&deviceID, &devicesN) != CL_SUCCESS)
{
printf("Could not get the system's OpenCL device
");
return false;
}
/** Offline Binary Kernel Generation **/
#define CL_CONTEXT_OFFLINE_DEVICES_AMD 0x403F
cprops[0] = CL_CONTEXT_PLATFORM;
cprops[1] = (cl_context_properties)platformID;
cprops[2] = CL_CONTEXT_OFFLINE_DEVICES_AMD;
cprops[3] = (cl_context_properties)1;
cprops[4] = (cl_context_properties)NULL;
/*********************************************/
// Create an OpenCL context
cl_context context = clCreateContext( NULL, 1, &deviceID, NULL, NULL, &ret);
if(ret != CL_SUCCESS)
{
printf("Could not create a valid OpenCL context
");
return false;
}
I have the cprops undeclared, can you explain how to declare it?