CUDA: synchronizing threads

前端 未结 4 1746
小鲜肉
小鲜肉 2021-02-04 09:30

Almost anywhere I read about programming with CUDA there is a mention of the importance that all of the threads in a warp do the same thing.
In my code I have a situation wh

4条回答
  •  没有蜡笔的小新
    2021-02-04 09:58

    From section 6.1 of the CUDA Best Practices Guide:

    Any flow control instruction (if, switch, do, for, while) can significantly affect the instruction throughput by causing threads of the same warp to diverge; that is, to follow different execution paths. If this happens, the different execution paths must be serialized, increasing the total number of instructions executed for this warp. When all the different execution paths have completed, the threads converge back to the same execution path.

    So, you don't need to do anything special.

提交回复
热议问题