Does OpenCL allow concurrent writes to same memory address?

强颜欢笑 提交于 2019-12-24 00:49:38

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2861401/does-opencl-allow-concurrent-writes-to-same-memory-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!