I found a strange behaviour in the header cl.hpp, and I'd like some feedback on this.
In the very example on top of cl.hpp I find these instructions:
So I think I'm supposed to pass a pointer to an Event object.Code :cl::Event event; cl::CommandQueue queue(context, devices, 0, &err); queue.enqueueNDRangeKernel( kernel, cl::NullRange, cl::NDRange(4,4), cl::NullRange, NULL, &event); event.wait();
However when inside the method enqueueNDRangeKernel the Event object pointer is casted to a cl_event pointer, like this:
I see 2 problems in this instruction:Code :::clEnqueueNDRangeKernel( object_, kernel(), (cl_uint) global.dimensions(), offset.dimensions() != 0 ? (const ::size_t*) offset : NULL, (const ::size_t*) global, local.dimensions() != 0 ? (const ::size_t*) local : NULL, (events != NULL) ? (cl_uint) events->size() : 0, (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, [color=#FF0000](cl_event*) event[/color]),
1. When debugging I know for sure that this doesn't release the previous cl_event stored in the Event wrapper. If you put this code in a loop it'll fill up your RAM. On the other hand there is no easy way to release the previous Event easily, since the Wrapper::release method is protected, the fastest way is to assign a null Event.
2. Why are we casting an Event pointer to a cl_event pointer? I don't see any operator& overloading in the wrapper that permits us to do such a thing. I'm no C++ guru, if somebody can explain me that i'd be glad to understand. Is it because the cl_event is the first and only field in the class (therefore it starts exactly where the Event object starts)?
Thank you for any feedback,