diff --git a/OpenCL/m01730_a0.cl b/OpenCL/m01730_a0.cl index fa28e6205..c46401604 100644 --- a/OpenCL/m01730_a0.cl +++ b/OpenCL/m01730_a0.cl @@ -5,6 +5,8 @@ #define _SHA512_ +#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_sha512[80] = { @@ -46,33 +46,33 @@ __constant u64 k_sha512[80] = SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f, }; -static void sha512_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u64 digest[8]) +static void sha512_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() \ { \ @@ -199,64 +199,41 @@ __kernel void m01730_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 salt */ - u32 s0[4]; + u32x s0[4]; s0[0] = salt_buf0[0]; s0[1] = salt_buf0[1]; s0[2] = salt_buf0[2]; s0[3] = salt_buf0[3]; - u32 s1[4]; + u32x s1[4]; s1[0] = salt_buf1[0]; s1[1] = salt_buf1[1]; s1[2] = salt_buf1[2]; s1[3] = salt_buf1[3]; - u32 s2[4]; + u32x s2[4]; s2[0] = 0; s2[1] = 0; s2[2] = 0; s2[3] = 0; - u32 s3[4]; + u32x s3[4]; s3[0] = 0; s3[1] = 0; @@ -267,10 +244,10 @@ __kernel void m01730_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, const u32 out_salt_len = (out_len * 2) + salt_len; - 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]; make_unicode (w0, w0_t, w1_t); make_unicode (w1, w2_t, w3_t); @@ -315,7 +292,7 @@ __kernel void m01730_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, w3_t[2] = 0; w3_t[3] = out_salt_len * 8; - u64 digest[8]; + u64x digest[8]; digest[0] = SHA512M_A; digest[1] = SHA512M_B; @@ -328,13 +305,12 @@ __kernel void m01730_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, sha512_transform (w0_t, w1_t, w2_t, w3_t, digest); + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); - const u32 r0 = l32_from_64 (digest[7]); - const u32 r1 = h32_from_64 (digest[7]); - const u32 r2 = l32_from_64 (digest[3]); - const u32 r3 = h32_from_64 (digest[3]); - - #include COMPARE_M + COMPARE_M_SIMD (r0, r1, r2, r3); } } @@ -414,64 +390,41 @@ __kernel void m01730_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 salt */ - u32 s0[4]; + u32x s0[4]; s0[0] = salt_buf0[0]; s0[1] = salt_buf0[1]; s0[2] = salt_buf0[2]; s0[3] = salt_buf0[3]; - u32 s1[4]; + u32x s1[4]; s1[0] = salt_buf1[0]; s1[1] = salt_buf1[1]; s1[2] = salt_buf1[2]; s1[3] = salt_buf1[3]; - u32 s2[4]; + u32x s2[4]; s2[0] = 0; s2[1] = 0; s2[2] = 0; s2[3] = 0; - u32 s3[4]; + u32x s3[4]; s3[0] = 0; s3[1] = 0; @@ -482,10 +435,10 @@ __kernel void m01730_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, const u32 out_salt_len = (out_len * 2) + salt_len; - 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]; make_unicode (w0, w0_t, w1_t); make_unicode (w1, w2_t, w3_t); @@ -530,7 +483,7 @@ __kernel void m01730_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, w3_t[2] = 0; w3_t[3] = out_salt_len * 8; - u64 digest[8]; + u64x digest[8]; digest[0] = SHA512M_A; digest[1] = SHA512M_B; @@ -543,13 +496,12 @@ __kernel void m01730_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, sha512_transform (w0_t, w1_t, w2_t, w3_t, digest); + const u32x r0 = l32_from_64 (digest[7]); + const u32x r1 = h32_from_64 (digest[7]); + const u32x r2 = l32_from_64 (digest[3]); + const u32x r3 = h32_from_64 (digest[3]); - const u32 r0 = l32_from_64 (digest[7]); - const u32 r1 = h32_from_64 (digest[7]); - const u32 r2 = l32_from_64 (digest[3]); - const u32 r3 = h32_from_64 (digest[3]); - - #include COMPARE_S + COMPARE_S_SIMD (r0, r1, r2, r3); } }