opencl-并行还原,无需本地内存 [英] opencl- parallel reduction without local memory
本文介绍了opencl-并行还原,无需本地内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大多数并行约简算法都使用共享的(本地)内存.
Most of the algorithms for parallel reduction uses shared(local) memory.
Nvidia,AMD,Intel等.
Nvidia,AMD, Intel and so on.
但是如果设备没有共享的(本地)内存.
But if devices has doesn't have shared(local) memory.
我该怎么办?
如果我使用相同的算法但将临时值存储在全局内存中,那会很好吗?
If i use same algorithms but store temporary value on global memory, is it gonna be work fine?
推荐答案
如果考虑到这一点,我的评论已经是完整的答案.
If I think about it, my comment already was the complete answer.
是的,您可以使用全局内存代替本地内存,但是:
Yes, you can use global memory as a replacement for local memory but:
- 您必须为所有工作组分配足够的全局内存,并为工作组分配其内存块(由于具有本地内存,因此您只需要指定单个工作组所需的内存,每个工作组将分配指定的内存)
- 您必须使用CLK_GLOBAL_MEM_FENCE而不是CLK_LOCAL_MEM_FENCE
- 您将失去大量的表现
如果我今晚有时间,我将举一个简单的例子.
If I have time this evening, I will post a simple example.
这篇关于opencl-并行还原,无需本地内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文