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
MATasint *MAT, but you access it asMAT[i][j].Assuming you have correctly allocated
MAT, I would change this toMAT[i*X + j]. Alternatively, defineMATasint **MAT, again, assuming you have allocated it correctly.(BTW, this is not a CUDA problem, it is a simple C syntax error.)