The OpenCL vector types defined in cl_platform.h do not play well with C++. You can not do something this simple:
#include <vector>
typedef float cl_float4[4] attribute((aligned(16)));
int main()
{
std::vector<cl_float4> vals;
cl_float4 a = {1.0f, 2.0f, 3.0f, 4.0f};
vals.push_back(a);
}
Because “ISO C++ forbids assignment of arrays”. If the definition would be changed to a struct like the following:
typedef struct cl_float4
{
float x,y,z,w;
} cl_float4 attribute((aligned(16)));
Not only would this play nicer with C++, it would also mirror the behaviour of float4 in device code, which is a win-win in my book.
-Brian
See also:
http://groups.google.com/group/comp.lan … 01707c9cc7
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40192