AnsweredAssumed Answered

Performance of work-item built-in functions

Question asked by gpgpucoder on Mar 1, 2015
Latest reply on Mar 2, 2015 by gpgpucoder

Questions on performance of work-item built-in functions. I'm talking about these:

get_work_dimNumber of dimensions in use
get_global_sizeNumber of global work items
get_global_idGlobal work item ID value
get_local_sizeNumber of local work items
get_local_idLocal work item ID
get_num_groupsNumber of work groups
get_group_idWork group ID

Are these like real function calls or more like a constant? I am supposing the latter. I might typically write something like this for a starting location:

 

int offset = get_group_id(0)*myitemsize*get_local_size(0);

and initialize other similar offset variables for other things, also using the same built-ins. Or perhaps something like:

int x = get_global_id(0);

If I were to never change x, or offset, do I get a performance benefit by defining these variables in the first place? How are registers impacted?  I was thinking about changing above to something like this for readability but don't know of the impact.

#define x get_global_id(0)

Outcomes