Inso Reiges
Inso Reiges

Reputation: 1929

OpenCL: Running CPU/GPU multiple devices

I want to run parallel tasks on GPU and CPU with OpenCL multiple devices. The standard examples from AMD SDK are not very clear on this subject. Can you advise any additional tutorials or examples on this subject? Any advice will do.

Thank you.

Upvotes: 6

Views: 10938

Answers (5)

Chanakya.sun
Chanakya.sun

Reputation: 587

OpenCL Programming Guide by Aftab Munshi & others will give you more details.

Upvotes: 0

Lissanro Rayen
Lissanro Rayen

Reputation: 589

Running parallel tasks on multiple devices requires dynamic scheduling for good effeciency because you never know exact performance of any device - it depends from current load (not only by your program but all others too), current clock (it may change significantly on most CPUs and GPUs depending on current energy saving profile or load). Also, real-world performance may depend on your input data.

Of course, you can write all neccessary code yourself like all other answers suggest, but in my opinion it is waste of time and it is much better idea to use existing solution. I recommend to use StarPU. I have used StarPU in my OpenCL project and it worked pretty well. StarPU comes with examples how to write code capable of using multiple GPUs and CPUs efficiently.

StarPU:

Traditional processors have reached architectural limits which heterogeneous multicore designs and hardware specialization (e.g. coprocessors, accelerators, ...) intend to address. However, exploiting such machines introduces numerous challenging issues at all levels, ranging from programming models and compilers to the design of scalable hardware solutions. The design of efficient runtime systems for these architectures is a critical issue. StarPU typically makes it much easier for high performance libraries or compiler environments to exploit heterogeneous multicore machines possibly equipped with GPGPUs or Cell processors: rather than handling low-level issues, programmers may concentrate on algorithmic concerns.

There is also another project, SkePU, but I did not try it myself:

SkePU:

SkePU is such a skeleton programming framework for multicore CPUs and multi-GPU systems. It is a C++ template library with six data-parallel and one task-parallel skeletons, two container types, and support for execution on multi-GPU systems both with CUDA and OpenCL. Recently, support for hybrid execution, performance-aware dynamic scheduling and load balancing is developed in SkePU by implementing a backend for the StarPU runtime system.

If you Google for "dynamic scheduling gpu cpu opencl" you can find even more possibly useful free or commercial projects and documentation.

Upvotes: 5

Divij
Divij

Reputation: 928

For tutorial and details on using multiple devices, you may want to refer section 4.12 of the AMD-APP-SDK Programming guide

Upvotes: 1

Rick-Rainer Ludwig
Rick-Rainer Ludwig

Reputation: 2401

With clGetPlatforms you will find out whether you have more than one platform or not. If you run a nVidia GPU board and an AMD CPU you will find to platforms. One platform for the AMD SDK and one for the nVidia CUDA OpenCL implementation. With clGetDevices you will find for each platform the devices available. It might be one per platform like 1xGPU and 1xCPU.

For each device create a context with clCreateContext and then you can run both in parallel.

Upvotes: 1

pmdj
pmdj

Reputation: 23438

There's nothing holding you back from doing this. You'll need to supply all devices you want to use to your call to clCreateContext() and then create at least one command queue for each of them. Depending on what you're trying to do, you may need to look at the more advanced task scheduling techniques, e.g. using out-of order command queues and events to schedule tasks across devices.

Upvotes: 1

Related Questions