PDA

View Full Version : openGL with multiple graphics card



yuriy99
09-08-2006, 01:43 PM
I have an OpenGL application that renders in two widgets using two different threads ("A" and "B") sharing the same OpenGL context. So far this app runs on a Linux system with a single graphics card. I understand that when thread "A" renders in the first widget, thread "B" has to wait intil "A" finishes its work.
I was thinking about speeding up the app by using a system with two graphics cards (PCI Express) and two monitors. For simplicity, each card drives its own monitor. How would I initialize GL context in this case ? Is there a sample code I could use?
I use Linux 2.6/X11.
Thanks,
Yuriy

RigidBody
09-08-2006, 02:12 PM
i've never done this, so i cannot give you a solution, only some hints how to start:

with 2 cards, i guess you have to run 2 x-servers. if you use Xlib, you have to connect to both servers like this:


Display *display_one = XOpenDisplay("localhost:0.0");

Display *display_two = XOpenDisplay("localhost:1.0"); i'm not absolutely sure if the second x-server is adressed with localhost:1.0 or localhost:0.1, but you can find out easily by checking if the variable's value is NULL.

when you have 2 display variables, you can create a window on the graphics card you want:


Window window_one = XCreateWindow(display_one, ...);
Window window_two = XCreateWindow(display_two, ...); i recommend you try with xlib first, and if it works, we can go on using motif ;)

jide
09-09-2006, 03:52 AM
I can remember a 'similar' question months ago. Try to make a search (don't remember if it were on the linux forum, the beginner one or here).

Why do you need the same context for both your rendering threads ?

As RigidBody said use 2 displays (0.0 and 1.0).

yuriy99
09-11-2006, 10:31 AM
Thanks guys for the prompt replies.
With one graphics card I share the context between threads, but with graphics cards I don't have to share the context.
XOpenDisplay() will solve my problems, at least, let me move to the next problem :) -

nglsuresh
06-13-2012, 11:38 PM
We have got a system with two graphics cards (Nvidia quadro 4000) and want to display two independent graphics window from single application. How do we do using opengl calls.

shadocko
06-14-2012, 12:41 AM
At any given time, there is only one active OpenGL context in a thread.
On Windows, you have to call wglMakeCurrent to switch contexts for the calling thread.
The X equivalent is glxMakeCurrent.

On windows, a context can only be made current by one thread at a time, so the thread using the context must call wglMakeCurrent( NULL, NULL ) before another thread can make the context current.
On Linux, as far as I can remember, you can have two threads binding the same context at the same time but that would be a bad idea anyway (at least you'd need some kind of mutex synchronization before actually calling any gl commands or the current OpenGL state would be unknown).

Dark Photon
06-14-2012, 05:02 AM
We have got a system with two graphics cards (Nvidia quadro 4000) and want to display two independent graphics window from single application. How do we do using opengl calls.

There are a number of way you can do this, but one way that parallelizes very well (on Linux) is:

1) Set up the GPUs to each provide their own X screen (e.g. :0.0 and :0.1)
2) Create two different threads (or processes) in your application (call these thread 0 and thread 1)
3) In each thread, create an X window and a GLX context.
4) Enjoy parallel OpenGL rendering via both GPUs (each to its own window/context/GPU).

There are other ways to set up multiple GPUs using the NVidia drivers. Check out:
/usr/share/doc/NVIDIA_GLX-1.0/README.txt for more details.

And use nvidia-xconfig or nvidia-settings to have their tools do this configuration for you.

Janika
06-14-2012, 07:40 AM
I have a similar question but after researching I could find this:

http://www.opengl.org/registry/specs/AMD/glx_gpu_association.txt

http://www.opengl.org/registry/specs/NV/gpu_affinity.txt

Not sure why NVIDIA does not provide one for XWindows.

I still hope for a unified context management system coming soon.

Dark Photon
06-14-2012, 05:26 PM
I have a similar question but after researching I could find this:

http://www.opengl.org/registry/specs/AMD/glx_gpu_association.txt

http://www.opengl.org/registry/specs/NV/gpu_affinity.txt

Not sure why NVIDIA does not provide one for XWindows.

See pg. 6 here:

* GTC2012: Programming Multiple GPUs for Scalable Rendering (NVidia) (http://developer.download.nvidia.com/GTC/PDF/GTC2012/PresentationPDF/S0353-GTC2012-Multi-GPU-Rendering.pdf)

On Linux, it's already supported through existing X window system mechanisms (as I was describing). MSWin's window system needs help here.