From: Chris Duncan Date: Sun, 5 Jan 2025 08:43:12 +0000 (-0800) Subject: Revert nonce and found swap. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=a49f46d1ed61792b6b063a740f1cd65fba4549de;p=libnemo.git Revert nonce and found swap. --- diff --git a/src/lib/workers/powgpu.ts b/src/lib/workers/powgpu.ts index 920e090..431f1eb 100644 --- a/src/lib/workers/powgpu.ts +++ b/src/lib/workers/powgpu.ts @@ -53,8 +53,8 @@ export class PowGpu extends WorkerInterface { @group(0) @binding(0) var ubo: UBO; struct WORK { - found: atomic, - nonce: vec2 + nonce: vec2, + found: atomic }; @group(0) @binding(1) var work: WORK; @@ -220,10 +220,6 @@ export class PowGpu extends WorkerInterface { work.nonce.y = m[1]; return; } - - /** - * Nonce not found in this execution context - */ return; } `; @@ -326,7 +322,7 @@ export class PowGpu extends WorkerInterface { PowGpu.#device.queue.writeBuffer(PowGpu.#uboBuffer, 0, uboView) // Reset `found` flag to 0u in WORK before each calculation - PowGpu.#device.queue.writeBuffer(PowGpu.#gpuBuffer, 0, new Uint32Array([0])) + PowGpu.#device.queue.writeBuffer(PowGpu.#gpuBuffer, 8, new Uint32Array([0])) // Bind UBO read and GPU write buffers const bindGroup = PowGpu.#device.createBindGroup({ @@ -373,8 +369,8 @@ export class PowGpu extends WorkerInterface { await PowGpu.#cpuBuffer.mapAsync(GPUMapMode.READ) await PowGpu.#device.queue.onSubmittedWorkDone() const data = new DataView(PowGpu.#cpuBuffer.getMappedRange()) - const found = !!data.getUint32(0) - const nonce = data.getBigUint64(8, true) + const nonce = data.getBigUint64(0, true) + const found = !!data.getUint32(8) PowGpu.#cpuBuffer.unmap() if (found) {