From: Chris Duncan Date: Thu, 16 Jan 2025 15:21:38 +0000 (-0800) Subject: Some final steps are unnecessary since we only use v0 and v8 in the threshold compari... X-Git-Tag: v2.0.0~44 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d978f7634d73541dffa751895ba11cc0ceb70a62;p=nano-pow.git Some final steps are unnecessary since we only use v0 and v8 in the threshold comparison, and any steps uninvolved with their final values can be discarded. --- diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index f4efcea..2da6c74 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -1551,21 +1551,12 @@ fn main(id: vec3) { // skip since adding 0u does nothing v13 = ((v13 ^ v2).xy >> ROTATE_16) | ((v13 ^ v2).yx << ROTATE_16); v8 = v8 + v13 + vec2(0u, u32(v8.x + v13.x < v8.x)); - v7 = ((v7 ^ v8).xy << ROTATE_1) | ((v7 ^ v8).yx >> ROTATE_31); + // skip since we already have the final values of `v0` and `v8` /** * r=11, i=7, a=v[3], b=v[4], c=v[9], d=v[14] */ - v3 = v3 + v4 + vec2(0u, u32(v3.x + v4.x < v3.x)); - // skip since adding 0u does nothing - v14 = v14.yx ^ v3.yx; - v9 = v9 + v14 + vec2(0u, u32(v9.x + v14.x < v9.x)); - v4 = ((v4 ^ v9).xy >> ROTATE_24) | ((v4 ^ v9).yx << ROTATE_8); - v3 = v3 + v4 + vec2(0u, u32(v3.x + v4.x < v3.x)); - v3 = v3 + m3 + vec2(0u, u32(v3.x + m3.x < v3.x)); - v14 = ((v14 ^ v3).xy >> ROTATE_16) | ((v14 ^ v3).yx << ROTATE_16); - v9 = v9 + v14 + vec2(0u, u32(v9.x + v14.x < v9.x)); - v4 = ((v4 ^ v9).xy << ROTATE_1) | ((v4 ^ v9).yx >> ROTATE_31); + // skip entire step since we already have the final values of `v0` and `v8` @@ -1576,7 +1567,7 @@ fn main(id: vec3) { ****************************************************************************/ /** - * Set m0 if it passes the threshold and no other thread has set it + * Set nonce if it passes the threshold and no other thread has set it */ if ((BLAKE2B_IV32_1 ^ v0.y ^ v8.y) > threshold && atomicLoad(&work.found) == 0u) { atomicStore(&work.found, 1u);