Intel® High Level Design
Support for Intel® High Level Synthesis Compiler, DSP Builder, OneAPI for Intel® FPGAs, Intel® FPGA SDK for OpenCL™
701 Discussions

Cannot use custom type in kernel

GRodr25
Beginner
1,745 Views

Hello,

I am unable to use a custom type in my OpenCL kernel, passing it by value (error: unsupported kernel argument type. This problem arises in compilation time). I found a solution in this question https://forums.intel.com/s/question/0D50P00004Nr1jn/emulation-fails-with-userdefined-data-type-for-a-kernel-argument, which tackles the problem passing a pointer and setting the address qualifier __global. I would rather stay with the passing by value version, due to some application constraints. I am using Intel FPGA SDK for OpenCL 16.1. Is there other way to overcome this issue instead of this ugly trick?

 

Just in case it helps you, I reproduced the problem with a minimal kernel:

 

typedef struct {   char a;   char b;  } error_type;    __kernel void min_kernel(error_type err_data) {   err_data.a = 'a';   err_data.b = 'b'; }

Thank you.

0 Kudos
4 Replies
MEIYAN_L_Intel
Employee
1,533 Views

Hi,

 

I had compare two OpenCL SDK version which are v16.0 and v19.3.

The latest version had stated "Pass structure parameters (struct) in OpenCL kernels either by value or as a pointer to a structure" while in v16.0 stated "Convert each structure parameter (struct) to a pointer that points to a structure".

I am checking internally whether in v16.0 can passing structure parameters by value.

 

Thanks

0 Kudos
MEIYAN_L_Intel
Employee
1,533 Views

Hi,

You can be able to put the struct as a parameter in the kernel declaration and then call clSetKernelArg() from host (https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/clSetKernelArg.html).

 

For an example:

// Host

error_type et;

clSetKernelArg( min_kernel, 0, sizeof(error_type), &(et) )

 

Thanks

0 Kudos
GRodr25
Beginner
1,533 Views

Hello @MeiYanL_Intel​,

Thank your for your answer. I am afraid that will not work, since AOC will not allow me to compile min_kernel. I read in one of the Intel guides structs must be passed as pointers, indeed. So, there seems to be no other way than creating a buffer for the struct and passing a pointer to it.

 

Thank you.

0 Kudos
MEIYAN_L_Intel
Employee
1,533 Views

Hi,

You are welcome.

Thanks

0 Kudos
Reply