mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.5.6
This commit is contained in:
@@ -7,11 +7,14 @@
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
#include "lyra2.h"
|
||||
#include "algo-gate-api.h"
|
||||
#include "avxdefs.h"
|
||||
|
||||
#ifndef NO_AES_NI
|
||||
#include "algo/groestl/aes_ni/hash-groestl256.h"
|
||||
#endif
|
||||
|
||||
//__thread uint64_t* lyra2re_wholeMatrix;
|
||||
|
||||
typedef struct {
|
||||
sph_blake256_context blake;
|
||||
sph_keccak256_context keccak;
|
||||
@@ -24,6 +27,7 @@ typedef struct {
|
||||
} lyra2re_ctx_holder;
|
||||
|
||||
lyra2re_ctx_holder lyra2re_ctx;
|
||||
static __thread sph_blake256_context lyra2_blake_mid;
|
||||
|
||||
void init_lyra2re_ctx()
|
||||
{
|
||||
@@ -37,6 +41,12 @@ void init_lyra2re_ctx()
|
||||
#endif
|
||||
}
|
||||
|
||||
void lyra2_blake256_midstate( const void* input )
|
||||
{
|
||||
memcpy( &lyra2_blake_mid, &lyra2re_ctx.blake, sizeof lyra2_blake_mid );
|
||||
sph_blake256( &lyra2_blake_mid, input, 64 );
|
||||
}
|
||||
|
||||
void lyra2re_hash(void *state, const void *input)
|
||||
{
|
||||
lyra2re_ctx_holder ctx;
|
||||
@@ -47,13 +57,19 @@ void lyra2re_hash(void *state, const void *input)
|
||||
#define hashA hash
|
||||
#define hashB hash+16
|
||||
|
||||
sph_blake256(&ctx.blake, input, 80);
|
||||
const int midlen = 64; // bytes
|
||||
const int tail = 80 - midlen; // 16
|
||||
|
||||
memcpy( &ctx.blake, &lyra2_blake_mid, sizeof lyra2_blake_mid );
|
||||
sph_blake256( &ctx.blake, input + 64, 16 );
|
||||
|
||||
// sph_blake256(&ctx.blake, input, 80);
|
||||
sph_blake256_close(&ctx.blake, hashA);
|
||||
|
||||
sph_keccak256(&ctx.keccak, hashA, 32);
|
||||
sph_keccak256_close(&ctx.keccak, hashB);
|
||||
|
||||
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
|
||||
LYRA2RE( hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
|
||||
|
||||
sph_skein256(&ctx.skein, hashA, 32);
|
||||
sph_skein256_close(&ctx.skein, hashB);
|
||||
@@ -81,6 +97,8 @@ int scanhash_lyra2re(int thr_id, struct work *work,
|
||||
|
||||
swab32_array( endiandata, pdata, 20 );
|
||||
|
||||
lyra2_blake256_midstate( endiandata );
|
||||
|
||||
do {
|
||||
be32enc(&endiandata[19], nonce);
|
||||
lyra2re_hash(hash, endiandata);
|
||||
@@ -112,10 +130,34 @@ void lyra2re_set_target ( struct work* work, double job_diff )
|
||||
work_set_target(work, job_diff / (128.0 * opt_diff_factor) );
|
||||
}
|
||||
|
||||
/*
|
||||
bool lyra2re_thread_init()
|
||||
{
|
||||
const int64_t ROW_LEN_INT64 = BLOCK_LEN_INT64 * 8; // nCols
|
||||
const int64_t ROW_LEN_BYTES = ROW_LEN_INT64 * 8;
|
||||
|
||||
int i = (int64_t)ROW_LEN_BYTES * 8; // nRows;
|
||||
lyra2re_wholeMatrix = _mm_malloc( i, 64 );
|
||||
|
||||
if ( lyra2re_wholeMatrix == NULL )
|
||||
return false;
|
||||
|
||||
#if defined (__AVX2__)
|
||||
memset_zero_m256i( (__m256i*)lyra2re_wholeMatrix, i/32 );
|
||||
#elif defined(__AVX__)
|
||||
memset_zero_m128i( (__m128i*)lyra2re_wholeMatrix, i/16 );
|
||||
#else
|
||||
memset( lyra2re_wholeMatrix, 0, i );
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool register_lyra2re_algo( algo_gate_t* gate )
|
||||
{
|
||||
init_lyra2re_ctx();
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT;
|
||||
// gate->miner_thread_init = (void*)&lyra2re_thread_init;
|
||||
gate->scanhash = (void*)&scanhash_lyra2re;
|
||||
gate->hash = (void*)&lyra2re_hash;
|
||||
gate->hash_alt = (void*)&lyra2re_hash;
|
||||
|
||||
Reference in New Issue
Block a user