cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

omega_doom
Adept I

Opengl interop - chosen wrong device but works

Hello.

I have quite old hardware in my laptop with switchable graphics - Intel HD 4000 and Radeon HD 7670M.

Switchable graphics works but behaves unexpectedly.

I have following code to choose opencl device for texture interop

for(auto& platform : platforms)

  {

  clGetGLContextInfoKHR_fn pclGetGLContextInfoKHR = (clGetGLContextInfoKHR_fn)

  clGetExtensionFunctionAddressForPlatform(platform(), "clGetGLContextInfoKHR");

  if (!pclGetGLContextInfoKHR)

  continue;

  cl_context_properties properties[] =

  {

  CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),

  CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),

  CL_CONTEXT_PLATFORM, (cl_context_properties)platform(),

  0

  };

  cl_device_id device_id;

  size_t value_size_ret;

  if (CL_SUCCESS != pclGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR

  , sizeof(cl_device_id), &device_id, &value_size_ret))

  continue;

  if (0 == value_size_ret)

  continue;

  return std::unique_ptr<cl::Device>(new cl::Device(device_id));

  }

  return nullptr;

It chooses intel instead of amd but for some reason works although slow. I can choose amd device explicitly and it works faster.

I don't understand why Intel opencl device doesn't lead to crash and why intel is chosen instead of amd for high performance settings.

Tags (2)
0 Likes
Reply
6 Replies
dipak
Staff
Staff

Re: Opengl interop - chosen wrong device but works

CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR returns the CL device currently associated with the specified OpenGL context. Here, the Intel integrated graphics might have been chosen by default during OpenGL context creation. And the reason could be because this is the primary card responsible for the display. Please check our OpenGL forum if they can suggest how to select the AMD card to create an OpenGL context for this switchable graphics settings.

By the way, can you please post the clinfo output and other setup details?

[Edit]:

Below are few related links (though I'm not sure if this is still applicable):

HP Notebook PCs - OpenGL Applications Cannot Use Discrete GPU with Intel + AMD Switchable Graphics |...

OpenGL Applications Cannot Use Discrete GPU with Intel + AMD Switchable Graphics

Thanks.

0 Likes
Reply
omega_doom
Adept I

Re: Opengl interop - chosen wrong device but works

I have HP Pavilion g6-2163sr. The latest bios for it is F.27 which doesn't have fixed mode.

But even if it doesn't have I see changes when I change the performance settings.

It has more fps in dx and opengl when I switch to high performance which indicates that discreet card is used.

Also when energy saving mode is used then only intel opencl device can be chosen(amd crashes).

But if high performance is used then both intel and amd can be used but as i said for some reason intel is chosen by the code in my first post with lower performance.

This code works fine (chooses correct devices on intel + nvidia).

I attached clinfo log,

0 Likes
Reply
dipak
Staff
Staff

Re: Opengl interop - chosen wrong device but works

From the attached clinfo output, everything looks good as far as OpenCL part is concerned. The discrete AMD gpu was correctly detected by the OpenCL runtime. I think the issue is more related to OpenGL. The OpenGL context was not associated with the discrete gpu, hence OpenCL runtime failed to retrieve that gpu. Please check our OpenGL forums for more information.

By the way, this page says that OpenGL applications cannot be configured to use the discrete AMD GPU under dynamic mode switchable graphics configuration. For more information about the switchable graphics configuration, please check here: HP Notebook PCs - Switchable Graphics on Notebooks Configured with Intel and ATI GPUs | HP® Customer... 

Thanks.

0 Likes
Reply
omega_doom
Adept I

Re: Opengl interop - chosen wrong device but works

dipak wrote:

From the attached clinfo output, everything looks good as far as OpenCL part is concerned. The discrete AMD gpu was correctly detected by the OpenCL runtime. I think the issue is more related to OpenGL. The OpenGL context was not associated with the discrete gpu, hence OpenCL runtime failed to retrieve that gpu. Please check our OpenGL forums for more information.

By the way, this page says that OpenGL applications cannot be configured to use the discrete AMD GPU under dynamic mode switchable graphics configuration. For more information about the switchable graphics configuration, please check here: HP Notebook PCs - Switchable Graphics on Notebooks Configured with Intel and ATI GPUs | HP® Customer...

Thanks.

I think they meant - When configuring the Dynamic Mode switchable graphics in the Catalyst Control Center, some computers do not permit any OpenGL applications to be associated with the discrete, or high-performance, GPU.

I have the latest bios and no fixed mode so I can assume dynamic mode should work fine for this laptop.

Maybe it's a problem of OpenGL but then why can i use AMD opencl device? I can just skip Intel and AMD works fine but faster like it's a device that meant to be used.

0 Likes
Reply
dipak
Staff
Staff

Re: Opengl interop - chosen wrong device but works

but then why can i use AMD opencl device? I can just skip Intel and AMD works fine but faster like it's a device that meant to be used.

Sorry, I didn't get your question. As I already said, the clinfo output looked good to me and an opencl application should run fine on the discrete amd gpu.

By the way, HD 7670M is a legacy gpu. This device is not officially supported, hence there will be no driver update for this gpu. Sorry for that.

0 Likes
Reply
omega_doom
Adept I

Re: Opengl interop - chosen wrong device but works

Ok, i think amd drivers are not good in general. Maybe they are ok for games but not for more complex tasks like opencl.

For example last driver for my laptop shows black picture in opencl. Also support for this hardware was dropped very quickly. This hardware was issued in 2012 and the last driver release is 2016. How can you expect to make a good driver with such short time support?

0 Likes
Reply