Skip to content
Discussion options

You must be logged in to vote

So there's actually a couple problems here. It's actually impossible to write a working mutex in wgsl for two reasons:

  • Atomics in wgsl have "Relaxed" memory semantics. This means that the visibility of atomic operations say nothing about the values of the rest of memory. In this case, there is no guarentee that ctr++ will actually do what you intend it to, and may end up reading stale values as there's nothing here forcing the caches to be flushed and memory to be visible to other threads. I think you're seeing a consistent value as it's a single workgroup (which share L1$) doing the addition. Split this across multiple workgroups with multiple L1$, and the output value will likely be ga…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@suguruwataru
Comment options

@suguruwataru
Comment options

Answer selected by suguruwataru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants