I would like to build a structure with 4 values. As I saw CUDA already provides the float4 type which allows you to save 4 float values and ensures fast memory access. However I have problems to define an array of float4 values.
I tried 2 versions, in the first one I just put the elements in a linear array, not knowing if CUDA handles a float4 just as one data element.
float4 weightedVoxel; size_t size=100*sizeof(float4); cudaMalloc((void**) &weightedVoxel, size); weightedVoxel.x=1;
I get following error message: no operator “” matches these operands
operand types are: float4 [ int ]
However the acces to the element doesn’t work, so I tried the CUDA array, even I just have a 1D array of float 4 elements.
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<float4>(); cudaArray* weightedVoxel; cudaMallocArray(&weightedVoxel, &channelDesc, 100,1); weightedVoxel.x=1;
However thee I get the error message: ‘expression must be a pointer to a complete object type’
So, what I am doing wrong here? Is there a closer description of the different variable types, the one in the programming guide is really short?