This commit is contained in:
Jay D Dee
2017-11-28 16:32:04 -05:00
parent 6d1361c87f
commit 4b57ac0eb9
70 changed files with 10549 additions and 2852 deletions

View File

@@ -1,4 +1,3 @@
#include "algo-gate-api.h"
#include "skein-gate.h"
#include <string.h>
#include <stdint.h>
@@ -60,7 +59,7 @@ int scanhash_skein_4way( int thr_id, struct work *work, uint32_t max_nonce,
// hash is returned deinterleaved
uint32_t *nonces = work->nonces;
bool *found = work->nfound;
int num_found;
int num_found = 0;
// data is 80 bytes, 20 u32 or 4 u64.
@@ -76,7 +75,6 @@ int scanhash_skein_4way( int thr_id, struct work *work, uint32_t max_nonce,
do
{
found[0] = found[1] = found[2] = found[3] = false;
num_found = 0;
be32enc( noncep0, n );
be32enc( noncep1, n+1 );
be32enc( noncep2, n+2 );

View File

@@ -1,7 +1,4 @@
#include "skein-gate.h"
#include "algo-gate-api.h"
//#include <string.h>
//#include <stdint.h>
#include "sph_skein.h"
#include "skein-hash-4way.h"
@@ -9,7 +6,7 @@ int64_t skein_get_max64() { return 0x7ffffLL; }
bool register_skein_algo( algo_gate_t* gate )
{
#if defined (FOUR_WAY) && defined (__AVX2__)
#if defined (SKEIN_4WAY)
gate->optimizations = SSE2_OPT | AVX2_OPT | SHA_OPT;
gate->scanhash = (void*)&scanhash_skein_4way;
gate->hash = (void*)&skeinhash_4way;

View File

@@ -1,15 +1,22 @@
#ifndef __SKEIN_GATE_H__
#define __SKEIN_GATE_H__
#include <stdint.h>
#include "algo-gate-api.h"
#if defined(__AVX2__)
#if defined(FOUR_WAY) && defined(__AVX2__)
#define SKEIN_4WAY
#endif
#if defined(SKEIN_4WAY)
void skeinhash_4way( void *output, const void *input );
int scanhash_skein_4way( int thr_id, struct work *work, uint32_t max_nonce,
uint64_t *hashes_done );
#endif
void skeinhash( void *output, const void *input );
int scanhash_skein( int thr_id, struct work *work, uint32_t max_nonce,
uint64_t *hashes_done );

View File

@@ -296,7 +296,6 @@ do { \
w5 = _mm256_add_epi64( w5, _mm256_add_epi64( SKBI(k,s,5), \
_mm256_set_epi64x( SKBT(t,s,0), SKBT(t,s,0), \
SKBT(t,s,0), SKBT(t,s,0) ) ) ); \
__m256i skbi6 = SKBI(k,s,6); \
w6 = _mm256_add_epi64( w6, _mm256_add_epi64( SKBI(k,s,6), \
_mm256_set_epi64x( SKBT(t,s,1), SKBT(t,s,1), \
SKBT(t,s,1), SKBT(t,s,1) ) ) ); \
@@ -458,20 +457,10 @@ skein_big_core_4way( skein512_4way_context *sc, const void *data,
unsigned first;
DECL_STATE_BIG_4WAY
// len is the array size, of data, ie 64 bytes
// data points to start of 4 element buf
// ptr is a len offset in bytes
// buff is an array of 4 elements
// buff_size is size of one array element
// One element is 8 bytes (64 bits) scalar but 32 bytes (256 bits) 4way
// To index buf using ptr it has to be scaled 8 to 1. the amounrt of
// data to copy is 32 bytes per element instead of 8, or one m256
buf = sc->buf;
ptr = sc->ptr;
const int buf_size = 64; // 64 * _m256i
// 64 byte len, no part block
if ( len <= buf_size - ptr )
{
memcpy_m256i( buf + (ptr>>3), vdata, len>>3 );
@@ -481,8 +470,6 @@ skein_big_core_4way( skein512_4way_context *sc, const void *data,
READ_STATE_BIG( sc );
first = ( bcount == 0 ) << 7;
// 64 byte len, only one block, no transform here.
// 80 byte len, transform first 64 bytes.
do {
size_t clen;
@@ -512,19 +499,7 @@ skein_big_close_4way( skein512_4way_context *sc, unsigned ub, unsigned n,
__m256i *buf;
size_t ptr;
unsigned et;
int i;
DECL_STATE_BIG_4WAY
/*
* Add bit padding if necessary.
*/
// if (n != 0) {
// unsigned z;
// unsigned char x;
//
// z = 0x80 >> n;
// x = ((ub & -z) | z) & 0xFF;
// skein_big_core(sc, &x, 1);
// }
buf = sc->buf;
ptr = sc->ptr;
@@ -543,8 +518,6 @@ skein_big_close_4way( skein512_4way_context *sc, unsigned ub, unsigned n,
* the encoding of "0", over 8 bytes, then padded with zeros).
*/
// 64 byte len, process only block
// 80 byte len, process last part block (16 bytes) padded.
READ_STATE_BIG(sc);
memset_zero_m256i( buf + (ptr>>3), (buf_size - ptr) >> 3 );
@@ -555,28 +528,6 @@ skein_big_close_4way( skein512_4way_context *sc, unsigned ub, unsigned n,
bcount = 0;
UBI_BIG_4WAY( 510, 8 );
// for ( i = 0; i < 2; i ++ )
// {
// UBI_BIG_AVX2( et, ptr );
// if (i == 0)
// {
// memset_zero_m256i( buf, buf_size >> 3 );
// bcount = 0;
// et = 510;
// ptr = 8;
// }
// }
// Can LE be assumed? Should be ok SPH_LITTLE_ENDIAN is defined
/* _mm256_enc64le( buf, h0 );
_mm256_enc64le( buf + 32, h1 );
_mm256_enc64le( buf + 64, h2 );
_mm256_enc64le( buf + 96, h3 );
_mm256_enc64le( buf + 128, h4 );
_mm256_enc64le( buf + 160, h5 );
_mm256_enc64le( buf + 192, h6 );
_mm256_enc64le( buf + 224, h7 );
*/
buf[0] = h0;
buf[1] = h1;
buf[2] = h2;
@@ -587,7 +538,6 @@ skein_big_close_4way( skein512_4way_context *sc, unsigned ub, unsigned n,
buf[7] = h7;
memcpy_m256i( dst, buf, out_len >> 3 );
// memcpy( dst, buf, out_len * 4 );
}
static const sph_u64 IV256[] = {

View File

@@ -1,10 +1,9 @@
#include "skein-gate.h"
#include "algo-gate-api.h"
#include "skein2-gate.h"
#include <string.h>
#include <stdint.h>
#include "skein-hash-4way.h"
#if defined(__AVX2__)
#if defined(SKEIN2_4WAY)
void skein2hash_4way( void *output, const void *input )
{
@@ -38,7 +37,7 @@ int scanhash_skein2_4way( int thr_id, struct work *work, uint32_t max_nonce,
// hash is returned deinterleaved
uint32_t *nonces = work->nonces;
bool *found = work->nfound;
int num_found;
int num_found = 0;
swab32_array( endiandata, pdata, 20 );
@@ -52,7 +51,6 @@ int scanhash_skein2_4way( int thr_id, struct work *work, uint32_t max_nonce,
do
{
found[0] = found[1] = found[2] = found[3] = false;
num_found = 0;
be32enc( noncep0, n );
be32enc( noncep1, n+1 );
be32enc( noncep2, n+2 );

View File

@@ -1,9 +1,6 @@
#include "skein2-gate.h"
#include "algo-gate-api.h"
//#include <string.h>
#include <stdint.h>
#include "sph_skein.h"
//#include "skein-hash-avx2.h"
int64_t skein2_get_max64 ()
{

View File

@@ -1,8 +1,13 @@
#ifndef __SKEIN2GATE_H__
#define __SKEIN2_GATE_H__
#include "algo-gate-api.h"
#include <stdint.h>
#if defined(__AVX2__)
#if defined(FOUR_WAY) && defined(__AVX2__)
#define SKEIN2_4WAY
#endif
#if defined(SKEIN2_4WAY)
void skein2hash_4way( void *output, const void *input );
int scanhash_skein2_4way( int thr_id, struct work *work, uint32_t max_nonce,
uint64_t* hashes_done );

View File

@@ -39,25 +39,6 @@
extern "C"{
#endif
void dump_sph_context( sph_u64 ptr, sph_u64 bcount, uint64_t* buf,
sph_u64 h0, sph_u64 h1, sph_u64 h2, sph_u64 h3, sph_u64 h4, sph_u64 h5,
sph_u64 h6, sph_u64 h7 )
{
//scalar
printf("sptr= %llu, bcount= %llu\n", ptr, bcount );
printf("sbuf: %016llx %016llx %016llx %016llx\n", *((uint64_t*)buf),
*((uint64_t*)buf+1), *((uint64_t*)buf+2), *((uint64_t*)buf+3) );
printf(" %016llx %016llx %016llx %016llx\n", *((uint64_t*)buf+4),
*((uint64_t*)buf+5), *((uint64_t*)buf+6), *((uint64_t*)buf+7) );
printf("sh:%016llx %016llx %016llx %016llx\n", h0, h1, h2, h3 );
printf(" %016llx %016llx %016llx %016llx\n", h4, h5, h6, h7 );
}
#if SPH_SMALL_FOOTPRINT && !defined SPH_SMALL_FOOTPRINT_SKEIN
#define SPH_SMALL_FOOTPRINT_SKEIN 1
#endif