If I have multi GPUs in my system, how can I know which gpu is used by the OS.
I am using OpenCL to do computing, and I don't want do use this gpu to do gpgpu.
thanks in advance.
Which OS are you on ?
1) both conditions "gpgpu" and "OpenCL to do computing", are similar
2) For OpenCL 1.2 has no any tools to choice free Device, for example the result of call clGetDeviceInfo(.., CL_DEVICE_AVAILABLE,...) can be returned as "true", even if this device is not connected to Monitor
you can choice
3) You can create a temporary OpenGL context or Direct3D11 device and try to choice free device is not associated to this OpenGL Context or Direct3D11 device.
dipak, what do you think about it ?
I completely agree with your points. AFAIK, OpenCL doesn't provide any device query parameter to know that information. The 3rd option can be a way to identify the active device.
On the other hand, GPU_DEVICE_ORDINAL environment parameter can be used to mask the visibility of the GPUs seen by the OpenCL application. For example, on a 3-GPU system, one GPU is using regular graphics operations and we want that OpenCL should use other two GPUs for compute jobs. To do that, on Windows, we can set this parameter as: set GPU_DEVICE_ORDINAL=1,2
Yes, I was told to use OpenGL context, specifically glGetString(GL_VENDOR).
On my computer, it returns "NVIDIA Corporation".
I wonder if I have several GPUs of the same brand, how to decide?
My computer only has one GPU, But i was asked to make a program who can deal with any number of GPUs and brands.
I think, clGetGLContextInfoKHR can be used to query the CL device currently associated with the specified OpenGL context. Later while creating the OpenCL context for computing, you can avoid this device.
Please note, OpenCL context is associated with a single platform only and it is created with one or more OpenCL devices available on the platform. Thus, on a multi-vendor multi-GPU setup, first you need to list all the platforms discovered by the clGetPlatformIDs and then get the list of devices available on each platform using clGetDeviceIDs .
I think this is the function I am looking for.
Thank you so much dipak!
If you know the PCI bus number and your code isn't being deployed on lots of machines you can just hard code the application not to run on that device. You can get the PCI bus number in Open CL as long as you are using the AMD version, using clGetDeviceInfo and CL_DEVICE_TOPOLOGY_AMD.
If you need to discover the PCI bus number of GPUs with a display attached you could use the Windows AMD Display Library method (ADL_Adapter_Active_Get). First you would do a ADL_Adapter_AdapterInfo_Get to get a LPAdapterInfo which contains the PCI Bus number.
GitHub - GPUOpen-LibrariesAndSDKs/display-library: AMD Display Library SDK
The samples in here have all the relevant code.
ADL (AMD Display Library) Public APIs
Retrieving data ...