Using multiple programs in OpenCL

Viewed 77

I am writing a piece of code that utilizes the GPU using OpenCL. I succeeded in making a kernel that runs Vector addition (in a function called VecAdd), so I know it is working. Suppose I want to make a second kernel for Vector subtraction VecSub. How should I go about that? Or more specifically: can I use the same context for both the VecAdd and VecSub function?

1 Answers

Hi @debruss welcome to StackOverflow!

Yes, you certainly can run multiple Kernels in the same Context.
You can define the Kernels in the same or multiple Programs. You could even run them simultaneously in two different Command Queues or a single Command Queue configured for out of order execution.

There is an example (in rust) of defining and running two Kernels in a Program here: opencl2_kernel_test.rs.

Related