最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multithreading - Computer shader data sharing among threads, - Stack Overflow

programmeradmin15浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论