admin管理员组文章数量:1391991
I have a compute shader in Vulkan, where I launch N threads with eight sub-threads each. Each subgroup of 8 threads share an eight element 'location' array. Each of the sub-threads calculate a number from 1 to 8 where there can be duplicates.The sub threads do no need to be ordered.
A sub-thread only needs to do work if it has calculated a number which is not a duplicate. So, each thread must read the location array to see if its number has already been processed. If its number is not in the array then it writes its number to the array and does work. Another thread comes along with the same number, reads the array, and sees that its number has been processed, and so does nothing.
I need the 'location' array to be shared and thread safe.
I tried to use subgroups to do this but it is not clear how the subgroup threads share writable data. Can I use broadcast? If so any ideas how? I've tried atomics and memory barriers without success.
本文标签: multithreadingComputer shader data sharing among threads Stack Overflow
版权声明:本文标题:multithreading - Computer shader data sharing among threads, - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744774809a2624560.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论