I have discovered what I consider to be a bug in the reference tracking for cl_command_queue instances that leads to a segmentation fault under a reasonable usage scenario.
The cl_command_queue reference count is not incremented when a cl_event instance is created. It should be.
clReleaseCommandQueue can be called while there are still cl_event instances that have not been released. Now, in this case, it is still possible to get a reference to the command queue associated with cl_event by calling clGetEventInfo ( cl_event event, CL_EVENT_COMMAND_QUEUE, , &queue ... ).
I experience a segmentation fault if I use that queue reference to get information about the command queue, for example: clGetCommandQueueInfo( command_queue, CL_QUEUE_DEVICE, ...)
I've attached a bug demo program to demonstrate the error.
My output shows the queue reference count is unaffected by the event lifecycle:
$ g++ -o bugDemo command_queue_ref_cnt_demo.cpp bugDemoSupport.cpp -I /opt/AMDAPP/include -lOpenCL
$ ./bugDemo
Selected CL_PLATFORM_NAME: AMD Accelerated Parallel Processing
CL_DEVICE_NAME: AMD Opteron(TM) Processor 6274
CL_DRIVER_VERSION: 1214.3 (sse2,avx,fma4)
reference count after instantiation: context 2, queue 1
reference count after creating an event: context 4, queue 1
reference count after releasing the event: context 3, queue 1
The Apple implementation does not suffer this problem. The queue reference count tracks the number of event instances associated with that queue:
$ ./bugDemo
Selected CL_PLATFORM_NAME: Apple
CL_DEVICE_NAME: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
CL_DRIVER_VERSION: 1.1
reference count after instantiation: context 2, queue 1
reference count after creating an event: context 4, queue 2
reference count after releasing the event: context 3, queue 1
Hi Noah,
Thanks for the code. We will try to reproduce it and get back.
Hi,
Sorry for this late reply.
I ran your code but haven't found any segmentation fault. Please find my observations given below:
-----------------------------------------------------------------------------------------------------------------
Selected CL_PLATFORM_NAME: AMD Accelerated Parallel Processing
CL_DEVICE_NAME: Turks
CL_DRIVER_VERSION: 1214.3
reference count after instantiation: context 2, queue 1
reference count after creating an event: context 4, queue 1
reference count after releasing the event: context 3, queue 1
The End
--------------------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////
After changing the " selected_OpenCL_device_index = 1; " in file bugDemoSupport.cpp.
---------------------------------------------------------------------------------------------------------------
Selected CL_PLATFORM_NAME: AMD Accelerated Parallel Processing
CL_DEVICE_NAME: Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
CL_DRIVER_VERSION: 1214.3 (sse2,avx)
reference count after instantiation: context 2, queue 1
reference count after creating an event: context 4, queue 1
reference count after releasing the event: context 3, queue 1
The End
------------------------------------------------------------------------------------------------------------
As per you, "The cl_command_queue reference count is not incremented when a cl_event instance is created. It should be."
Please can you elaborate your point or refer any document/link that suggests this point.
Regards,
Hi Noak,
Is your problem resolved? Can you post an update?