0

I am trying to translate a smaller program written in C into openCL. I am supposed to transfer some input data to the GPU and then perform ALL calculations on the device using successive kernel calls.

However, I am facing difficulties with parts of the code that are not suitable for parallelization since I must avoid transferring data back and forth between CPU and GPU because of the amount of data used.

Is there a way to execute some kernels without the parallel processing so I can replace these parts of code with them? Is this achieved by setting global work size to 1?

2 Answers 2

0

You could manage two devices :

  • the GPU for highly parallelized code
  • the CPU for sequential code

This is a bit complex as you must manage one command-queue by device to schedule each kernel on the appropriate device.

If the devices are part of the same platform (typically AMD) you can use the same context, otherwise you will have to create one more context for the CPU.

Moreover, if you want to have a more fine-grained CPU task-parallelization you could use device-fission if your CPU supports it.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer. I'm new to openCL so forgive me if this is a stupid question but if I have two contexts ( Intel CPU and nVidia GPU ) doesn't that mean that I still have to send data back and forth?
You could use pinned-memory with memory-mappings : CPU will have direct access to the memory, and GPU may copy the necessary parts to its global memory. If you have a lot of data movements compared to processing you may have to adapt your algorithm. In the ideal case you'll be able to run CPU and GPU concurrently.
0

Yes, you can execute code serially on OpenCL devices. To do this, write your kernel code the same as you would in C and then execute it with the clEnqueueTask() function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.