在 CUDA PTX 中,%warpid 到底是什么意思?
In CUDA PTX, what does %warpid mean, really?
在 CUDA PTX 中,有一个特殊寄存器用于保存线程的 warp 索引:%warpid
。现在,规范说:
Note that %warpid
is volatile and returns the location of a thread
at the moment when read, but its value may change during execution,
e.g., due to rescheduling of threads following preemption.
嗯,那是什么地方?它不应该是块内的位置,例如对于一维网格 %tid.x / warpSize
?它是 SM 中的某个 slot-for-a-warp(例如 warp 调度程序或某些内部队列)?我很困惑。
动机:我想通过使用这个特殊的寄存器来省去计算%tid.x / warpSize
的麻烦,同时释放一个寄存器。
您需要阅读您在问题中发布的引文后紧跟的文档的接下来的 25 个单词:
For this reason, %ctaid and %tid should be used to compute a virtual
warp index if such a value is needed in kernel code;
然后是
%warpid is intended mainly to enable profiling and diagnostic code to
sample and log information such as work place mapping and load
distribution.
所以不,你不能用它来做你想做的事。 %warpid
实际上是一个调度程序槽 ID,而不是一个块内恒定的、唯一的 warp 索引。
在 CUDA PTX 中,有一个特殊寄存器用于保存线程的 warp 索引:%warpid
。现在,规范说:
Note that
%warpid
is volatile and returns the location of a thread at the moment when read, but its value may change during execution, e.g., due to rescheduling of threads following preemption.
嗯,那是什么地方?它不应该是块内的位置,例如对于一维网格 %tid.x / warpSize
?它是 SM 中的某个 slot-for-a-warp(例如 warp 调度程序或某些内部队列)?我很困惑。
动机:我想通过使用这个特殊的寄存器来省去计算%tid.x / warpSize
的麻烦,同时释放一个寄存器。
您需要阅读您在问题中发布的引文后紧跟的文档的接下来的 25 个单词:
For this reason, %ctaid and %tid should be used to compute a virtual warp index if such a value is needed in kernel code;
然后是
%warpid is intended mainly to enable profiling and diagnostic code to sample and log information such as work place mapping and load distribution.
所以不,你不能用它来做你想做的事。 %warpid
实际上是一个调度程序槽 ID,而不是一个块内恒定的、唯一的 warp 索引。