#define _GOST2012_256_
+#define NEW_SIMD_CODE
+
#include "include/constants.h"
#include "include/kernel_vendor.h"
#include "include/kernel_functions.c"
#include "OpenCL/types_ocl.c"
#include "OpenCL/common.c"
-
-#define COMPARE_S "OpenCL/check_single_comp4.c"
-#define COMPARE_M "OpenCL/check_multi_comp4.c"
+#include "OpenCL/simd.c"
#define INITVAL 0x0101010101010101
-#define SBOG_LPSti64 \
- s_sbob_sl64[0][(t[0] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[1][(t[1] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[2][(t[2] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[3][(t[3] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[4][(t[4] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[5][(t[5] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[6][(t[6] >> (i * 8)) & 0xff] ^ \
- s_sbob_sl64[7][(t[7] >> (i * 8)) & 0xff]
+#if VECT_SIZE == 1
+#define BOX(S,n,i) (S)[(n)][(i)]
+#elif VECT_SIZE == 2
+#define BOX(S,n,i) (u64x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1])
+#elif VECT_SIZE == 4
+#define BOX(S,n,i) (u64x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3])
+#elif VECT_SIZE == 8
+#define BOX(S,n,i) (u64x) ((S)[(n)][(i).s0], (S)[(n)][(i).s1], (S)[(n)][(i).s2], (S)[(n)][(i).s3], (S)[(n)][(i).s4], (S)[(n)][(i).s5], (S)[(n)][(i).s6], (S)[(n)][(i).s7])
+#endif
+
+#define SBOG_LPSti64 \
+ BOX (s_sbob_sl64, 0, ((t[0] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 1, ((t[1] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 2, ((t[2] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 3, ((t[3] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 4, ((t[4] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 5, ((t[5] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 6, ((t[6] >> (i * 8)) & 0xff)) ^ \
+ BOX (s_sbob_sl64, 7, ((t[7] >> (i * 8)) & 0xff))
// constants
},
};
-static void streebog_g (u64 h[8], const u64 m[8], __local u64 s_sbob_sl64[8][256])
+static void streebog_g (u64x h[8], const u64x m[8], __local u64 s_sbob_sl64[8][256])
{
- u64 k[8];
- u64 s[8];
- u64 t[8];
+ u64x k[8];
+ u64x s[8];
+ u64x t[8];
#pragma unroll
for (int i = 0; i < 8; i++)
u32 w0l = w[0];
- for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
+ for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos += VECT_SIZE)
{
- const u32 w0r = bfs_buf[il_pos].i;
+ const u32x w0r = w0r_create_bft (bfs_buf, il_pos);
- w[0] = w0l | w0r;
+ const u32x w0lr = w0l | w0r;
/**
* reverse message block
*/
- u64 m[8];
+ u64x m[8];
m[0] = hl32_to_64 (w[15], w[14]);
m[1] = hl32_to_64 (w[13], w[12]);
m[4] = hl32_to_64 (w[ 7], w[ 6]);
m[5] = hl32_to_64 (w[ 5], w[ 4]);
m[6] = hl32_to_64 (w[ 3], w[ 2]);
- m[7] = hl32_to_64 (w[ 1], w[ 0]);
+ m[7] = hl32_to_64 (w[ 1], w0lr );
m[0] = swap64 (m[0]);
m[1] = swap64 (m[1]);
// state buffer (hash)
- u64 h[8];
+ u64x h[8];
h[0] = INITVAL;
h[1] = INITVAL;
streebog_g (h, m, s_sbob_sl64);
- u64 z[8];
+ u64x z[8];
z[0] = 0;
z[1] = 0;
streebog_g (h, z, s_sbob_sl64);
streebog_g (h, m, s_sbob_sl64);
- const u32 r0 = l32_from_64 (h[0]);
- const u32 r1 = h32_from_64 (h[0]);
- const u32 r2 = l32_from_64 (h[1]);
- const u32 r3 = h32_from_64 (h[1]);
+ const u32x r0 = l32_from_64 (h[0]);
+ const u32x r1 = h32_from_64 (h[0]);
+ const u32x r2 = l32_from_64 (h[1]);
+ const u32x r3 = h32_from_64 (h[1]);
- #include COMPARE_M
+ COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
u32 w0l = w[0];
- for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
+ for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos += VECT_SIZE)
{
- const u32 w0r = bfs_buf[il_pos].i;
+ const u32x w0r = w0r_create_bft (bfs_buf, il_pos);
- w[0] = w0l | w0r;
+ const u32x w0lr = w0l | w0r;
/**
* reverse message block
*/
- u64 m[8];
+ u64x m[8];
m[0] = hl32_to_64 (w[15], w[14]);
m[1] = hl32_to_64 (w[13], w[12]);
m[4] = hl32_to_64 (w[ 7], w[ 6]);
m[5] = hl32_to_64 (w[ 5], w[ 4]);
m[6] = hl32_to_64 (w[ 3], w[ 2]);
- m[7] = hl32_to_64 (w[ 1], w[ 0]);
+ m[7] = hl32_to_64 (w[ 1], w0lr );
m[0] = swap64 (m[0]);
m[1] = swap64 (m[1]);
// state buffer (hash)
- u64 h[8];
+ u64x h[8];
h[0] = INITVAL;
h[1] = INITVAL;
streebog_g (h, m, s_sbob_sl64);
- u64 z[8];
+ u64x z[8];
z[0] = 0;
z[1] = 0;
streebog_g (h, z, s_sbob_sl64);
streebog_g (h, m, s_sbob_sl64);
- const u32 r0 = l32_from_64 (h[0]);
- const u32 r1 = h32_from_64 (h[0]);
- const u32 r2 = l32_from_64 (h[1]);
- const u32 r3 = h32_from_64 (h[1]);
+ const u32x r0 = l32_from_64 (h[0]);
+ const u32x r1 = h32_from_64 (h[0]);
+ const u32x r2 = l32_from_64 (h[1]);
+ const u32x r3 = h32_from_64 (h[1]);
- #include COMPARE_S
+ COMPARE_S_SIMD (r0, r1, r2, r3);
}
}