|02-29-12, 05:53 AM||#1|
Join Date: Feb 2012
[Bug?] Thread safety issue with OpenGL/OpenCL interoperability
I've just started learning OpenCL, and I've already encountered a few roadblocks in getting proper interoperability with OpenCL, mostly because of the difficulty in writing portable code.
In the end, I managed to get things to work on a single-threaded environment, but it'll be easier to integrate into our physics engine if I could run the OpenCL code in a separate thread, not the same one where the OpenGL commands are issued. I also think our code will be more future-proof and scale better in multi-core processors and multi-GPU architectures.
I understand some synchronization between the OpenCL and OpenGL threads will be involved, but I hope it could be restricted to the code working with the shared resources.
What I observed instead is that my code had a hard time running on PCs equipped with NVIDIA GPUs. And while the last driver release (295.73) appears to have fixed the issue on Windows, I cannot manage to get my code to work under Linux (latest driver, 295.20).
To be more specific, my code will either crash or hang while inside the clEnqueueAcquireGLObjects() function (the same used to happen on Windows before the driver update).
Attached, you'll find the code I'm talking about. Under Windows, you'll need Microsoft Visual C++ 2008 or later to build it (use the install.bat script to copy the DLLs), while on Linux you'll need SCons (http://www.scons.org/), the SDL development libraries and the GLEW development libraries. On both platforms, you'll also need the proper OpenCL SDK, of course.
I tested the attached code on the following GPUs: NVIDIA Quadro 4000, NVIDIA 8800 GTS, ATI FirePro V7800 and operating systems: Windows 7 64-bit, 64-bit Ubuntu, 64-bit Fedora.
This is the output I get from gdb:
PS: Due to limits on the size of the attachment I only provided the Linux version of the program, go here if you want to try it on Windows.