Branch based on the WARP ID

423 Views Asked by At

Is there any way to find the WARP id of a thread in CUDA? I want to perform a branch based on the WARP id.

1

There are 1 best solutions below

4
On

There is the %warpid register, and it wouldn't be hard to write a function that accesses it via inline assembly.

However, it is extremely unusual that you would ever want to use it; e.g.

  • threads don't "stay put" and will change which warp they're running on over time
  • it's not a globally unique identifier

which makes its possible use cases extremely limited. To quote the documentation:

... The warp identifier provides a unique warp number within a CTA but not across CTAs within a grid. ...

Note that %warpid is volatile and returns the location of a thread at the moment when read, but its value may change during execution, ... %warpid is intended mainly to enable profiling and diagnostic code to sample and log information such as work place mapping and load distribution.