Results 1 to 2 of 2

Thread: Global variables in OpenCL

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    2

    Global variables in OpenCL

    Hello,
    I was wondering, is there any possibility to use global variables in OpenCL that are consistent over several functions called from the kernel?

    Let me give you an example of what I'm looking for.

    Code :
    uint numObjects;
     
    __kernel mainKernel
    (__global uint numberOfObjects,
    /* other variables */
    )
    {
         numObjects = numberOfObjects;
    }
     
     
    void doSomethingElse
    (
       /* variables */
    )
    {
        int i;
        for(i = 0; i < numObjects; i++)
        {
     
        }
    }

    I'm asking this because otherwise I have to send the variable through many functions as the doSomethingElse() function is supposed to be called from a different function and not the kernel itself.

    Thank you.

    //Considerate

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Global variables in OpenCL

    Global variables can be declared in program source but they must use the "constant" address space qualifier and need to be initialized. You cannot have global variables that can be modified by kernels and where the modified values are persistent across work-groups and kernel executions. For this, you should use memory objects instead.

Similar Threads

  1. initialize global variables
    By sanderbeckers in forum OpenCL
    Replies: 1
    Last Post: 03-18-2011, 05:46 AM
  2. Global Arrays in OpenCL
    By HolyGeneralK in forum OpenCL
    Replies: 2
    Last Post: 10-04-2010, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •