Converted _a3 kernels, use SIMD for CPU and GPU
[hashcat.git] / OpenCL / m05100_a3.cl
index fa2de71..4de1ac8 100644 (file)
@@ -5,6 +5,8 @@
 
 #define _MD5H_
 
+#define NEW_SIMD_CODE
+
 #include "include/constants.h"
 #include "include/kernel_vendor.h"
 
@@ -16,9 +18,7 @@
 #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"
 
 static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
 {
@@ -41,18 +41,18 @@ static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   u32 w0l = w0[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);
 
-    w0[0] = w0l | w0r;
+    const u32x w0lr = w0l | w0r;
 
-    u32 a = MD5M_A;
-    u32 b = MD5M_B;
-    u32 c = MD5M_C;
-    u32 d = MD5M_D;
+    u32x a = MD5M_A;
+    u32x b = MD5M_B;
+    u32x c = MD5M_C;
+    u32x d = MD5M_D;
 
-    MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
+    MD5_STEP (MD5_Fo, a, b, c, d, w0lr,  MD5C00, MD5S00);
     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
@@ -72,7 +72,7 @@ static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
-    MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
+    MD5_STEP (MD5_Go, b, c, d, a, w0lr,  MD5C13, MD5S13);
     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
@@ -95,7 +95,7 @@ static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
-    MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
+    MD5_STEP (MD5_H , d, a, b, c, w0lr,  MD5C29, MD5S21);
     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
@@ -103,7 +103,7 @@ static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
 
-    MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
+    MD5_STEP (MD5_I , a, b, c, d, w0lr,  MD5C30, MD5S30);
     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
@@ -125,32 +125,14 @@ static void m05100m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     c += MD5M_C;
     d += MD5M_D;
 
-    {
-      const u32 r0 = a;
-      const u32 r1 = b;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
-
-      #include COMPARE_M
-    }
+    u32x e = 0;
+    u32x f = 0;
 
-    {
-      const u32 r0 = b;
-      const u32 r1 = c;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
+    COMPARE_M_SIMD (a, b, e, f);
 
-      #include COMPARE_M
-    }
+    COMPARE_M_SIMD (b, c, e, f);
 
-    {
-      const u32 r0 = c;
-      const u32 r1 = d;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
-
-      #include COMPARE_M
-    }
+    COMPARE_M_SIMD (c, d, e, f);
   }
 }
 
@@ -187,18 +169,18 @@ static void m05100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
 
   u32 w0l = w0[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);
 
-    w0[0] = w0l | w0r;
+    const u32x w0lr = w0l | w0r;
 
-    u32 a = MD5M_A;
-    u32 b = MD5M_B;
-    u32 c = MD5M_C;
-    u32 d = MD5M_D;
+    u32x a = MD5M_A;
+    u32x b = MD5M_B;
+    u32x c = MD5M_C;
+    u32x d = MD5M_D;
 
-    MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
+    MD5_STEP (MD5_Fo, a, b, c, d, w0lr,  MD5C00, MD5S00);
     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
@@ -218,7 +200,7 @@ static void m05100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
-    MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
+    MD5_STEP (MD5_Go, b, c, d, a, w0lr,  MD5C13, MD5S13);
     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
@@ -241,7 +223,7 @@ static void m05100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
-    MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
+    MD5_STEP (MD5_H , d, a, b, c, w0lr,  MD5C29, MD5S21);
     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
@@ -249,7 +231,7 @@ static void m05100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
 
-    MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
+    MD5_STEP (MD5_I , a, b, c, d, w0lr,  MD5C30, MD5S30);
     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
@@ -271,32 +253,14 @@ static void m05100s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_le
     c += MD5M_C;
     d += MD5M_D;
 
-    {
-      const u32 r0 = a;
-      const u32 r1 = b;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
-
-      #include COMPARE_S
-    }
-
-    {
-      const u32 r0 = b;
-      const u32 r1 = c;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
+    u32x e = 0;
+    u32x f = 0;
 
-      #include COMPARE_S
-    }
+    COMPARE_S_SIMD (a, b, e, f);
 
-    {
-      const u32 r0 = c;
-      const u32 r1 = d;
-      const u32 r2 = 0;
-      const u32 r3 = 0;
+    COMPARE_S_SIMD (b, c, e, f);
 
-      #include COMPARE_S
-    }
+    COMPARE_S_SIMD (c, d, e, f);
   }
 }