mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v23.5
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
/* #define NO_PRECOMPUTED_IV */
|
||||
|
||||
#if defined(__SSE2__) // || defined(__ARM_NEON)
|
||||
|
||||
/*
|
||||
* Increase the counter.
|
||||
@@ -16,7 +16,7 @@ void IncreaseCounter(hashState_sd *state, DataLength databitlen) {
|
||||
#ifdef HAS_64
|
||||
state->count += databitlen;
|
||||
#else
|
||||
u32 old_count = state->count_low;
|
||||
uint32_t old_count = state->count_low;
|
||||
state->count_low += databitlen;
|
||||
if (state->count_low < old_count)
|
||||
state->count_high++;
|
||||
@@ -28,14 +28,9 @@ void IncreaseCounter(hashState_sd *state, DataLength databitlen) {
|
||||
* Initialize the hashState_sd with a given IV.
|
||||
* If the IV is NULL, initialize with zeros.
|
||||
*/
|
||||
HashReturn InitIV(hashState_sd *state, int hashbitlen, const u32 *IV) {
|
||||
int InitIV(hashState_sd *state, int hashbitlen, const u32 *IV) {
|
||||
|
||||
int n;
|
||||
|
||||
if (!SupportedLength(hashbitlen))
|
||||
return BAD_HASHBITLEN;
|
||||
|
||||
n = 8;
|
||||
int n = 8;
|
||||
|
||||
state->hashbitlen = hashbitlen;
|
||||
state->n_feistels = n;
|
||||
@@ -71,15 +66,15 @@ HashReturn InitIV(hashState_sd *state, int hashbitlen, const u32 *IV) {
|
||||
|
||||
// free(state->buffer);
|
||||
// free(state->A);
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the hashState_sd.
|
||||
*/
|
||||
HashReturn init_sd(hashState_sd *state, int hashbitlen) {
|
||||
HashReturn r;
|
||||
int init_sd(hashState_sd *state, int hashbitlen) {
|
||||
int r;
|
||||
char *init;
|
||||
|
||||
#ifndef NO_PRECOMPUTED_IV
|
||||
@@ -91,7 +86,7 @@ HashReturn init_sd(hashState_sd *state, int hashbitlen) {
|
||||
// r=InitIV(state, hashbitlen, IV_384);
|
||||
// else
|
||||
if (hashbitlen == 512)
|
||||
r=InitIV(state, hashbitlen, IV_512);
|
||||
r = InitIV(state, hashbitlen, IV_512);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
@@ -99,7 +94,7 @@ HashReturn init_sd(hashState_sd *state, int hashbitlen) {
|
||||
* Nonstandart length: IV is not precomputed.
|
||||
*/
|
||||
r=InitIV(state, hashbitlen, NULL);
|
||||
if (r != SUCCESS)
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
init = malloc(state->blocksize);
|
||||
@@ -115,7 +110,7 @@ HashReturn init_sd(hashState_sd *state, int hashbitlen) {
|
||||
return r;
|
||||
}
|
||||
|
||||
HashReturn update_sd( hashState_sd *state, const BitSequence *data,
|
||||
int update_sd( hashState_sd *state, const BitSequence *data,
|
||||
DataLength databitlen )
|
||||
{
|
||||
unsigned current;
|
||||
@@ -135,7 +130,7 @@ HashReturn update_sd( hashState_sd *state, const BitSequence *data,
|
||||
{
|
||||
// The number of hashed bits is not a multiple of 8.
|
||||
// Very painfull to implement and not required by the NIST API.
|
||||
return FAIL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ( databitlen > 0 )
|
||||
@@ -156,7 +151,7 @@ HashReturn update_sd( hashState_sd *state, const BitSequence *data,
|
||||
{
|
||||
memcpy( state->buffer+current/8, data, (databitlen+7)/8 );
|
||||
IncreaseCounter( state, databitlen );
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,16 +164,16 @@ HashReturn update_sd( hashState_sd *state, const BitSequence *data,
|
||||
}
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HashReturn final_sd( hashState_sd *state, BitSequence *hashval )
|
||||
int final_sd( hashState_sd *state, BitSequence *hashval )
|
||||
{
|
||||
#ifdef HAS_64
|
||||
u64 l;
|
||||
uint64_t l;
|
||||
int current = state->count & (state->blocksize - 1);
|
||||
#else
|
||||
u32 l;
|
||||
uint32_t l;
|
||||
int current = state->count_low & (state->blocksize - 1);
|
||||
#endif
|
||||
unsigned int i;
|
||||
@@ -248,10 +243,10 @@ HashReturn final_sd( hashState_sd *state, BitSequence *hashval )
|
||||
BitSequence mask = 0xff << ( 8 - (state->hashbitlen % 8) );
|
||||
hashval[state->hashbitlen/8 + 1] = bs[state->hashbitlen/8 + 1] & mask;
|
||||
}
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
int update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
const BitSequence *data, DataLength databitlen )
|
||||
{
|
||||
int current, i;
|
||||
@@ -259,7 +254,7 @@ HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
static int align = -1;
|
||||
BitSequence out[64];
|
||||
int isshort = 1;
|
||||
u64 l;
|
||||
uint64_t l;
|
||||
|
||||
if (align == -1)
|
||||
align = RequiredAlignment();
|
||||
@@ -274,7 +269,7 @@ HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
{
|
||||
// The number of hashed bits is not a multiple of 8.
|
||||
// Very painfull to implement and not required by the NIST API.
|
||||
return FAIL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ( databitlen > 0 )
|
||||
@@ -357,7 +352,7 @@ HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
BitSequence mask = 0xff << ( 8 - (state->hashbitlen % 8) );
|
||||
hashval[state->hashbitlen/8 + 1] = out[state->hashbitlen/8 + 1] & mask;
|
||||
}
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
@@ -372,7 +367,7 @@ int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
static int align = -1;
|
||||
BitSequence out[64];
|
||||
int isshort = 1;
|
||||
u64 l;
|
||||
uint64_t l;
|
||||
|
||||
if (align == -1)
|
||||
align = RequiredAlignment();
|
||||
@@ -387,7 +382,7 @@ int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
{
|
||||
// The number of hashed bits is not a multiple of 8.
|
||||
// Very painfull to implement and not required by the NIST API.
|
||||
return FAIL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ( databitlen > 0 )
|
||||
@@ -470,6 +465,8 @@ int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
BitSequence mask = 0xff << ( 8 - (state->hashbitlen % 8) );
|
||||
hashval[state->hashbitlen/8 + 1] = out[state->hashbitlen/8 + 1] & mask;
|
||||
}
|
||||
return SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,16 +20,16 @@ typedef struct {
|
||||
unsigned int n_feistels;
|
||||
|
||||
#ifdef HAS_64
|
||||
u64 count;
|
||||
uint64_t count;
|
||||
#else
|
||||
u32 count_low;
|
||||
u32 count_high;
|
||||
uint32_t count_low;
|
||||
uint32_t count_high;
|
||||
#endif
|
||||
|
||||
DATA_ALIGN(u32 A[32]);
|
||||
u32 *B;
|
||||
u32 *C;
|
||||
u32 *D;
|
||||
DATA_ALIGN(uint32_t A[32]);
|
||||
uint32_t *B;
|
||||
uint32_t *C;
|
||||
uint32_t *D;
|
||||
DATA_ALIGN(unsigned char buffer[128]);
|
||||
|
||||
} hashState_sd;
|
||||
@@ -38,13 +38,13 @@ typedef struct {
|
||||
* NIST API
|
||||
*/
|
||||
|
||||
HashReturn init_sd(hashState_sd *state, int hashbitlen);
|
||||
int init_sd(hashState_sd *state, int hashbitlen);
|
||||
|
||||
HashReturn update_sd(hashState_sd *state, const BitSequence *data, DataLength databitlen);
|
||||
int update_sd(hashState_sd *state, const BitSequence *data, DataLength databitlen);
|
||||
|
||||
HashReturn final_sd(hashState_sd *state, BitSequence *hashval);
|
||||
int final_sd(hashState_sd *state, BitSequence *hashval);
|
||||
|
||||
HashReturn update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
int update_final_sd( hashState_sd *state, BitSequence *hashval,
|
||||
const BitSequence *data, DataLength databitlen );
|
||||
|
||||
int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
@@ -54,7 +54,7 @@ int simd_full( hashState_sd *state, BitSequence *hashval,
|
||||
* Internal API
|
||||
*/
|
||||
|
||||
int SupportedLength(int hashbitlen);
|
||||
//int SupportedLength(int hashbitlen);
|
||||
int RequiredAlignment(void);
|
||||
void SIMD_Compress(hashState_sd * state, const unsigned char *M, int final);
|
||||
|
||||
|
||||
@@ -5,16 +5,19 @@
|
||||
#include "vector.h"
|
||||
|
||||
|
||||
//#if defined(__SSE2__) || defined(__ARM_NEON)
|
||||
#if defined(__SSE2__)
|
||||
|
||||
#define PRINT_SOME 0
|
||||
|
||||
/*
|
||||
int SupportedLength(int hashbitlen) {
|
||||
if (hashbitlen <= 0 || hashbitlen > 512)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
int RequiredAlignment(void) {
|
||||
return 16;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __VECTOR_H__
|
||||
|
||||
#include "compat.h"
|
||||
#include "simd-utils.h"
|
||||
|
||||
/*******************************
|
||||
* Using GCC vector extensions *
|
||||
@@ -133,13 +134,13 @@ union u32 {
|
||||
#define vec_or(x,y) v128_or( x, y )
|
||||
#define vec_xor(x,y) v128_xor( x, y )
|
||||
|
||||
#define v16_and vec_and
|
||||
#define v16_or vec_or
|
||||
#define v16_xor vec_xor
|
||||
#define v16_and v128_and
|
||||
#define v16_or v128_or
|
||||
#define v16_xor v128_xor
|
||||
|
||||
#define v32_and vec_and
|
||||
#define v32_or vec_or
|
||||
#define v32_xor vec_xor
|
||||
#define v32_and v128_and
|
||||
#define v32_or v128_or
|
||||
#define v32_xor v128_xor
|
||||
|
||||
#define vec_andn( x,y ) v128_andnot( x, y )
|
||||
#define v16_andn vec_andn
|
||||
@@ -158,7 +159,6 @@ union u32 {
|
||||
#define v16_interleavel v128_unpacklo16
|
||||
#define v16_interleaveh v128_unpackhi16
|
||||
|
||||
// the builtins compile for arm, so ???
|
||||
#define v16_mergel(a,b) V1632(__builtin_ia32_punpcklwd128(a,b))
|
||||
#define v16_mergeh(a,b) V1632(__builtin_ia32_punpckhwd128(a,b))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user