Using templated struct as argument in OpenCL kernel

Hi everybody,

I am running into a problem for which I would be incredibly grateful if you could help me a solution.

I am trying to compile the code snippet seen below using clang-17, but get the error:

openclTemplateTest.hpp:12:68: error: '__global MyTemplatedTestStructWithSize *__private' (aka '__global MyTemplatedTestStruct<32> *__private') cannot be used as the type of a kernel parameter
   12 | kernel void myTestFunction(__global MyTemplatedTestStructWithSize* myArgument)
      |                                                                    ^
1 error generated.

The complete list of clang arguments is as follows:

/usr/lib/llvm-17/bin/clang++ -c -cl-std=clc++ -target spir64 -emit-llvm -fcolor-diagnostics -Xclang -finclude-default-header [some header includes for OpenCL-C++ using -I] openclTemplateTest.hpp -o bitcode_out.bc

The first guess is that OpenCL kernels do not support arrays of templated structs as arguments, but that’s not true, is it? If they are allowed in general, what am I doing wrong?

Thank you very much in advance!

The code in question:

template<unsigned int NUM_BLOCKS>
struct MyTemplatedTestStruct
{
    int blocks[NUM_BLOCKS];
};

typedef MyTemplatedTestStruct<32> MyTemplatedTestStructWithSize;

kernel void myTestFunction(__global MyTemplatedTestStructWithSize* myArgument)
{
    for (unsigned int i = 0; i < 5; ++i)
    {
        myArgument->blocks[i] = 42; // completely nonsensical, just for testing purposes
    }
}