OpenCL是否允许并发写入相同的内存地址? [英] Does OpenCL allow concurrent writes to same memory address?

查看:357
本文介绍了OpenCL是否允许并发写入相同的内存地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否允许两个(或多个)不同的线程写入OpenCL中全局空间中的相同内存位置?写操作总是将uchar从0改为1,所以结果应该是可预测的,但是在我的程序中我得到不稳定的结果,所以我想知道是否原因可能是一些写失败。

Is two (or more) different threads allowed to write to the same memory location in global space in OpenCL? The write is always changing a uchar from 0 to 1 so the outcome should be predictable, but I'm getting erratic results in my program, so I'm wondering if the reason can be that some of the writes fail.

它可以帮助声明缓冲区只写,然后复制到只读缓冲区?

Could it help to declare the buffer write-only and copy it to a read-only buffer afterwards?

推荐答案

您是否尝试使用 cl_khr_global_int32_base_atomics 扩展和 atom_inc 内在函数?我首先将数据存储在 int32 而不是 uchar 作为概念验证,然后优化内存占用数据结构。

Did you try to use the cl_khr_global_int32_base_atomics extension and atom_inc intrinsic function? I would first store the data on an int32 instead of an uchar as proof of concept, then optimize the memory footprint of data structures.

这篇关于OpenCL是否允许并发写入相同的内存地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆