) {
if (atomicLoad(&work.found) != 0u) { return; }
+ let threshold: u32 = ubo.threshold;
+
/**
* Flatten 3D workgroup and local identifiers into u32 for each thread
*/
/**
* Set nonce if it passes the threshold and no other thread has set it
*/
- if ((BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > ubo.threshold && atomicLoad(&work.found) == 0u) {
+ if ((BLAKE2B_IV32_1 ^ v[1u] ^ v[17u]) > threshold && atomicLoad(&work.found) == 0u) {
atomicStore(&work.found, 1u);
work.nonce.x = m[0];
work.nonce.y = m[1];
PowGpu.#device.queue.submit([commandEncoder.finish()])
// Read results back to Javascript and then unmap buffer after reading
+ const start = performance.now()
await PowGpu.#cpuBuffer.mapAsync(GPUMapMode.READ)
await PowGpu.#device.queue.onSubmittedWorkDone()
+ console.log(`mapAsync and onSubmittedWorkDone (${performance.now() - start} ms)`)
const data = new DataView(PowGpu.#cpuBuffer.getMappedRange())
const nonce = data.getBigUint64(0, true)
const found = !!data.getUint32(8)