CUDA warp 中的线程是否在多处理器上并行执行?
一个经纱是 32 个线程。 32 个线程在多处理器中并行执行吗? 如果 32 个线程没有并行执行,则 warp 中不存在竞争条件。 在看了一些例子后我产生了这个疑问。
A warp is 32 threads. Does the 32 threads execute in parallel in a Multiprocessor?
If 32 threads are not executing in parallel then there is no race condition in the warp.
I got this doubt after going through the some examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 CUDA 编程模型中,warp 内的所有线程并行运行。但硬件中的实际执行可能不是并行的,因为 SM(流多处理器)内的核心数量可能少于 32 个。例如,GT200 架构每个 SM 有 8 个核心,而一个 warp 内的线程将需要 4 个时钟周期来完成执行。
如果多个线程写入同一位置(共享内存或全局内存),并且如果您不想竞争,那么您必须使用原子操作或锁,因为 CUDA 编程模型不保证哪个线程将写入。
In the CUDA programming model, all the threads within a warp run in parallel. But the actual execution in hardware may not be parallel because the number of cores within a SM (Stream Multiprocessor) can be less than 32. For example, GT200 architecture have 8 cores per SM, and the threads within a warp would need 4 clock cycles to finish the execution.
If multiple threads write to the same location (either shared memory or global memory), and if you don't want race, then you have to use atomic operations or locks, because CUDA programming model does not guarantee which thread is going to write.
是的。 WARP 中的 32 个线程将并行执行。 GPU是SIMT(单指令多线程)机器,单指令由多个线程并行执行。
顺便说一句,SIMT 在某种程度上是一个营销术语,它与 SIMD 基本相同。
Yes. The 32 threads in a WARP will execute in parallel. The GPU is a SIMT (single instruction multiple thread) machine, single instruction which is executed by multiple threads in parallel.
Btw, SIMT is somewhat of a marketing term, it is basically the same as SIMD.