Hey everyone,

I have a code for a simple diffusion problem (with Q=5 iterations), which gives me an error message; at Line 15 (two times) and Line 18 (three times) it says, â€œerror: expression must have pointer-to-object typeâ€. Does anyone know what to do? (Again, I just want to run this diffusion equation for a given number of steps).

Thanks for looking!

# include <stdio.h>

# include <stdlib.h>

# include <cuda.h>

**global** void incrementArrayOnDevice(float *c, float q, int N)
{
int idx = blockIdx.xblockDim.x + threadIdx.x;
int x;
int Q = 5;
for(x=0; x<Q; x++)
{
q[idx][x] = c[idx][x];
for(idx=1; idx<N-1; idx++)
{
c[idx][x] = 0.25*q[idx-1] + 0.5

*q[idx][x] + 0.25*q[idx+1];

}

}

}

int main(void)

{

printf("\n");

float *a_h, *b_h;

float *a_d,

*q;*

int i;

int N = 10;

size_t size = Nsizeof(float);

int i;

int N = 10;

size_t size = N

a_h = (float *)malloc(size);

b_h = (float *)malloc(size);

cudaMalloc((void **) &a_d, size);

cudaMalloc((void **) &q, size);

for (i=0; i<1; i++)

{

a_h[i] = 5;

}

for (i=1; i<N; i++)

{

a_h[i] = 0;

}

cudaMemcpy(a_d, a_h, sizeof(float)*N, cudaMemcpyHostToDevice);

int blockSize = 4;

int nBlocks = N/blockSize + (N%blockSize == 0?0:1);

incrementArrayOnDevice <<< nBlocks, blockSize >>> (a_d, q, N);

cudaMemcpy(b_h, a_d, sizeof(float)*N, cudaMemcpyDeviceToHost);

printf("\n");

for(i=0; i<N; i++)

{

printf("%f\n",b_h[i]);

}

free(a_h); free(b_h); cudaFree(a_d);

printf("\n");

}