Results 1 to 2 of 2

Thread: A bit confused regarding get_local_id and get_group_id

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    5

    A bit confused regarding get_local_id and get_group_id

    Is the value returned by get_local_id indexed relative to the group id or is it globally indexed.



    Take the following example:
    I am splitting a matrix up into small 4x4 blocks for processing. Each thread will compute the results for a single 4x4 block. So to find the (i,j) of that matrix do I need to simply refer to the get_local_id or do I need to offset by the group id.

    I have the following to get group index:
    Code :
      // Block index
        int gx = get_group_id(0);
        int gy = get_group_id(1);
     
        // Thread index
        int tx = get_local_id(0);
        int ty = get_local_id(1);

    so which indexing should I do:
    Code :
        int mat_i =  4*tx;
        int mat_j =  4*ty;

    or
    Code :
        int mat_i =  4*tx + THREADS_PER_GROUP*4*gx;
        int mat_j =  4*ty + THREADS_PER_GROUP*4*gy;

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: A bit confused regarding get_local_id and get_group_id

    Is the value returned by get_local_id() indexed relative to the group id or is it globally indexed
    For each work-group, the local IDs will go from 0 to get_local_size()-1. That is, from zero to the work-group size minus one.

    It's explained in section 3.2 of the spec.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. OpenCL for 32 bit (x86) on 64 bit Windows 7
    By JohnJi in forum OpenCL - parallel programming of heterogeneous systems
    Replies: 0
    Last Post: 08-02-2012, 09:18 AM
  2. 32 bit textures on 16 bit framebuffer
    By muratmat in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 08-21-2008, 07:59 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
  •