brucefan1983 / CUDA-Programming

Sample codes for my CUDA programming book
GNU General Public License v3.0
1.51k stars 316 forks source link

代码优化 #25

Closed Z-JY-Alex closed 1 year ago

Z-JY-Alex commented 1 year ago

08-shared-memory章节中的reduce2gpu.cu中的 50、75、100行中的__syncthreads();可以放在循环外,可以减少运行时间。

fever-Wong commented 1 year ago

谢谢,您发给我的邮件已经收到,我会尽快处理。Thank you,the email you sent me has been received and I will handle it as soon as possible.王景博fever wong

brucefan1983 commented 1 year ago

08-shared-memory章节中的reduce2gpu.cu中的 50、75、100行中的__syncthreads();可以放在循环外,可以减少运行时间。

这里不能把同步移出循环的。即使你测试发现结果不变,也不代表一定安全。原则上循环内的每一次迭代都需要同步的。

Z-JY-Alex commented 1 year ago

感谢,是我理解错了。