This error is generated 3 times in reference to the code below. It has to do with the [][] operators. CUDA:: DeviceMemory<> is a class I defined, almost identical to a std::vector<> class type, with the [] operators behaving the same as vector's would. I am lead to think it is being generated by the [] operators, yet I don't know how to solve it, especially since I have it working in another part of the code. Any help on what this error means, or what causes it would be appreciated.
Code:error: operand of "*" must be a pointer
Code:// code that does not compile, and generates above error
__global__ void Kernel_square2d(CUDA::DeviceMemory< CUDA::DeviceMemory<float> > a)
{
const int idx = blockIdx.x * blockDim.x + threadIdx.x; // these are just for indexing
const int idy = blockIdx.y * blockDim.y + threadIdx.y; // indexing
if (idx < a.size() && idy < a[idx].size()) {
a[idx][idy] = a[idx][idy] + a[idx][idy]; // get an error here, 3 times, one for each a[idx][idy]
}
}
// code that does work, HostMemory is virtually identical to DeviceMemory.
// make a 2D array
printf("Allocating a 10x10 2 dimensional array of type float\n");
HostMemory< HostMemory<float> > twoDimArray;
twoDimArray.allocate(10);
for(unsigned int i = 0; i < twoDimArray.size(); i++) {
twoDimArray[i].allocate(10);
}
// assign values to the 2D array
printf("Assigning values of 10x10 matrix\n");
for(unsigned int i = 0; i < twoDimArray.size(); i++) {
for(unsigned int n = 0; n < twoDimArray[i].size(); n++) {
twoDimArray[i][n] = twoDimArray.size()*i + n;
}
}