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.
Asked
Active
Viewed 403 times
1 Answers
3
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.

Community
- 1
- 1
-
1"threads don't "stay put" and will change which warp they're running on over time." Do you have a reference for that? AFAIK warp number and lane number are fixed for the life of a thread – talonmies Jul 23 '15 at 19:45
-
@talonmies: Yes: the PTX ISA documentation, as quoted. – Jul 23 '15 at 19:56
-
For my own purpose which is using GPGPU-Sim simulator, I am sure that the the warp id remains unchanged for the life of a thread. – AmirC Jul 23 '15 at 23:12
-
@Hurkyl: Yes, but that doesn't mean that "threads don't "stay put" and will change which warp they're running on over time". It means that the CTA `%warpid` value assigned to a given warp is transient. But a thread (and its 31 neighbours) stay in the same warp for their lifespan. What you didn't quote is the text directly following it which says you can use %ctaid and %tid to calculate the unique warp number. – talonmies Jul 24 '15 at 05:40