diff --git a/OpenCL/m10800_a0.cl b/OpenCL/m10800_a0.cl index be11ffcd9..7bda95c9f 100644 --- a/OpenCL/m10800_a0.cl +++ b/OpenCL/m10800_a0.cl @@ -5,6 +5,8 @@ #define _SHA384_ +#define NEW_SIMD_CODE + #include "include/constants.h" #include "include/kernel_vendor.h" @@ -18,9 +20,7 @@ #include "OpenCL/common.c" #include "include/rp_kernel.h" #include "OpenCL/rp.c" - -#define COMPARE_S "OpenCL/check_single_comp4.c" -#define COMPARE_M "OpenCL/check_multi_comp4.c" +#include "OpenCL/simd.c" __constant u64 k_sha384[80] = { @@ -46,33 +46,33 @@ __constant u64 k_sha384[80] = SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f, }; -static void sha384_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u64 digest[8]) +static void sha384_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u64x digest[8]) { - u64 w0_t = hl32_to_64 (w0[0], w0[1]); - u64 w1_t = hl32_to_64 (w0[2], w0[3]); - u64 w2_t = hl32_to_64 (w1[0], w1[1]); - u64 w3_t = hl32_to_64 (w1[2], w1[3]); - u64 w4_t = hl32_to_64 (w2[0], w2[1]); - u64 w5_t = hl32_to_64 (w2[2], w2[3]); - u64 w6_t = hl32_to_64 (w3[0], w3[1]); - u64 w7_t = 0; - u64 w8_t = 0; - u64 w9_t = 0; - u64 wa_t = 0; - u64 wb_t = 0; - u64 wc_t = 0; - u64 wd_t = 0; - u64 we_t = 0; - u64 wf_t = hl32_to_64 (w3[2], w3[3]); + u64x w0_t = hl32_to_64 (w0[0], w0[1]); + u64x w1_t = hl32_to_64 (w0[2], w0[3]); + u64x w2_t = hl32_to_64 (w1[0], w1[1]); + u64x w3_t = hl32_to_64 (w1[2], w1[3]); + u64x w4_t = hl32_to_64 (w2[0], w2[1]); + u64x w5_t = hl32_to_64 (w2[2], w2[3]); + u64x w6_t = hl32_to_64 (w3[0], w3[1]); + u64x w7_t = 0; + u64x w8_t = 0; + u64x w9_t = 0; + u64x wa_t = 0; + u64x wb_t = 0; + u64x wc_t = 0; + u64x wd_t = 0; + u64x we_t = 0; + u64x wf_t = hl32_to_64 (w3[2], w3[3]); - u64 a = digest[0]; - u64 b = digest[1]; - u64 c = digest[2]; - u64 d = digest[3]; - u64 e = digest[4]; - u64 f = digest[5]; - u64 g = digest[6]; - u64 h = digest[7]; + u64x a = digest[0]; + u64x b = digest[1]; + u64x c = digest[2]; + u64x d = digest[3]; + u64x e = digest[4]; + u64x f = digest[5]; + u64x g = digest[6]; + u64x h = digest[7]; #define ROUND_EXPAND() \ { \ @@ -178,37 +178,14 @@ __kernel void m10800_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, * loop */ - for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE) { - u32 w0[4]; + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; - w0[0] = pw_buf0[0]; - w0[1] = pw_buf0[1]; - w0[2] = pw_buf0[2]; - w0[3] = pw_buf0[3]; - - u32 w1[4]; - - w1[0] = pw_buf1[0]; - w1[1] = pw_buf1[1]; - w1[2] = pw_buf1[2]; - w1[3] = pw_buf1[3]; - - u32 w2[4]; - - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - - u32 w3[4]; - - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len); + const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); append_0x80_2x4 (w0, w1, out_len); @@ -216,10 +193,10 @@ __kernel void m10800_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, * SHA384 */ - u32 w0_t[4]; - u32 w1_t[4]; - u32 w2_t[4]; - u32 w3_t[4]; + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; w0_t[0] = swap32 (w0[0]); w0_t[1] = swap32 (w0[1]); @@ -238,7 +215,7 @@ __kernel void m10800_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, w3_t[2] = 0; w3_t[3] = out_len * 8; - u64 digest[8]; + u64x digest[8]; digest[0] = SHA384M_A; digest[1] = SHA384M_B; @@ -251,12 +228,12 @@ __kernel void m10800_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, sha384_transform (w0_t, w1_t, w2_t, w3_t, digest); - const u32 r0 = l32_from_64 (digest[3]); - const u32 r1 = h32_from_64 (digest[3]); - const u32 r2 = l32_from_64 (digest[2]); - const u32 r3 = h32_from_64 (digest[2]); + const u32x r0 = l32_from_64 (digest[3]); + const u32x r1 = h32_from_64 (digest[3]); + const u32x r2 = l32_from_64 (digest[2]); + const u32x r3 = h32_from_64 (digest[2]); - #include COMPARE_M + COMPARE_M_SIMD (r0, r1, r2, r3); } } @@ -316,37 +293,14 @@ __kernel void m10800_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, * loop */ - for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE) { - u32 w0[4]; + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; - w0[0] = pw_buf0[0]; - w0[1] = pw_buf0[1]; - w0[2] = pw_buf0[2]; - w0[3] = pw_buf0[3]; - - u32 w1[4]; - - w1[0] = pw_buf1[0]; - w1[1] = pw_buf1[1]; - w1[2] = pw_buf1[2]; - w1[3] = pw_buf1[3]; - - u32 w2[4]; - - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - - u32 w3[4]; - - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len); + const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); append_0x80_2x4 (w0, w1, out_len); @@ -354,10 +308,10 @@ __kernel void m10800_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, * SHA384 */ - u32 w0_t[4]; - u32 w1_t[4]; - u32 w2_t[4]; - u32 w3_t[4]; + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; w0_t[0] = swap32 (w0[0]); w0_t[1] = swap32 (w0[1]); @@ -376,7 +330,7 @@ __kernel void m10800_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, w3_t[2] = 0; w3_t[3] = out_len * 8; - u64 digest[8]; + u64x digest[8]; digest[0] = SHA384M_A; digest[1] = SHA384M_B; @@ -389,12 +343,12 @@ __kernel void m10800_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, sha384_transform (w0_t, w1_t, w2_t, w3_t, digest); - const u32 r0 = l32_from_64 (digest[3]); - const u32 r1 = h32_from_64 (digest[3]); - const u32 r2 = l32_from_64 (digest[2]); - const u32 r3 = h32_from_64 (digest[2]); + const u32x r0 = l32_from_64 (digest[3]); + const u32x r1 = h32_from_64 (digest[3]); + const u32x r2 = l32_from_64 (digest[2]); + const u32x r3 = h32_from_64 (digest[2]); - #include COMPARE_S + COMPARE_S_SIMD (r0, r1, r2, r3); } }