cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

How to link Macros defined in the host code to the kernel code?

I am trying to execute a bitonic sort code from the book OpenCL in Action__Matthew Scarpino. In the cl code they have defined two macros and have called these macros in the kernel code(I have attached an image of this code below). But I think macros can't be defined in kernel code, so we need to define them in the host code. If this is so how do we link them to the kernel code..? i mean how do we give it as an argument to the kernel code..?

   I have also attached a pdf of this book  below, this part is given in section 11.2(chapter name : Coding Practical in OpenCL->  Bitonic Sort).

I have one more doubt... Can I see what values do the variables possess as the kernel code progresses.. how do we do this... giving breakpoints doesn't work...!

1 Solution
himanshu_gautam
Grandmaster

Check the build options parameter of clBuildProgram API. And check section 5.6.4 of OpenCL spec 1.2 for details on how to define macros from host side.

View solution in original post

0 Likes
2 Replies
himanshu_gautam
Grandmaster

Check the build options parameter of clBuildProgram API. And check section 5.6.4 of OpenCL spec 1.2 for details on how to define macros from host side.

0 Likes

Although it is also ok to define macros in device code. The preprocessor is run over the kernels.