Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "expression must have integral or enum type" in thats code:

Tags:

cuda

Error "expression must have integral or enum type" in thats code:

__global__ void VectorKernel(float *a, float *b, float *c, int n)
{
    int i = threadIdx.x;
    float y = 0, z = 0;

if (i < n)

    y = (b-a) / n;

    for (float j = y; j <= n ; j++) {
        z = (((j+y) - j) / 6) * function(j) + 4 * (function((j + (y+j)) / 2)) + function(y+j);

        c = c + z;
    }
}

the error happen in "z", in stretch:

c = c + z;

(i'm beginner in CUDA programming)

like image 301
Yago Tonini Avatar asked Dec 01 '25 11:12

Yago Tonini


1 Answers

c is a pointer. Pointer arithmetic requires a pointer and an integer type expression.

If you want to to add z to the float pointed to by c you should change the expression to:

*c = *c + z;
like image 54
Klas Lindbäck Avatar answered Dec 04 '25 17:12

Klas Lindbäck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!