Obtaining GPU deviceID for each window/NSScreen in multi-display/multi-GPU app?

Apprentice
Posts: 5
Joined: 2012.10
Post: #1
HI,

Wondering if anyone has any experience using clGetGLContextInfoAPPLE in an openCL/openGL application to obtain the device ID for the GPU currently being used to display an application window containing an NSOpenGLView?

In short, I have multiple windows each drawing separately (in a threaded render loop) into an NSOpenGLView. The texture being rendered in computed on the GPU using openCL. I have the openCL/openGL code working together to avoid the openCL result from having to back to the host before being rendered by openGL. However, I can't seem to successfully figure out which GPU a particular window window is being displayed on. Using clGetGLContextInfoAPPLE always return the first physical GPU regardless of which physical display the window is on. As a result, for one of the windows, the openCL result image does have to go back through the host before rendering on the correct display. In addition, one GPU is doing all the openCL kernel processing while the other is doing none of it. Perhaps it has something to do with the openGL context creation, but I've done everything I can think of to make sure the window's openGL context is created after the window is created and positioned on the desired display.

Any thoughts or suggestions greatly appreciated!

thx,
dan
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Abe responded with some answers here on the dev forums.

AFAICT, how this *should* work is:
1) Use CGDisplay/NSScreen to position a window on each display
2) create a context for each window, accepting all renderers
3) ensure the window is visible and the context is updated. This will set its virtual screen correctly.
4) call clGetGLContextInfoAPPLE with CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE to get a cl_device_id
5) pass that to clCreateCommandQueue

... and of course, ensure that 3-5 are repeated whenever the window moves.

Some other possibly useful info:
* the low byte of the GL renderer ID distinguishes identical GPUs
* CGDisplay can give you an IOFramebuffer for a display, which you can use to correlate a display with this low byte and with the physical port on the rear of the machine.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Mud with or without Multi-Threading ? MadPsycho 21 8,762 Oct 3, 2006 11:06 AM
Last Post: Dan Potter
  Should my board game be multi-threaded? Tasnu Arakun 2 3,840 Aug 25, 2006 07:14 AM
Last Post: Tasnu Arakun
  Obtaining GL Context nalenb 10 7,245 May 21, 2006 01:32 PM
Last Post: LongJumper
  Obtaining Supported Screen Resolutions Volte 4 4,311 Sep 11, 2005 03:05 AM
Last Post: Volte