0
votes

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

1
float4 is a device type, to be used in kernel code. Where are you using float4, 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
oh, right that is actually the point, i was using it in host code, i tested it on kernel no error, thanks a lot. - Jarem
I'll put that as an answer for future viewers. - Dithermaster

1 Answers

2
votes

float4 is a device type, to be used in kernel code. On the host side you need to use cl_float4, and the accessors are different (more like array notation).