]> zoso.dev Git - libnemo.git/commitdiff
Remove extraneous commenting. Move XOR to start of for loop. Whitespace.
authorChris Duncan <chris@zoso.dev>
Sun, 5 Jan 2025 07:10:13 +0000 (23:10 -0800)
committerChris Duncan <chris@zoso.dev>
Sun, 5 Jan 2025 07:10:13 +0000 (23:10 -0800)
src/lib/workers/powgpu.ts

index e9e5901800b74f9cb99e0c9a5bcc09620d7c8fce..7c5b826b32365b53eb907db01bbe4211eed042ce 100644 (file)
@@ -150,9 +150,7 @@ export class PowGpu extends WorkerInterface {
                        @builtin(workgroup_id) workgroup_id: vec3<u32>,
                        @builtin(local_invocation_id) local_id: vec3<u32>
                ) {
-                       if (atomicLoad(&work.found) != 0u) {
-                               return;
-                       }
+                       if (atomicLoad(&work.found) != 0u) { return; }
 
                        /**
                        * Flatten 3D workgroup and local identifiers into u32 for each thread
@@ -199,9 +197,10 @@ export class PowGpu extends WorkerInterface {
                                0x04BE4294u, 0xE07C2654u, 0x137E2179u, 0x5BE0CD19u
                        );
 
-                       for (var i: u32 = 0u; i < 0xFFFFu; i = i + 1u) {
+                       for (var i: u32 = 0u; i < 0xFFu; i = i << 1u) {
+                               m[0u] = m[0u] ^ i;
                                /**
-                               * Twelve rounds of mixing as part of compression step
+                               * Twelve rounds of mixing as part of BLAKE2b compression step
                                */
                                for (var r: u32 = 0u; r < 12u; r = r + 1u) {
                                        G(&v, &m, 0u, 8u, 16u, 24u, SIGMA82[r * 16u + 0u], SIGMA82[r * 16u + 1u]);
@@ -223,17 +222,10 @@ export class PowGpu extends WorkerInterface {
                                        work.nonce.y = m[1];
                                        return;
                                }
-
-                               /**
-                               * If not found, move on to the next nonce candidate.
-                               * For example, increment by the total number of *active* threads,
-                               * or simply increment by 1.
-                               */
-                               m[0u] = m[0u] + 1u;
                        }
-
-                       // No valid nonce found by this thread in 'maxIterations' attempts
-                       // Exit. Another dispatch or CPU fallback might handle continuing.
+                       /**
+                       * Nonce not found in this execution context
+                       */
                        return;
                }
        `;