Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Thread Tools
Old 02-29-12, 05:53 AM   #1
Registered User
Join Date: Feb 2012
Posts: 1
Default [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:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe9cf8700 (LWP 2868)]
0x00007ffff68ac47e in ?? () from /usr/lib64/libnvidia-glcore.so.285.05.09
(gdb) bt
#0 0x00007ffff68ac47e in ?? () from /usr/lib64/libnvidia-glcore.so.285.05.09
#1 0x00007ffff68adc30 in ?? () from /usr/lib64/libnvidia-glcore.so.285.05.09
#2 0x00007fffee07840a in ?? () from /usr/lib64/libcuda.so
#3 0x00007fffee091957 in ?? () from /usr/lib64/libcuda.so
#4 0x00007fffee0a2c71 in ?? () from /usr/lib64/libcuda.so
#5 0x00007fffee0a3c94 in ?? () from /usr/lib64/libcuda.so
#6 0x00007fffee09dd73 in ?? () from /usr/lib64/libcuda.so
#7 0x000000000040584f in CLThread::animate (this=0xbd6910, t=0) at src/CLThread.cpp:81
#8 0x0000000000405a5d in CLThread::run (this=0xbd6910) at src/CLThread.cpp:129
#9 0x0000000000405bbe in CLThread::threadFunc (thread_data=0xbd6910) at src/CLThread.cpp:148
#10 0x00000038e6211265 in SDL_RunThread (data=0xbea1c0) at src/thread/SDL_thread.c:204
#11 0x00000038e62569c9 in RunThread (data=<value optimized out>) at src/thread/pthread/SDL_systhread.c:47
#12 0x000000368b406ccb in start_thread (arg=0x7fffe9cf8700) at pthread_create.c:301
#13 0x000000368b0e0c2d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
(gdb) frame 7
#7 0x000000000040584f in CLThread::animate (this=0xbd6910, t=0) at src/CLThread.cpp:81
81 error = clEnqueueAcquireGLObjects(_cl_queue, 1, &_cl_vao, 0, NULL, NULL);
Any feedback will be greatly appreciated, and I'll be happy to provide more info (logs, backtraces, core dumps...) if it could be of help.

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.
Attached Files
File Type: bz2 ParallelGLPlusCL.tar.bz2 (8.8 KB, 43 views)
lvezzaro is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 08:24 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.