]> zoso.dev Git - libnemo.git/commitdiff
Shortcut conditional by validating nonce prior to loading atomic. Remove redundant...
authorChris Duncan <chris@zoso.dev>
Sun, 5 Jan 2025 09:24:15 +0000 (01:24 -0800)
committerChris Duncan <chris@zoso.dev>
Sun, 5 Jan 2025 09:24:15 +0000 (01:24 -0800)
src/lib/workers/powgpu.ts

index 431f1ebf0508e5e697418854c9d78cc792d03363..707fcab43e120e0f414a2b0af8abff2cb9f8a6d9 100644 (file)
@@ -214,11 +214,10 @@ export class PowGpu extends WorkerInterface {
                        /**
                        * Set nonce if it passes the threshold and no other thread has set it
                        */
-                       if (atomicLoad(&work.found) == 0u && (BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold) {
+                       if (BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold && atomicStore(&work.found) == 0u) {
                                atomicStore(&work.found, 1u);
                                work.nonce.x = m[0];
                                work.nonce.y = m[1];
-                               return;
                        }
                        return;
                }