From 55b51488de9a71e4c948ce3f4480985b81b4d0af Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 6 Feb 2016 10:38:39 +0100 Subject: [PATCH] Converted to new SIMD: -m 6000 -a 0 --- OpenCL/m06000_a0.cl | 130 +++++++++++++------------------------------- 1 file changed, 37 insertions(+), 93 deletions(-) diff --git a/OpenCL/m06000_a0.cl b/OpenCL/m06000_a0.cl index 377c7d051..b623fce70 100644 --- a/OpenCL/m06000_a0.cl +++ b/OpenCL/m06000_a0.cl @@ -5,6 +5,8 @@ #define _RIPEMD160_ +#define NEW_SIMD_CODE + #include "include/constants.h" #include "include/kernel_vendor.h" @@ -18,17 +20,15 @@ #include "OpenCL/common.c" #include "include/rp_kernel.h" #include "OpenCL/rp.c" +#include "OpenCL/simd.c" -#define COMPARE_S "OpenCL/check_single_comp4.c" -#define COMPARE_M "OpenCL/check_multi_comp4.c" - -static void ripemd160_transform (const u32 w[16], u32 dgst[5]) +static void ripemd160_transform (const u32x w[16], u32x dgst[5]) { - u32 a1 = dgst[0]; - u32 b1 = dgst[1]; - u32 c1 = dgst[2]; - u32 d1 = dgst[3]; - u32 e1 = dgst[4]; + u32x a1 = dgst[0]; + u32x b1 = dgst[1]; + u32x c1 = dgst[2]; + u32x d1 = dgst[3]; + u32x e1 = dgst[4]; RIPEMD160_STEP (RIPEMD160_F , a1, b1, c1, d1, e1, w[ 0], RIPEMD160C00, RIPEMD160S00); RIPEMD160_STEP (RIPEMD160_F , e1, a1, b1, c1, d1, w[ 1], RIPEMD160C00, RIPEMD160S01); @@ -115,11 +115,11 @@ static void ripemd160_transform (const u32 w[16], u32 dgst[5]) RIPEMD160_STEP (RIPEMD160_J , c1, d1, e1, a1, b1, w[15], RIPEMD160C40, RIPEMD160S4E); RIPEMD160_STEP (RIPEMD160_J , b1, c1, d1, e1, a1, w[13], RIPEMD160C40, RIPEMD160S4F); - u32 a2 = dgst[0]; - u32 b2 = dgst[1]; - u32 c2 = dgst[2]; - u32 d2 = dgst[3]; - u32 e2 = dgst[4]; + u32x a2 = dgst[0]; + u32x b2 = dgst[1]; + u32x c2 = dgst[2]; + u32x d2 = dgst[3]; + u32x e2 = dgst[4]; RIPEMD160_STEP_WORKAROUND_BUG (RIPEMD160_J , a2, b2, c2, d2, e2, w[ 5], RIPEMD160C50, RIPEMD160S50); RIPEMD160_STEP (RIPEMD160_J , e2, a2, b2, c2, d2, w[14], RIPEMD160C50, RIPEMD160S51); @@ -206,11 +206,11 @@ static void ripemd160_transform (const u32 w[16], u32 dgst[5]) RIPEMD160_STEP (RIPEMD160_F , c2, d2, e2, a2, b2, w[ 9], RIPEMD160C90, RIPEMD160S9E); RIPEMD160_STEP (RIPEMD160_F , b2, c2, d2, e2, a2, w[11], RIPEMD160C90, RIPEMD160S9F); - const u32 a = dgst[1] + c1 + d2; - const u32 b = dgst[2] + d1 + e2; - const u32 c = dgst[3] + e1 + a2; - const u32 d = dgst[4] + a1 + b2; - const u32 e = dgst[0] + b1 + c2; + const u32x a = dgst[1] + c1 + d2; + const u32x b = dgst[2] + d1 + e2; + const u32x c = dgst[3] + e1 + a2; + const u32x d = dgst[4] + a1 + b2; + const u32x e = dgst[0] + b1 + c2; dgst[0] = a; dgst[1] = b; @@ -255,41 +255,18 @@ __kernel void m06000_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu * 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); - u32 wl[16]; + u32x wl[16]; wl[ 0] = w0[0]; wl[ 1] = w0[1]; @@ -308,7 +285,7 @@ __kernel void m06000_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu wl[14] = out_len * 8; wl[15] = 0; - u32 dgst[5]; + u32x dgst[5]; dgst[0] = RIPEMD160M_A; dgst[1] = RIPEMD160M_B; @@ -318,12 +295,7 @@ __kernel void m06000_m04 (__global pw_t *pws, __global kernel_rule_t * rules_bu ripemd160_transform (wl, dgst); - const u32 r0 = dgst[0]; - const u32 r1 = dgst[1]; - const u32 r2 = dgst[2]; - const u32 r3 = dgst[3]; - - #include COMPARE_M + COMPARE_M_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } } @@ -383,41 +355,18 @@ __kernel void m06000_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu * 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); - u32 wl[16]; + u32x wl[16]; wl[ 0] = w0[0]; wl[ 1] = w0[1]; @@ -436,7 +385,7 @@ __kernel void m06000_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu wl[14] = out_len * 8; wl[15] = 0; - u32 dgst[5]; + u32x dgst[5]; dgst[0] = RIPEMD160M_A; dgst[1] = RIPEMD160M_B; @@ -446,12 +395,7 @@ __kernel void m06000_s04 (__global pw_t *pws, __global kernel_rule_t * rules_bu ripemd160_transform (wl, dgst); - const u32 r0 = dgst[0]; - const u32 r1 = dgst[1]; - const u32 r2 = dgst[2]; - const u32 r3 = dgst[3]; - - #include COMPARE_S + COMPARE_S_SIMD (dgst[0], dgst[1], dgst[2], dgst[3]); } }