From: Chris Duncan Date: Tue, 14 Jan 2025 06:04:36 +0000 (-0800) Subject: Stage final fully reduced u64 addition operation using vectors. This will be the... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=9c790daed644acfe9f9d1eb43852c91cf96b4ef1;p=nano-pow.git Stage final fully reduced u64 addition operation using vectors. This will be the technique going forward; the assignments to individual scalars after the vector sum are purely placeholders until the entire algorithm can be converted. --- diff --git a/src/shaders/compute.wgsl b/src/shaders/compute.wgsl index 16f2af1..17cfdd6 100644 --- a/src/shaders/compute.wgsl +++ b/src/shaders/compute.wgsl @@ -57,6 +57,10 @@ fn main(@builtin(global_invocation_id) id: vec3) { * v[28u] = ~v[28u]; * v[29u] = ~v[29u]; */ + var v_01: vec2 = vec2(0xF2BDC900u, 0x6A09E667u); + var v_23: vec2 = vec2(0x84CAA73Bu, 0xBB67AE85u); + var v_89: vec2 = vec2(0xADE682D1u, 0x510E527Fu); + var v_1011: vec2 = vec2(0x2B3E6C1Fu, 0x9B05688Cu); var v0: u32 = 0xF2BDC900u; var v1: u32 = 0x6A09E667u; var v2: u32 = 0x84CAA73Bu; @@ -114,9 +118,14 @@ fn main(@builtin(global_invocation_id) id: vec3) { */ // a = a + b - v1 = v1 + v9; - v1 = v1 + select(0u, 1u, v0 + v8 < v0); - v0 = v0 + v8; + // v1 = v1 + v9 + select(0u, 1u, v0 + v8 < v0); + // v0 = v0 + v8; + v_01 = v_01 + v_89 + select(vec2(0u), vec2(0u, 1u), v_01.x + v_89.x < v_01.x); + v0 = v_01.x; + v1 = v_01.y; + v8 = v_89.x; + v9 = v_89.y; + // a = a + m[sigma[r][2*i+0]] o0 = v0 + m0; @@ -184,11 +193,18 @@ fn main(@builtin(global_invocation_id) id: vec3) { */ // a = a + b - o0 = v2 + v10; - o1 = v3 + v11; - o1 = o1 + select(0u, 1u, o0 < v2); - v2 = o0; - v3 = o1; + v_23 = v_23 + v_1011 + select(vec2(0u), vec2(0u, 1u), v_23.x + v_1011.x < v_23.x); + v2 = v_23.x; + v3 = v_23.y; + v10 = v_1011.x; + v11 = v_1011.y; + + // o0 = v2 + v10; + // o1 = v3 + v11; + // o1 = o1 + select(0u, 1u, o0 < v2); + // v2 = o0; + // v3 = o1; + // a = a + m[sigma[r][2*i+0]] o0 = v2 + m4;