Issue with cg::this_grid().thread_rank() in Non-Zero blockIdx.x

namespace cg = cooperative_groups;
int tid = cg::this_grid().thread_rank();

It’s strange that the tid retrieved using cg::this_grid().thread_rank() only seems to work when blockIdx.x == 0. When I try to use this in blockIdx.x == 1, nothing gets printed. However, if I switch to using threadIdx.x, everything works as expected.

Why does this happen? Is cg::this_grid().thread_rank() limited to blockIdx.x == 0 by default?

Please show a minimal reproducer.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.