mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.12.8
This commit is contained in:
@@ -19,11 +19,12 @@
|
||||
*/
|
||||
|
||||
#include "cpuminer-config.h"
|
||||
#include "miner.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "yescrypt-r8g.h"
|
||||
#include <stdlib.h>
|
||||
#include "algo-gate-api.h"
|
||||
#include "yespower.h"
|
||||
|
||||
int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done, struct thr_info *mythr )
|
||||
@@ -37,7 +38,17 @@ int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce,
|
||||
const uint32_t last_nonce = max_nonce;
|
||||
const int thr_id = mythr->id;
|
||||
|
||||
yespower_params_t params =
|
||||
static __thread int initialized = 0;
|
||||
static __thread yespower_local_t local;
|
||||
|
||||
if ( !initialized )
|
||||
{
|
||||
if ( yespower_init_local( &local ) )
|
||||
return -1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
yespower_params_t params =
|
||||
{
|
||||
.version = YESPOWER_0_5,
|
||||
.N = 2048,
|
||||
@@ -56,7 +67,7 @@ int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce,
|
||||
SHA256_Update( &sha256_prehash_ctx, endiandata, 64 );
|
||||
|
||||
do {
|
||||
yespower_tls( (unsigned char *)endiandata, params.perslen,
|
||||
yespower_hash( &local, (unsigned char *)endiandata, params.perslen,
|
||||
¶ms, (yespower_binary_t*)hash, thr_id );
|
||||
|
||||
if unlikely( valid_hash( hash, ptarget ) && !opt_benchmark )
|
||||
@@ -76,7 +87,6 @@ bool register_yescryptr8g_algo( algo_gate_t* gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yespower_r8g;
|
||||
gate->hash = (void*)&yespower_tls;
|
||||
pk_buffer_size = 26;
|
||||
opt_sapling = true;
|
||||
opt_target_factor = 65536.0;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*-
|
||||
* Copyright 2009 Colin Percival
|
||||
* Copyright 2013-2018 Alexander Peslyak
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file was originally written by Colin Percival as part of the Tarsnap
|
||||
* online backup system.
|
||||
*/
|
||||
#ifndef _YESPOWERR8G_H_
|
||||
#define _YESPOWERR8G_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h> /* for size_t */
|
||||
#include "algo-gate-api.h"
|
||||
#include "algo/yespower/yespower.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int yespowerr8g_tls(const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_YESPOWERR8G_H_ */
|
||||
@@ -1112,10 +1112,10 @@ static void smix(uint8_t *B, size_t r, uint32_t N,
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*/
|
||||
int yespower_b2b(yespower_local_t *local,
|
||||
int yespower_b2b_hash(yespower_local_t *local,
|
||||
const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params,
|
||||
yespower_binary_t *dst, int thrid )
|
||||
void *dst, int thrid )
|
||||
{
|
||||
uint32_t N = params->N;
|
||||
uint32_t r = params->r;
|
||||
@@ -1191,37 +1191,4 @@ fail:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* yespower_tls(src, srclen, params, dst):
|
||||
* Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target".
|
||||
* The memory allocation is maintained internally using thread-local storage.
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*/
|
||||
int yespower_b2b_tls(const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thrid )
|
||||
{
|
||||
static __thread int initialized = 0;
|
||||
static __thread yespower_local_t local;
|
||||
|
||||
if (!initialized) {
|
||||
init_region(&local);
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
return yespower_b2b(&local, src, srclen, params, dst, thrid);
|
||||
}
|
||||
/*
|
||||
int yespower_init_local(yespower_local_t *local)
|
||||
{
|
||||
init_region(local);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yespower_free_local(yespower_local_t *local)
|
||||
{
|
||||
return free_region(local);
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,25 +23,17 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file was originally written by Cryply team as part of the Cryply
|
||||
* coin.
|
||||
*/
|
||||
#include "yespower.h"
|
||||
|
||||
#include "algo-gate-api.h"
|
||||
|
||||
yespower_params_t yespower_params;
|
||||
|
||||
SHA256_CTX sha256_prehash_ctx;
|
||||
// Give each thread its own copy to avoid requiring mutex.
|
||||
__thread SHA256_CTX sha256_prehash_ctx;
|
||||
|
||||
// YESPOWER
|
||||
|
||||
int yespower_hash( const char *input, char *output, uint32_t len, int thrid )
|
||||
{
|
||||
return yespower_tls( input, len, &yespower_params,
|
||||
(yespower_binary_t*)output, thrid );
|
||||
}
|
||||
|
||||
int scanhash_yespower( struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done, struct thr_info *mythr )
|
||||
{
|
||||
@@ -54,6 +46,16 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce,
|
||||
uint32_t n = first_nonce;
|
||||
const int thr_id = mythr->id;
|
||||
|
||||
static __thread int initialized = 0;
|
||||
static __thread yespower_local_t local;
|
||||
|
||||
if ( !initialized )
|
||||
{
|
||||
if ( yespower_init_local( &local ) )
|
||||
return -1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
for ( int k = 0; k < 19; k++ )
|
||||
be32enc( &endiandata[k], pdata[k] );
|
||||
endiandata[19] = n;
|
||||
@@ -63,7 +65,8 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce,
|
||||
SHA256_Update( &sha256_prehash_ctx, endiandata, 64 );
|
||||
|
||||
do {
|
||||
if ( yespower_hash( (char*)endiandata, (char*)vhash, 80, thr_id ) )
|
||||
if ( yespower_hash( &local, (char*)endiandata, 80, &yespower_params,
|
||||
(char*)vhash, thr_id ) )
|
||||
if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark )
|
||||
{
|
||||
be32enc( pdata+19, n );
|
||||
@@ -78,11 +81,6 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce,
|
||||
|
||||
// YESPOWER-B2B
|
||||
|
||||
int yespower_b2b_hash( const char *input, char *output, uint32_t len, int thrid )
|
||||
{
|
||||
return yespower_b2b_tls( input, len, &yespower_params, (yespower_binary_t*)output, thrid );
|
||||
}
|
||||
|
||||
int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done, struct thr_info *mythr )
|
||||
{
|
||||
@@ -95,6 +93,16 @@ int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce,
|
||||
const uint32_t last_nonce = max_nonce;
|
||||
const int thr_id = mythr->id;
|
||||
|
||||
static __thread int initialized = 0;
|
||||
static __thread yespower_local_t local;
|
||||
|
||||
if ( !initialized )
|
||||
{
|
||||
if ( yespower_init_local( &local ) )
|
||||
return -1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
for ( int k = 0; k < 19; k++ )
|
||||
be32enc( &endiandata[k], pdata[k] );
|
||||
endiandata[19] = n;
|
||||
@@ -104,7 +112,8 @@ int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce,
|
||||
SHA256_Update( &sha256_prehash_ctx, endiandata, 64 );
|
||||
|
||||
do {
|
||||
if (yespower_b2b_hash( (char*) endiandata, (char*) vhash, 80, thr_id ) )
|
||||
if (yespower_b2b_hash( &local, (char*) endiandata, 80, &yespower_params,
|
||||
(char*) vhash, thr_id ) )
|
||||
if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark )
|
||||
{
|
||||
be32enc( pdata+19, n );
|
||||
@@ -145,7 +154,6 @@ bool register_yespower_algo( algo_gate_t* gate )
|
||||
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yespower;
|
||||
gate->hash = (void*)&yespower_hash;
|
||||
opt_target_factor = 65536.0;
|
||||
return true;
|
||||
};
|
||||
@@ -159,7 +167,6 @@ bool register_yespowerr16_algo( algo_gate_t* gate )
|
||||
yespower_params.perslen = 0;
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yespower;
|
||||
gate->hash = (void*)&yespower_hash;
|
||||
opt_target_factor = 65536.0;
|
||||
return true;
|
||||
};
|
||||
@@ -268,9 +275,8 @@ bool register_power2b_algo( algo_gate_t* gate )
|
||||
applog( LOG_NOTICE,"Key= \"%s\"", yespower_params.pers );
|
||||
applog( LOG_NOTICE,"Key length= %d\n", yespower_params.perslen );
|
||||
|
||||
gate->optimizations = SSE2_OPT | SHA_OPT;
|
||||
gate->optimizations = SSE2_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yespower_b2b;
|
||||
gate->hash = (void*)&yespower_b2b_hash;
|
||||
opt_target_factor = 65536.0;
|
||||
return true;
|
||||
};
|
||||
@@ -310,7 +316,6 @@ bool register_yespower_b2b_algo( algo_gate_t* gate )
|
||||
|
||||
gate->optimizations = SSE2_OPT;
|
||||
gate->scanhash = (void*)&scanhash_yespower_b2b;
|
||||
gate->hash = (void*)&yespower_b2b_hash;
|
||||
opt_target_factor = 65536.0;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1024,10 +1024,10 @@ static void smix(uint8_t *B, size_t r, uint32_t N,
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*/
|
||||
int yespower(yespower_local_t *local,
|
||||
int yespower_hash( yespower_local_t *local,
|
||||
const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params,
|
||||
yespower_binary_t *dst, int thrid )
|
||||
void *dst, int thrid )
|
||||
{
|
||||
yespower_version_t version = params->version;
|
||||
uint32_t N = params->N;
|
||||
@@ -1158,27 +1158,6 @@ int yespower(yespower_local_t *local,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* yespower_tls(src, srclen, params, dst):
|
||||
* Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target".
|
||||
* The memory allocation is maintained internally using thread-local storage.
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*/
|
||||
int yespower_tls(const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thrid )
|
||||
{
|
||||
static __thread int initialized = 0;
|
||||
static __thread yespower_local_t local;
|
||||
|
||||
if (!initialized) {
|
||||
if (yespower_init_local(&local))
|
||||
return -1;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
return yespower( &local, src, srclen, params, dst, thrid );
|
||||
}
|
||||
|
||||
int yespower_init_local(yespower_local_t *local)
|
||||
{
|
||||
@@ -1190,4 +1169,5 @@ int yespower_free_local(yespower_local_t *local)
|
||||
{
|
||||
return free_region(local);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,67 +76,21 @@ typedef struct {
|
||||
unsigned char uc[32];
|
||||
} yespower_binary_t __attribute__ ((aligned (64)));
|
||||
|
||||
yespower_params_t yespower_params;
|
||||
extern yespower_params_t yespower_params;
|
||||
|
||||
SHA256_CTX sha256_prehash_ctx;
|
||||
extern __thread SHA256_CTX sha256_prehash_ctx;
|
||||
|
||||
/**
|
||||
* yespower_init_local(local):
|
||||
* Initialize the thread-local (RAM) data structure. Actual memory allocation
|
||||
* is currently fully postponed until a call to yespower().
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*
|
||||
* MT-safe as long as local is local to the thread.
|
||||
*/
|
||||
extern int yespower_init_local(yespower_local_t *local);
|
||||
|
||||
/**
|
||||
* yespower_free_local(local):
|
||||
* Free memory that may have been allocated for an initialized thread-local
|
||||
* (RAM) data structure.
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*
|
||||
* MT-safe as long as local is local to the thread.
|
||||
*/
|
||||
extern int yespower_free_local(yespower_local_t *local);
|
||||
|
||||
/**
|
||||
* yespower(local, src, srclen, params, dst):
|
||||
* Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target".
|
||||
* local is the thread-local data structure, allowing to preserve and reuse a
|
||||
* memory allocation across calls, thereby reducing processing overhead.
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*
|
||||
* local must be initialized with yespower_init_local().
|
||||
*
|
||||
* MT-safe as long as local and dst are local to the thread.
|
||||
*/
|
||||
extern int yespower(yespower_local_t *local,
|
||||
extern int yespower_hash(yespower_local_t *local,
|
||||
const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thrid);
|
||||
const yespower_params_t *params, void *dst, int thrid);
|
||||
|
||||
extern int yespower_b2b(yespower_local_t *local,
|
||||
extern int yespower_b2b_hash(yespower_local_t *local,
|
||||
const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thrid );
|
||||
|
||||
/**
|
||||
* yespower_tls(src, srclen, params, dst):
|
||||
* Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target".
|
||||
* The memory allocation is maintained internally using thread-local storage.
|
||||
*
|
||||
* Return 0 on success; or -1 on error.
|
||||
*
|
||||
* MT-safe as long as dst is local to the thread.
|
||||
*/
|
||||
extern int yespower_tls(const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thr_id);
|
||||
|
||||
extern int yespower_b2b_tls(const uint8_t *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_binary_t *dst, int thr_id);
|
||||
|
||||
const yespower_params_t *params, void *dst, int thrid );
|
||||
|
||||
#if defined(__AVX2__)
|
||||
|
||||
@@ -149,7 +103,6 @@ extern int yespower_8way( yespower_local_t *local, const __m256i *src,
|
||||
size_t srclen, const yespower_params_t *params,
|
||||
yespower_8way_binary_t *dst, int thrid );
|
||||
|
||||
|
||||
extern int yespower_8way_tls( const __m256i *src, size_t srclen,
|
||||
const yespower_params_t *params, yespower_8way_binary_t *dst, int thr_id );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user