This commit is contained in:
Jay D Dee
2022-05-27 18:12:30 -04:00
parent db76d3865f
commit 26b8927632
20 changed files with 1600 additions and 256 deletions

View File

@@ -26,6 +26,7 @@ typedef struct {
} allium_16way_ctx_holder;
static __thread allium_16way_ctx_holder allium_16way_ctx;
static __thread __m512i blake256_16way_midstate[16];
bool init_allium_16way_ctx()
{
@@ -58,8 +59,9 @@ void allium_16way_hash( void *state, const void *input )
allium_16way_ctx_holder ctx __attribute__ ((aligned (64)));
memcpy( &ctx, &allium_16way_ctx, sizeof(allium_16way_ctx) );
blake256_16way_update( &ctx.blake, input + (64<<4), 16 );
blake256_16way_close( &ctx.blake, vhash );
ctx.blake.buf[3] = casti_m512i( input, 19 ); // grab nonce from input
blake256_16way_final_rounds_le( vhash, blake256_16way_midstate, ctx.blake.H,
ctx.blake.buf );
dintrlv_16x32( hash0, hash1, hash2, hash3, hash4, hash5, hash6, hash7,
hash8, hash9, hash10, hash11, hash12, hash13, hash14, hash15,
@@ -198,6 +200,7 @@ void allium_16way_hash( void *state, const void *input )
groestl256_full( &ctx.groestl, state+416, hash13, 256 );
groestl256_full( &ctx.groestl, state+448, hash14, 256 );
groestl256_full( &ctx.groestl, state+480, hash15, 256 );
#endif
}
@@ -214,15 +217,29 @@ int scanhash_allium_16way( struct work *work, uint32_t max_nonce,
__m512i *noncev = (__m512i*)vdata + 19; // aligned
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
const __m512i sixteen = m512_const1_32( 16 );
if ( bench ) ( (uint32_t*)ptarget )[7] = 0x0000ff;
mm512_bswap32_intrlv80_16x32( vdata, pdata );
for ( int i = 0; i < 19; i++ )
casti_m512i( vdata, i ) = _mm512_set1_epi32( pdata[i] );
*noncev = _mm512_set_epi32( n+15, n+14, n+13, n+12, n+11, n+10, n+ 9, n+ 8,
n+ 7, n+ 6, n+ 5, n+ 4, n+ 3, n+ 2, n +1, n );
// Prehash first block
blake256_16way_init( &allium_16way_ctx.blake );
blake256_16way_update( &allium_16way_ctx.blake, vdata, 64 );
blake256_16way_update_le( &allium_16way_ctx.blake, vdata, 64 );
// Prehash second block, fill buf with last 16 bytes and add padding.
memcpy_512( allium_16way_ctx.blake.buf, (__m512i*)vdata + 16, 4 );
allium_16way_ctx.blake.buf[ 4] = m512_const1_32( 0x80000000 );
memset_zero_512( allium_16way_ctx.blake.buf + 5, 8 );
allium_16way_ctx.blake.buf[13] = m512_one_32;
allium_16way_ctx.blake.buf[14] = m512_zero;
allium_16way_ctx.blake.buf[15] = m512_const1_32( 80*8 );
blake256_16way_round0_prehash_le( blake256_16way_midstate,
allium_16way_ctx.blake.H, allium_16way_ctx.blake.buf );
do {
allium_16way_hash( hash, vdata );
@@ -230,10 +247,10 @@ int scanhash_allium_16way( struct work *work, uint32_t max_nonce,
for ( int lane = 0; lane < 16; lane++ )
if ( unlikely( valid_hash( hash+(lane<<3), ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n + lane );
submit_solution( work, hash+(lane<<3), mythr );
pdata[19] = n + lane;
submit_solution( work, hash+(lane<<3), mythr );
}
*noncev = _mm512_add_epi32( *noncev, m512_const1_32( 16 ) );
*noncev = _mm512_add_epi32( *noncev, sixteen );
n += 16;
} while ( likely( (n < last_nonce) && !work_restart[thr_id].restart) );
pdata[19] = n;
@@ -256,6 +273,7 @@ typedef struct {
} allium_8way_ctx_holder;
static __thread allium_8way_ctx_holder allium_8way_ctx;
static __thread __m256i blake256_8way_midstate[16];
bool init_allium_8way_ctx()
{
@@ -279,8 +297,9 @@ void allium_8way_hash( void *hash, const void *input )
allium_8way_ctx_holder ctx __attribute__ ((aligned (64)));
memcpy( &ctx, &allium_8way_ctx, sizeof(allium_8way_ctx) );
blake256_8way_update( &ctx.blake, input + (64<<3), 16 );
blake256_8way_close( &ctx.blake, vhashA );
ctx.blake.buf[3] = casti_m256i( input, 19 ); // grab nonce from input
blake256_8way_final_rounds_le( vhashA, blake256_8way_midstate, ctx.blake.H,
ctx.blake.buf );
dintrlv_8x32( hash0, hash1, hash2, hash3, hash4, hash5, hash6, hash7,
vhashA, 256 );
@@ -386,11 +405,24 @@ int scanhash_allium_8way( struct work *work, uint32_t max_nonce,
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
mm256_bswap32_intrlv80_8x32( vdata, pdata );
for ( int i = 0; i < 19; i++ )
casti_m256i( vdata, i ) = _mm256_set1_epi32( pdata[i] );
*noncev = _mm256_set_epi32( n+7, n+6, n+5, n+4, n+3, n+2, n+1, n );
// Prehash first block
blake256_8way_init( &allium_8way_ctx.blake );
blake256_8way_update( &allium_8way_ctx.blake, vdata, 64 );
blake256_8way_update_le( &allium_8way_ctx.blake, vdata, 64 );
// Prehash second block, fill buf with last 16 bytes and add padding.
memcpy_256( allium_8way_ctx.blake.buf, (__m256i*)vdata + 16, 4 );
allium_8way_ctx.blake.buf[ 4] = m256_const1_32( 0x80000000 );
memset_zero_256( allium_8way_ctx.blake.buf + 5, 8 );
allium_8way_ctx.blake.buf[13] = m256_one_32;
allium_8way_ctx.blake.buf[14] = m256_zero;
allium_8way_ctx.blake.buf[15] = m256_const1_32( 80*8 );
blake256_8way_round0_prehash_le( blake256_8way_midstate,
allium_8way_ctx.blake.H, allium_8way_ctx.blake.buf );
do {
allium_8way_hash( hash, vdata );
@@ -400,7 +432,7 @@ int scanhash_allium_8way( struct work *work, uint32_t max_nonce,
const uint64_t *lane_hash = hash + (lane<<2);
if ( unlikely( valid_hash( lane_hash, ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n + lane );
pdata[19] = n + lane;
submit_solution( work, lane_hash, mythr );
}
}