How to use 2 OpenCL runtimes

I want to use 2 OpenCL loops on the same system together (in my case, AMD and Nvidia, but the question is pretty general).

I know that I can compile my program with any SDK. But when I start the program, I need to provide libOpenCL.so. How can I provide libs of both versions so that I see 3 devices in my OpenCL program (AMD processor, AMD GPU, Nvidia graphics adapter)?

I know that this should be possible somehow, but I did not find a description of how to do this for linux.

Thanks a lot, Thomas

+6
source share
4 answers

The answers of Smith and Thomas are correct; it simply extends this information: when you list the OpenCL platforms, you will get one for each installed driver. In each platform, you list devices. AMD and Intel drivers also display processors. Thus, on fully-populated machines, you can see the AMD platform (with processors and GPU devices), the NVIDIA platform (with GPU devices) and the Intel platform (with processors and GPU devices). Your code creates a context on any device that you want to use, and one or more queues of commands for their submission. You can make them busy working on things, but you can only share data buffers between devices from the same platform. To exchange data between platforms, it must delete processor memory between them.

+4
source

You do not think about it correctly. The SDK is not provided by the application and is not needed to run the compiled program. OpenCL battery life is provided by the client system and what gives your software platforms and devices for use in clGetPlatformIDs and clGetDeviceIDs .

If a user does not have an Nvidia graphics card, you simply cannot use the Nvidia platform and device on your system, because he does not have the execution time or Nvidia OpenCL hardware.

All of the various OpenCL SDKs provide you with vendor-specific extensions, which are then understood at vendor runtime.

+5
source

The Khronos OpenCL working group has identified an ICD (installable client driver) level that allows multiple vendor drivers to be installed on the system. The application accesses vendor drivers through the ICD layer. See cl_khr_icd.txt for details .

+4
source

Regarding the simultaneous launch of several OpenCL devices. If you want to run on multiple devices, create a separate context for each device / provider and run each in a separate thread. For example, I have a GTX 590. This appears as two GTX 590 devices. I also have an Intel i7 processor. I create three contexts: two for 590 devices and one for the processor and start each context / device in three threads using SDL_CreateThread (pthreads also works well). You must weigh the number of tasks for each device, proportional to their "speed" if you want to get good results. For example, 45% for each GTX 590 and 10% for the CPU. The best weights to use depend on the application.

+2
source

All Articles