views:

163

answers:

2

If I have something like:

err = clEnqueueReadBuffer(cmdQueue, output, CL_TRUE, 0, sizeof(float) * data_sz, &results, 0, NULL, NULL);

I'd like to do:

if (err != CL_SUCCESS){
    perror("Read Failed!");
}

But the error constants like "CL_HOST_OUT_OF_MEMORY" and the like are (understandably) not known to perror().

I could go around grepping the .h files associated with opencl, but that is not an ideal solution. I'm open to any other convenient ways of tracking down the error numbers. I'm on OSX Snow Leopard (Including that just in case, but I don't think it's relevant)

A: 

If you have the NVIDIA OpenCL SDK then you could use the oclErrorString() function provided by oclUtils.

Tom
A: 

There is none currently. I ended up writing my own, in the style of gluErrorString(). I just pasted all the cl_error codes into a file and processed each line in Emacs to convert it into a bunch of cases inside a switch statement (to allow for discontiguous entries) that return constant strings. It was pretty easy, and quite useful. I can post it somewhere if you like.

gavinb
Where can I find a listing of all the cl_error codes?
Yktula
The full list is in the header: http://www.khronos.org/registry/cl/api/1.0/cl.h
gavinb