Remix.run Logo
▲ loeg 41 minutes ago

I think the answer is yes, a counter is state, but it's state that is already available anyway.

▲articulatepang 32 minutes ago | parent [-]

Correct, each thread in a GPU kernel launch has its threadIdx.x and so forth. It needs this just in order to know, "Which part of the work am I supposed to do?"

For example, if you're writing matrix multiplication, each thread needs to know which tile it's working on. If you're simulating particles, each thread might have some block of particles to work on. And so forth. Any GPU code always has this available.