View Full Version : Checking wether a command queue is valid...

08-25-2012, 01:53 AM

I would like to check if a given comand queue is valid. (I have a lot of host code, some functions taking a command queue as a parameter, and I had a bug where I gave an unitialised command queue, so I would like to avoid such a bug in the future).
Anyway, I have tried a simple:

bool queueValid(const cl_command_queue& queue)
size_t size;
cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, 0, NULL, &size);
return (err == CL_SUCCESS);

But it turns out that calling clGetCommandQueueInfo on an unitialised queue segfault. (AMD APP SDK 2.7)

I have seen a previous post about "Check whether cl_mem object is valid":http://www.khronos.org/message_boards/viewtopic.php?f=28&t=4995
but it does not seem to apply to queues.

Any pointer ? (no pun intended!)
Thanks a lot in advance.


08-27-2012, 04:00 AM
Just write more robust code ...? :)

They're just pointers, so treat them like any other pointer. i.e. init to 0, use !0 checks, and/or fail earlier if they aren't created in the first place.