2015-12-04 14:47:52 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2015-12-04 14:47:52 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-05-25 21:04:26 +00:00
|
|
|
#include "inc_vendor.cl"
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#define CHARSIZ 256
|
|
|
|
|
2016-05-25 21:04:26 +00:00
|
|
|
#include "inc_types.cl"
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2019-03-09 08:05:44 +00:00
|
|
|
DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val);
|
2018-07-22 09:47:42 +00:00
|
|
|
DECLSPEC void generate_pw (u32 *pw_buf, __global const cs_t *root_css_buf, __global const cs_t *markov_css_buf, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, u64 val)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2016-11-22 19:20:34 +00:00
|
|
|
__global const cs_t *cs = &root_css_buf[pw_r_len];
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
u32 i;
|
|
|
|
u32 j;
|
|
|
|
|
|
|
|
for (i = 0, j = pw_r_len; i < pw_l_len; i++, j++)
|
|
|
|
{
|
|
|
|
const u32 len = cs->cs_len;
|
|
|
|
|
|
|
|
const u64 next = val / len;
|
|
|
|
const u64 pos = val % len;
|
|
|
|
|
|
|
|
val = next;
|
|
|
|
|
|
|
|
const u32 key = cs->cs_buf[pos];
|
|
|
|
|
|
|
|
const u32 jd4 = j / 4;
|
|
|
|
const u32 jm4 = j % 4;
|
|
|
|
|
2015-12-15 11:04:22 +00:00
|
|
|
pw_buf[jd4] |= key << ((3 - jm4) * 8);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
cs = &markov_css_buf[(j * CHARSIZ) + key];
|
|
|
|
}
|
|
|
|
|
|
|
|
const u32 jd4 = j / 4;
|
|
|
|
const u32 jm4 = j % 4;
|
|
|
|
|
2015-12-15 11:04:22 +00:00
|
|
|
pw_buf[jd4] |= (0xff << ((3 - jm4) * 8)) & mask80;
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (bits14) pw_buf[14] = (pw_l_len + pw_r_len) * 8;
|
|
|
|
if (bits15) pw_buf[15] = (pw_l_len + pw_r_len) * 8;
|
|
|
|
}
|
|
|
|
|
2018-11-21 12:00:30 +00:00
|
|
|
__kernel void l_markov (__global pw_t * restrict pws_buf_l, __global const cs_t * restrict root_css_buf, __global const cs_t * restrict markov_css_buf, const u64 off, const u32 pw_l_len, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
u32 pw_buf[64] = { 0 };
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_l_len, pw_r_len, mask80, bits14, bits15, off + gid);
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
#pragma unroll
|
|
|
|
for (int idx = 0; idx < 64; idx++)
|
|
|
|
{
|
|
|
|
pws_buf_l[gid].i[idx] = pw_buf[idx];
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
pws_buf_l[gid].pw_len = pw_l_len + pw_r_len;
|
|
|
|
}
|
|
|
|
|
2018-11-21 12:00:30 +00:00
|
|
|
__kernel void r_markov (__global bf_t * restrict pws_buf_r, __global const cs_t * restrict root_css_buf, __global const cs_t * restrict markov_css_buf, const u64 off, const u32 pw_r_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
u32 pw_buf[64] = { 0 };
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_r_len, 0, 0, 0, 0, off + gid);
|
|
|
|
|
|
|
|
pws_buf_r[gid].i = pw_buf[0];
|
|
|
|
}
|
|
|
|
|
2018-11-21 12:00:30 +00:00
|
|
|
__kernel void C_markov (__global pw_t * restrict pws_buf, __global const cs_t * restrict root_css_buf, __global const cs_t * restrict markov_css_buf, const u64 off, const u32 pw_len, const u32 mask80, const u32 bits14, const u32 bits15, const u64 gid_max)
|
2015-12-04 14:47:52 +00:00
|
|
|
{
|
2017-08-19 14:39:22 +00:00
|
|
|
const u64 gid = get_global_id (0);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
if (gid >= gid_max) return;
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
u32 pw_buf[64] = { 0 };
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
generate_pw (pw_buf, root_css_buf, markov_css_buf, pw_len, 0, mask80, bits14, bits15, off + gid);
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
#pragma unroll
|
|
|
|
for (int idx = 0; idx < 64; idx++)
|
|
|
|
{
|
|
|
|
pws_buf[gid].i[idx] = pw_buf[idx];
|
|
|
|
}
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
pws_buf[gid].pw_len = pw_len;
|
|
|
|
}
|