문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top