Results 1 to 5 of 5

Thread: Global writable parameters passing

  1. #1
    Member
    Join Date
    Sep 2009
    Posts
    35

    Global writable parameters passing

    How do you pass a parameter, that is one element of global array, so that the called function has ability to write back to that global element?

    Code :
    void Auxiliary(__global SomeStruct element)
    {
        element.something = ...;
    }
    __kernel void Kernel(__global SomeStruct *data)
    {
        Auxiliary ( data[get_global_id(0)] );
    }

    Is this valid ? Are variable references or pointer to one struct element available?
    It's really ugly to pass the whole global array and item id to Auxiliary function...

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Global writable parameters passing

    As long as you keep the memory type (global, local, private, constant) in mind, you can just pass around pointers as you do in C. E.g., just pass the function a pointer to the struct and then de-reference it there.

  3. #3
    Member
    Join Date
    Sep 2009
    Posts
    35

    Re: Global writable parameters passing

    Can I use the -> operator or I must do (*element).something ?

    Are variable references available ?
    Code :
    void Auxiliary(__global SomeStruct &element)
    {
        element.something = ...;
    }

    (Sorry for asking, but I have to since I'm writing OpenCL code blindly, with no access to OpenCL enabled hardware to test it atm.)

  4. #4
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Global writable parameters passing

    I know both AMD and Apple have OpenCL that will run on your CPU, so you should be able to play around with it regardless of your graphics card. In general I suggest people start working with OpenCL on the CPU because it is far more forgiving for debugging. (And you can often get printf and a bit of gdb to work, although neither are officially supported.)

  5. #5
    Member
    Join Date
    Sep 2009
    Posts
    35

    Re: Global writable parameters passing

    Unfortunately OpenCL (AMD/ATI's implementation) support X86 CPU w/ SSE 3.x or later. My historic Intel P4 doesn't meet the minimal requirement. And OpenCL specs are cheap on words considering pointers (or support of variable references) in OpenCL. Can you feel my pain?

Similar Threads

  1. Replies: 3
    Last Post: 01-30-2013, 03:34 AM
  2. GL_TEXTURE_CROP_RECT_OES parameters
    By Nils Pipenbrinck in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 06-12-2007, 04:13 AM
  3. ML Audio Parameters
    By ehsan2004 in forum OpenML Coding & Technical Issues
    Replies: 1
    Last Post: 07-24-2004, 06:44 AM

Posting Permissions

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