Forum Discussion

GRodr25's avatar
GRodr25
Icon for New Contributor rankNew Contributor
6 years ago

Cannot use custom type in kernel

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.

4 Replies

  • MEIYAN_L_Intel's avatar
    MEIYAN_L_Intel
    Icon for Frequent Contributor rankFrequent Contributor

    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

    • GRodr25's avatar
      GRodr25
      Icon for New Contributor rankNew Contributor

      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.