0
votes

I have two questions related to the arguments of an OpenCL kernel. Please, correct me if I'm wrong in the context that I use to describe my questions.

The scalar arguments (e.g., kernel foo (int a) ) are placed in the private address space (like all the kernel arguments, regardless if they are scalar or not). There is no need of __private keyword; by default arguments are placed in the private address space. Q1: who takes care of placing the scalar in the GPU private address space? there is no need of explicit transfer operation (from CPU to GPU address space) for a scalar. why is that? Q2: can I have a scalar as an argument output? I want to get, among other arrays, one value from a kernel calculation.

1

1 Answers

1
votes

Q1: The OpenCL runtime takes care of your kernel arguments.

Q2: No. You would have to write to a buffer or image. If you want a single value from the whole execution of the kernel, consider it a reduction. Your kernel will potentially be running simultaneously on a certain number of processing units and those instances may not be executed in any particular order. If your kernel stores a single value, each instance of your kernel will each be storing one value. Each instance should have its own place to store the value so one doesn't overwrite another.