Question

What is the global id if we had a 2D index space, with work groups of size (14,30). If a particular execution of the kernel in workgroup (2,3) has

get_local_id(0) = 5 and get_local_id(1) = 7

What would be for get_global_id(0) and get_global_id(1) ? I actually do not have the local size!

How can we calculate?

Does is it equal to

get_global_id(0) = 5*2 = 10

get_global_id(1) = 3*7 = 21
Was it helpful?

Solution

You need to know the local size. And thankfully you can get it by calling get_local_size. It will always return a valid value.

It goes like this assuming no offset:

get_global_id(0) = get_local_id(0)+get_local_size(0)*get_group_id(0)

Remember that even if you call your kernel with NULL as the local size the implementation will make something up so that you will always get valid values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top