AnsweredAssumed Answered

How do create an OpenCL context from an OpenGL context in a Multiple GPU environment?

Question asked by jepe on Sep 21, 2015
Latest reply on Oct 7, 2015 by sandyandr

Hello,

 

my target is to setup an OpenCL context and present to result to an OpenGL context. Therefore, I successfully setup my OpenCL context from the OpenGL context using GLUT windowing system.

This version runs very well by using a single GPU.

 

Now I want to setup my OpenCL context with multiple GPUs. Unfortunately, the changes are not straight forward. After some investigation into the AMD APP documentation, I found an interesting article in the document "AMD_OpenCL_Programming_User_Guide.pdf" of AMD APP SDK 3.0 BETA.

There, in the appendix chapter E.1.2, is exactly the explanation how to do a multiple GPU environment by creating CL context from a GL context.

First I removed all my GLUT function calls and setup a windowing system by using Win32 API.

I did all the points are mentioned in the document. At the end I got again a single GPU system running as before except for my windowing system is now managed by Win32 API and not GLUT anymore.

So, I wondering about the clCreateContext call.

 

// Create OpenCL context from device's id

context = clCreateContext(properties, 1, &interopDevice, 0, 0, &status);

 

Actually, by a Multi GPU system I expected here to setup the OpenCL context for more than 1 GPU like this (in my case a have 3 AMD GPUs)

context = clCreateContext(properties, 3, &myGPUDevices[0], 0, 0, &status);

So, myGPUDevices points now to an array of 3 valid created GPU devices:

cl_device_id *myGPUDevices = new cl_device_id[3];

 

I did a lot of work to find out how to call it for a multi GPU system, but finally I could not found a solution. I understand that only one GPU can has a GL context, but inside an OpenCL context I want to run my processing on 3 GPUs, combine the result from each command queue of each device in the CL context and present it to GL context. Therefore, I need to setup the CL context at the beginning with GL interoperability too.

 

Has anyone an idea what is my error in reasoning here? Is the sample in the document running in a CL context on multiple GPUs?

 

Driver: 15.20.1062.1004-150803a1-187671C

Catalyst Version: 15.7.1

OpenCL 1.2 or 2.0

AMD APP SDK 2.9.1 or 3.0 BETA

Hardware:

AMD Radeon R9 295 X2

AMD Radeon R9 390

 

Thank you in advance,

Jens

Outcomes