So it's not defined in the standard, but how ugly is it?
As I understand it, using vectors in host code is implementation defined, but is there some way which is broadly supported (meaning it will work using both AMD and Nvidia SDKs)?
At present I do not even need to access or change the values of the vector type arrays in host code, I just need to be able to copy them and rearrange them. The attached code illustrates the kind of operations I want to be able to do (I haven't even tried doing this yet, as I want to aviod non-standard stuff as much as possible).
So basically, are the kinds of operations done in the attached code snippet allowed and guaranteed to work on all implementations, or is there still something that relies on non-standard behaviour?
My impression is that the only problem with vectors in host code is that there is no standard way to access the elements, so depending on how the vector components are stored (in what order) it's not possible to write truly portable code. Have I got the gist of it correctly or what?
Thanks for any help
//Create float3 buffer cl::Buffer Buffer3(context, CL_MEM_READ_WRITE, sizeof(cl_float3) * length, NULL, &err); //Create host array to hold the buffer contents cl_float3 *float3arr = new cl_float3 [length]; //Read buffer into host array queue.enqueueReadBuffer(Buffer3, CL_TRUE, 0, sizeof(float3) * length, float3arr); //Shuffle some values around (here switching first and second vectors) cl_float3 temp = float3arr[0]; float3arr[0] = float3arr[1]; float3arr[1] = temp; //Write array back into buffer. Is everything still guaranteed to be consistent? queue.enqueueWriteBuffer(Buffer3, CL_TRUE, 0, sizeof(float3) * length, float3arr);