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:


  // 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:


    int mat_i =  4*tx;
    int mat_j =  4*ty;   

or


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

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.