I am trying to explore the way to use structure in opencl
I first try struct (defined on host)
typedef struct UserStruct {
cl_int x;
cl_int y;
cl_int z;
cl_int w;
} UserStruct;
and structure (defined on device)
typedef struct UserStruct {
int x;
int y;
int z;
int w;
} UserStruct;
Using the defined structure, I create two buffers (para_input and para_output) and init them by different values. The kernel function copies value from para_input to para_output.
The example works fine.
But, when I add cl_int16 in the struct, the copying kernel does not work. here is the modified structure:
typedef struct UserStruct {
cl_int x;
cl_int y;
cl_int z;
cl_int w;
cl_int16 vn16;
} UserStruct;
and structure (defined on device)
typedef struct UserStruct {
int x;
int y;
int z;
int w;
int16 vn16;
} UserStruct;
Is there requirement to align the structure on both host and device? Or what is the most popular way to use structure in opencl? Thanks.