Originally posted by: lust Hello,
I needed to define some things to make previous OpenCL code work.
#define __constant __const
#define true 1
#define false 0
__const, true, false etc are not keywords as per OpenCL specification, which means they will have to be defined explicitly, in case you need to use them.
Also, indexing in float4s does not work, i.e.
This is due to incorrect way of indexing, you can access the 3rd element of a float4 variable by either f.z or f.s2
Well, about true or false it is ok, but nVidia's OpenCL SDK supports indexing in float4s. This is crucial for our application, since it is too frequently used and if we replace it by a swith/case construct this may yield a lot of divergence.
Support for array like indexing for float4 is not a requirement as per OpenCL Specification
Well, it would be nice, and comfortable, for us, poor developers More than the spec is always better
If you want indexing into floats, use a float array.
In your case above
float a = f;
Vectors are not arrays as vectors are mapped to the underlying vector hardware and an array is mapped depending on it's type. NVidia can do this because they are a scalar architecture, so they map all vectors to multiple scalars. One of the reasons for OpenCL is that you don't have to write different code for different vendors for the code to work correctly, by not following the OpenCL spec and allowing things that aren't there, this breaks this situation.