Do the threads in a CUDA warp execute in parallel on a multiprocessor?

后端 未结 2 1368
無奈伤痛
無奈伤痛 2021-01-22 19:27

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

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 20:10

    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.

提交回复
热议问题