Reputation: 13
My program doesn't work both using CPU and GPU:
ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_CPU, 1, &device_id, &ret_num_devices);
ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices);
When using CPU I receive this message:
First-chance exception at 0x000007FEE30E8F90 (amdocl64.dll) in Project2.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. If there is a handler for this exception, the program may be safely continued.
The problem appears while executing this command:
ret = clEnqueueReadBuffer(command_queue, Cmobj, CL_TRUE, 0,
K*L*sizeof(float), C, 0, NULL, NULL);
When using GPU program freezes when executing this command:
ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
Is there problem with memory? Or something else? I use Visual Studio 2012, AMD Radeon HD 6470M, AMD APP SDK 2.9-1
Upvotes: 1
Views: 987
Reputation: 53
How did you initialize device_id
and ret_num_devices
?
Normally, you need to call clGetDeviceIDs
twice: first get the number of available devices, then allocate memory for the device IDs, then call it again to fill that memory, like this:
cl_uint numDevices = 0;
cl_device_id *devices;
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
if (numDevices > 0)
{
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
}
else
{
// error: no device available: exit or fall back to CPU ...
}
// use any of the devices[0 .. numDevices-1]
// after compiling/loading the kernel, you can free(devices)
Some of the examples that come with the APP SDK also show this pattern, samples/opencl/cl/app/HelloWorld/HelloWorld.cpp for example. Maybe you just use one of the examples and adapt it to your needs?
Upvotes: 1