logoalt Hacker News

loeg • today at 8:42 PM • 1 reply • view on HN

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


Replies

articulatepang • today at 8:50 PM

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.

➕ show 1 reply