Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Static variable error

hey

I have a error when I write the static variable in kernel function.

Here is a simple example.

"

void funA()

{

static int b = 0;

}

void kernel fun(__global int *a)

{

funA();

}

"

Don't I use the "static" in opencl kernel ?

regards.,

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The OpenCL language specification does not allow static variables. See Section 6.8.f "The extern, static, auto and register storage-class specifiers are notsupported."

    --- Quote Start ---

    hey

    I have a error when I write the static variable in kernel function.

    Here is a simple example.

    "

    void funA()

    {

    static int b = 0;

    }

    void kernel fun(__global int *a)

    {

    funA();

    }

    "

    Don't I use the "static" in opencl kernel ?

    regards.,

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can however define constant data at file scope:

    
    __constant int b = 0;
    void funA()
    {
        // Access b here
    }
    void kernel fun(__global int *a)
    {
        funA();
    }