Hi guys,
I started writing an OpenCL Wrapper class, which initialises OpenCL Context and some more. Why I did this? Just to get to know OpenCL, nothing special. The class is not supposed to ever be used, but it’s the easiest way for me to learn.
Now I have a weird problem, which happens to occur even without using the code from the class. When I try to run the program I wrote using OpenCL. This problem occurs with and without using the class on own code examples.
Following is happening:
ciErrNum = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);
As soon as the above line is reached, ciErrNum returns -42, which stands for CL_INVALID_BINARY. I’m not using clCreateBinary, but rather clCreateProgramWithSource. I used the file loading solution from the OCL tools and I used my own. It is always the same. The code compiles fine without any warnings or errors. I use VS2010 and the newest OpenCL sdk from nvidia. Videocard is a 470GTX.
This is my test code right now:
ciErrNum = clGetPlatformIDs( 1, &cpPlatform, NULL );
//Get the devices
ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, 0, NULL, &uiNumDevices);
cdDevices = (cl_device_id *)malloc(uiNumDevices * sizeof(cl_device_id) );
ciErrNum = clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, uiNumDevices, cdDevices, NULL);
//Create the context
cxGPUContext = clCreateContext(0, uiNumDevices, cdDevices, NULL, NULL, &ciErrNum);
// create the command queue
cqCommandQueue = clCreateCommandQueue(cxGPUContext, cdDevice, 0, &ciErrNum);
cdDevice = cdDevices[0];
// Program Setup
size_t program_length;
cPathAndName = shrFindFilePath("SDL_Demo_kernel.cl", argv[0]);
cSourceCL = oclLoadProgSource(cPathAndName, "", &program_length);
// create the program
cpProgram = clCreateProgramWithSource(cxGPUContext, 1,
(const char **) &cSourceCL , &program_length, &ciErrNum);
// build the program
ciErrNum = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);
if( ciErrNum != CL_SUCCESS ) {
printf( "Nope, no success here..." );
}