cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

psath
Journeyman III

Kernel Compile-time "adjustable" constant

Hi guys, I'm working with memory coalescing in my kernel and I'm trying to write things generically as possible. I want to allocate a local array like "__local float coalesce[get_local_size(0)]" I know that this operation isn't permitted (variable length array), but the only time I need it to "vary" is right when I compile the kernel. Local sizes must be adjustable on a per-run basis in the host code, but will never change after their first initialization.

Is there anyway of passing a variable down to the OpenCL compiler other than simply appending the rest of the source to a string like "#define localSize %d\n" +

Thanks!

-psath

 

Oh now I feel silly... "-D name=definition" preprocessor option to clbuildprogram.

Tags (1)
0 Likes
3 Replies
MicahVillmow
Staff
Staff

Kernel Compile-time

pass something like "-DLOCAL_SIZE=64" as an option to clBuildProgram
0 Likes
psath
Journeyman III

Kernel Compile-time

just found that in the spec, but thanks!

0 Likes
LeeHowes
Staff
Staff

Kernel Compile-time

Or why not use the run-time specification of local allocation as an alternative? Does it really need to be compile-time at all?

I only ever use the run-time version because I think the scoping makes more sense. That is pass a __local float *coalesce pointer to the kernel.

0 Likes