Checking wether a command queue is valid...


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”:
but it does not seem to apply to queues.

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


Just write more robust code …? :slight_smile:

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.