I have the following code in CUDA
__global__ void matvec(int *MAT, int *VEC, int *SOL)
{
int bx = blockIdx.x;
int tx = threadIdx.x;
int i = 32*bx+tx;
for (int j = 0; j < X; j++){
SOL[i] = ((MAT[i][j] * VEC[j]) + SOL[i]) % 2;
}
}
My problem is that in line 6 I have an error. It says that my expression must have a pointer-to-object type.
The reason for the error is that you are treating a pointer as a 2D array. You define MAT as int *MAT, but you access it as MAT[i][j].
Assuming you have correctly allocated MAT, I would change this to MAT[i*X + j]. Alternatively, define MAT as int **MAT, again, assuming you have allocated it correctly.
(BTW, this is not a CUDA problem, it is a simple C syntax error.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With