i am using OpenCL 2.0 C on nvidia graphic card on windows and i want to use the built in vector data types but i can't use them, they are somehow not declared. For example when i try to initialise a float4 vector i get a following error:
float4 data_vec = (float4)(1.0, 1.0, 1.0, 1.0);
error: 'float4' was not declared in this scope
I kept looking in opencl specification but could not find the reason. though when i try to get the prefered width of any vector type i get 1 as a result for example:
cl_uint float_width;
err = clGetDeviceInfo(devices[0],
CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT,sizeof(char_width), &char_width, NULL);
printf("%d",float_width);
Even if i try CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT or CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR I get 1 as a result.
Anyone could tell me the reason?
Thanks
float4is a device type, to be used in kernel code. Where are you usingfloat4, on the host or in the device code? On the host you need to use cl_float4. And the accessors are different (more like array notation). - Dithermaster