]> zoso.dev Git - nano-pow.git/commitdiff
Found the culprit. Atomic exchange is actually 40ms slower than atomic load, so rever...
authorChris Duncan <chris@zoso.dev>
Wed, 5 Feb 2025 14:18:33 +0000 (06:18 -0800)
committerChris Duncan <chris@zoso.dev>
Wed, 5 Feb 2025 14:18:33 +0000 (06:18 -0800)
src/shaders/compute.wgsl

index 6f2a29a21e12693d1b58db24a74a78c3b0076d27..d6d01f1fbcce27a1e8765e1c3c141ebcd082f050 100644 (file)
@@ -1456,7 +1456,8 @@ fn main(id: vec3<u32>) {
        * Set nonce if it passes the threshold and no other thread has set it.
        * Only high bits are needed for comparison since threshold low bits are zero.
        */
-       if ((BLAKE2B_IV_0.y ^ v0.y ^ v8.y) >= ubo.threshold && atomicExchange(&work.found, 1u) == 0u) {
+       if ((BLAKE2B_IV32_1 ^ v0.y ^ v8.y) > threshold && atomicLoad(&work.found) == 0u) {
+               atomicStore(&work.found, 1u);
                work.nonce = m0;
        }
        return;