mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.11.1
This commit is contained in:
@@ -10,7 +10,6 @@ bool register_nist5_algo( algo_gate_t* gate )
|
||||
gate->scanhash = (void*)&scanhash_nist5_4way;
|
||||
gate->hash = (void*)&nist5hash_4way;
|
||||
#else
|
||||
init_nist5_ctx();
|
||||
gate->scanhash = (void*)&scanhash_nist5;
|
||||
gate->hash = (void*)&nist5hash;
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#ifndef __NIST5_GATE_H__
|
||||
#define __NIST5_GATE_H__ 1
|
||||
#ifndef NIST5_GATE_H__
|
||||
#define NIST5_GATE_H__ 1
|
||||
|
||||
#include "algo-gate-api.h"
|
||||
#include <stdint.h>
|
||||
@@ -30,7 +30,7 @@ void nist5hash( void *state, const void *input );
|
||||
|
||||
int scanhash_nist5( struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done, struct thr_info *mythr );
|
||||
void init_nist5_ctx();
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -1,84 +1,59 @@
|
||||
#include "nist5-gate.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "algo/blake/sph_blake.h"
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#include "algo/skein/sph_skein.h"
|
||||
#include "algo/jh/sph_jh.h"
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
|
||||
#include "algo/blake/sse2/blake.c"
|
||||
#include "algo/keccak/sse2/keccak.c"
|
||||
#include "algo/skein/sse2/skein.c"
|
||||
#include "algo/jh/sse2/jh_sse2_opt64.h"
|
||||
|
||||
#ifndef NO_AES_NI
|
||||
#include "algo/skein/sph_skein.h"
|
||||
#if defined(__AES__)
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_context groestl;
|
||||
#else
|
||||
hashState_groestl groestl;
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#endif
|
||||
} nist5_ctx_holder;
|
||||
|
||||
nist5_ctx_holder nist5_ctx;
|
||||
|
||||
void init_nist5_ctx()
|
||||
{
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_init( &nist5_ctx.groestl );
|
||||
#else
|
||||
init_groestl( &nist5_ctx.groestl, 64 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void nist5hash(void *output, const void *input)
|
||||
{
|
||||
size_t hashptr;
|
||||
unsigned char hashbuf[128];
|
||||
sph_u64 hashctA;
|
||||
sph_u64 hashctB;
|
||||
unsigned char hash[128] __attribute__ ((aligned (64))) ;
|
||||
#define hashA hash
|
||||
#define hashB hash+64
|
||||
uint32_t hash[16] __attribute__((aligned(64)));
|
||||
sph_blake512_context ctx_blake;
|
||||
#if defined(__AES__)
|
||||
hashState_groestl ctx_groestl;
|
||||
#else
|
||||
sph_groestl512_context ctx_groestl;
|
||||
#endif
|
||||
sph_skein512_context ctx_skein;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
uint32_t mask = 8;
|
||||
|
||||
nist5_ctx_holder ctx __attribute__ ((aligned (64)));
|
||||
memcpy( &ctx, &nist5_ctx, sizeof(nist5_ctx) );
|
||||
sph_blake512_init( &ctx_blake );
|
||||
sph_blake512( &ctx_blake, input, 80 );
|
||||
sph_blake512_close( &ctx_blake, hash );
|
||||
|
||||
DECL_BLK;
|
||||
BLK_I;
|
||||
BLK_W;
|
||||
BLK_C;
|
||||
#if defined(__AES__)
|
||||
init_groestl( &ctx_groestl, 64 );
|
||||
update_and_final_groestl( &ctx_groestl, (char*)hash,
|
||||
(const char*)hash, 512 );
|
||||
#else
|
||||
sph_groestl512_init( &ctx_groestl );
|
||||
sph_groestl512( &ctx_groestl, hash, 64 );
|
||||
sph_groestl512_close( &ctx_groestl, hash );
|
||||
#endif
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512 (&ctx.groestl, hash, 64);
|
||||
sph_groestl512_close(&ctx.groestl, hash);
|
||||
#else
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash,
|
||||
(const char*)hash, 512 );
|
||||
#endif
|
||||
sph_jh512_init( &ctx_jh );
|
||||
sph_jh512( &ctx_jh, hash, 64 );
|
||||
sph_jh512_close( &ctx_jh, hash );
|
||||
|
||||
DECL_JH;
|
||||
JH_H;
|
||||
sph_keccak512_init( &ctx_keccak );
|
||||
sph_keccak512( &ctx_keccak, hash, 64 );
|
||||
sph_keccak512_close( &ctx_keccak, hash );
|
||||
|
||||
DECL_KEC;
|
||||
KEC_I;
|
||||
KEC_U;
|
||||
KEC_C;
|
||||
sph_skein512_init( &ctx_skein );
|
||||
sph_skein512( &ctx_skein, hash, 64 );
|
||||
sph_skein512_close( &ctx_skein, hash );
|
||||
|
||||
DECL_SKN;
|
||||
SKN_I;
|
||||
SKN_U;
|
||||
SKN_C;
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
memcpy( output, hash, 32 );
|
||||
}
|
||||
|
||||
int scanhash_nist5( struct work *work, uint32_t max_nonce,
|
||||
|
117
algo/nist5/zr5.c
117
algo/nist5/zr5.c
@@ -30,23 +30,14 @@
|
||||
#include "algo-gate-api.h"
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#include "algo/blake/sph_blake.h"
|
||||
#include "algo/jh/sph_jh.h"
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
|
||||
#ifndef NO_AES_NI
|
||||
#include "algo/skein/sph_skein.h"
|
||||
#if defined(__AES__)
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#endif
|
||||
|
||||
#include "algo/jh/sse2/jh_sse2_opt64.h"
|
||||
#include "algo/skein/sse2/skein.c"
|
||||
#include "algo/blake/sse2/blake.c"
|
||||
|
||||
/*define data alignment for different C compilers*/
|
||||
#if defined(__GNUC__)
|
||||
#define DATA_ALIGN16(x) x __attribute__ ((aligned(16)))
|
||||
#else
|
||||
#define DATA_ALIGN16(x) __declspec(align(16)) x
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#endif
|
||||
|
||||
#define ZR_BLAKE 0
|
||||
@@ -56,38 +47,19 @@
|
||||
#define POK_BOOL_MASK 0x00008000
|
||||
#define POK_DATA_MASK 0xFFFF0000
|
||||
|
||||
typedef struct {
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_context groestl;
|
||||
#else
|
||||
hashState_groestl groestl;
|
||||
#endif
|
||||
sph_keccak512_context keccak;
|
||||
} zr5_ctx_holder;
|
||||
|
||||
zr5_ctx_holder zr5_ctx;
|
||||
|
||||
void init_zr5_ctx()
|
||||
{
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_init( &zr5_ctx.groestl );
|
||||
#else
|
||||
init_groestl( &zr5_ctx.groestl, 64 );
|
||||
#endif
|
||||
sph_keccak512_init(&zr5_ctx.keccak);
|
||||
}
|
||||
|
||||
static void zr5hash(void *state, const void *input)
|
||||
{
|
||||
char hash[128] __attribute__((aligned(64)));
|
||||
sph_blake512_context ctx_blake;
|
||||
#if defined(__AES__)
|
||||
hashState_groestl ctx_groestl;
|
||||
#else
|
||||
sph_groestl512_context ctx_groestl;
|
||||
#endif
|
||||
sph_skein512_context ctx_skein;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
|
||||
DATA_ALIGN16(unsigned char hashbuf[128]);
|
||||
DATA_ALIGN16(unsigned char hash[128]);
|
||||
DATA_ALIGN16(size_t hashptr);
|
||||
DATA_ALIGN16(sph_u64 hashctA);
|
||||
DATA_ALIGN16(sph_u64 hashctB);
|
||||
|
||||
//memset(hash, 0, 128);
|
||||
|
||||
static const int arrOrder[][4] =
|
||||
{
|
||||
{ 0, 1, 2, 3 }, { 0, 1, 3, 2 }, { 0, 2, 1, 3 }, { 0, 2, 3, 1 },
|
||||
@@ -98,50 +70,48 @@ static const int arrOrder[][4] =
|
||||
{ 3, 1, 0, 2 }, { 3, 1, 2, 0 }, { 3, 2, 0, 1 }, { 3, 2, 1, 0 }
|
||||
};
|
||||
|
||||
zr5_ctx_holder ctx;
|
||||
memcpy( &ctx, &zr5_ctx, sizeof(zr5_ctx) );
|
||||
|
||||
sph_keccak512 (&ctx.keccak, input, 80);
|
||||
sph_keccak512_close(&ctx.keccak, hash);
|
||||
sph_keccak512_init( &ctx_keccak );
|
||||
sph_keccak512( &ctx_keccak, input, 80 );
|
||||
sph_keccak512_close( &ctx_keccak, hash );
|
||||
|
||||
unsigned int nOrder = *(unsigned int *)(&hash) % 24;
|
||||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for ( i = 0; i < 4; i++ )
|
||||
{
|
||||
switch (arrOrder[nOrder][i])
|
||||
switch ( arrOrder[nOrder][i] )
|
||||
{
|
||||
case 0:
|
||||
{DECL_BLK;
|
||||
BLK_I;
|
||||
BLK_U;
|
||||
BLK_C;}
|
||||
break;
|
||||
sph_blake512_init( &ctx_blake );
|
||||
sph_blake512( &ctx_blake, hash, 64 );
|
||||
sph_blake512_close( &ctx_blake, hash );
|
||||
break;
|
||||
case 1:
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512 (&ctx.groestl, hash, 64);
|
||||
sph_groestl512_close(&ctx.groestl, hash);
|
||||
#else
|
||||
update_groestl( &ctx.groestl, (char*)hash,512);
|
||||
final_groestl( &ctx.groestl, (char*)hash);
|
||||
#endif
|
||||
break;
|
||||
#if defined(__AES__)
|
||||
init_groestl( &ctx_groestl, 64 );
|
||||
update_and_final_groestl( &ctx_groestl, (char*)hash,
|
||||
(const char*)hash, 512 );
|
||||
#else
|
||||
sph_groestl512_init( &ctx_groestl );
|
||||
sph_groestl512( &ctx_groestl, hash, 64 );
|
||||
sph_groestl512_close( &ctx_groestl, hash );
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
{DECL_JH;
|
||||
JH_H;}
|
||||
break;
|
||||
sph_jh512_init( &ctx_jh );
|
||||
sph_jh512( &ctx_jh, hash, 64 );
|
||||
sph_jh512_close( &ctx_jh, hash );
|
||||
break;
|
||||
case 3:
|
||||
{DECL_SKN;
|
||||
SKN_I;
|
||||
SKN_U;
|
||||
SKN_C; }
|
||||
break;
|
||||
sph_skein512_init( &ctx_skein );
|
||||
sph_skein512( &ctx_skein, hash, 64 );
|
||||
sph_skein512_close( &ctx_skein, hash );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
asm volatile ("emms");
|
||||
memcpy(state, hash, 32);
|
||||
memcpy( state, hash, 32 );
|
||||
}
|
||||
|
||||
int scanhash_zr5( struct work *work, uint32_t max_nonce,
|
||||
@@ -219,7 +189,6 @@ int zr5_get_work_data_size() { return 80; }
|
||||
bool register_zr5_algo( algo_gate_t* gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | AES_OPT;
|
||||
init_zr5_ctx();
|
||||
gate->get_new_work = (void*)&zr5_get_new_work;
|
||||
gate->scanhash = (void*)&scanhash_zr5;
|
||||
gate->hash = (void*)&zr5hash;
|
||||
|
Reference in New Issue
Block a user