Usage of vector data types in OpenCL host code


I have another question about usage of vector data types in OpenCL host code.
It throws an error if I try to do the following in OpenCl host code.


cl_short4 a;
a.x = 1; – >throws an error : unknown access of ‘ .x’
a.y = 1;
a.z = 0;
a.w = 0;

But it works in the kernel code.

Your comments will be helpful


Host and kernel codes are compiled by different compilers; kernel code compiler recognize special syntax, like “*.[xyzw]”, but with the host compiler, you have available only what’s defined in corresponding header files. For this particular case, see CL/cl_platform.h on your SDK installation - you should be able to get by with “a[0]”, “a[1]”, etc. but this won’t be portable at all (for example, with AMD SDK, at the moment you’d have to use “a.i16[0]”, “a.i16[1]”, etc.).