mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c0aadbcc99 | ||
![]() |
3da149418a | ||
![]() |
720610cce5 |
41
README.md
41
README.md
@@ -37,25 +37,25 @@ Requirements
|
||||
------------
|
||||
|
||||
1. A x86_64 architecture CPU with a minimum of SSE2 support. This includes
|
||||
Intel Core2 and newer and AMD equivalents. In order to take advantage of AES_NI
|
||||
optimizations a CPU with AES_NI is required. This includes Intel Westmere
|
||||
and newer and AMD equivalents. Further optimizations are available on some
|
||||
algoritms for CPUs with AVX and AVX2, Sandybridge and Haswell respectively.
|
||||
Intel Core2 and newer and AMD equivalents. Further optimizations are available
|
||||
on some algoritms for CPUs with AES, AVX, AVX2, SHA, AVX512 and VAES.
|
||||
|
||||
Older CPUs are supported by cpuminer-multi by TPruvot but at reduced
|
||||
performance.
|
||||
|
||||
ARM CPUs are not supported.
|
||||
ARM and Aarch64 CPUs are not supported.
|
||||
|
||||
2. 64 bit Linux OS. Ubuntu and Fedora based distributions, including Mint and
|
||||
Centos, are known to work and have all dependencies in their repositories.
|
||||
Others may work but may require more effort. Older versions such as Centos 6
|
||||
don't work due to missing features.
|
||||
2. 64 bit Linux or Windows OS. Ubuntu and Fedora based distributions,
|
||||
including Mint and Centos, are known to work and have all dependencies
|
||||
in their repositories. Others may work but may require more effort. Older
|
||||
versions such as Centos 6 don't work due to missing features.
|
||||
64 bit Windows OS is supported with mingw_w64 and msys or pre-built binaries.
|
||||
|
||||
MacOS, OSx and Android are not supported.
|
||||
|
||||
3. Stratum pool. Some algos may work wallet mining using getwork or GBT. YMMV.
|
||||
3. Stratum pool supporting stratum+tcp:// or stratum+ssl:// protocols or
|
||||
RPC getwork using http:// or https://.
|
||||
GBT is YMMV.
|
||||
|
||||
Supported Algorithms
|
||||
--------------------
|
||||
@@ -152,6 +152,27 @@ Supported Algorithms
|
||||
yespower-b2b generic yespower + blake2b
|
||||
zr5 Ziftr
|
||||
|
||||
Many variations of scrypt based algos can be mine by specifying their
|
||||
parameters:
|
||||
|
||||
scryptn2: --algo scrypt --param-n 1048576
|
||||
|
||||
cpupower: --algo yespower --param-key "CPUpower: The number of CPU working or available for proof-of-work mining"
|
||||
|
||||
power2b: --algo yespower-b2b --param-n 2048 --param-r 32 --param-key "Now I am become Death, the destroyer of worlds"
|
||||
|
||||
sugarchain: --algo yespower --param-n 2048 -param-r 32 --param-key "Satoshi Nakamoto 31/Oct/2008 Proof-of-work is essentially one-CPU-one-vote"
|
||||
|
||||
yespoweriots: --algo yespower --param-n 2048 --param-key "Iots is committed to the development of IOT"
|
||||
|
||||
yespowerlitb: --algo yespower --param-n 2048 --param-r 32 --param-key "LITBpower: The number of LITB working or available for proof-of-work mini"
|
||||
|
||||
yespoweric: --algo yespower --param-n 2048 --param-r 32 --param-key "IsotopeC"
|
||||
|
||||
yespowerurx: --algo yespower --param-n 2048 --param-r 32 --param-key "UraniumX"
|
||||
|
||||
yespowerltncg: --algo yespower --param-n 2048 --param-r 32 --param-key "LTNCGYES"
|
||||
|
||||
Errata
|
||||
------
|
||||
|
||||
|
@@ -65,6 +65,45 @@ If not what makes it happen or not happen?
|
||||
Change Log
|
||||
----------
|
||||
|
||||
v3.12.6
|
||||
|
||||
Issue #246: improved stale share detection for getwork.
|
||||
|
||||
Improved precision of target_to_diff conversion from 4 digits to 20+.
|
||||
|
||||
Display hash and target debug data for all rejected shares.
|
||||
|
||||
A graphical representation of CPU affinity is displayed when using --threads.
|
||||
|
||||
Added highest and lowest accepted share to summary log.
|
||||
|
||||
Other small changes to logs to improve consistency and clarity.
|
||||
|
||||
v3.12.5
|
||||
|
||||
Issues #246 & #251: fixed incorrect share diff for stratum and getwork,
|
||||
fixed incorrect target diff for getwork. Stats should now be correct for
|
||||
getwork as well as stratum.
|
||||
|
||||
Getwork: reduce stale blocks, faster response to new work.
|
||||
|
||||
Added ntime to new job/work logs.
|
||||
|
||||
README.md now lists the parameters for yespower variations that don't have
|
||||
a specific algo name.
|
||||
|
||||
v3.12.4.6
|
||||
|
||||
Issue #246: fixed getwork repeated new block logs with same height. New work
|
||||
for the same block is now reported as "New work" instead of New block".
|
||||
Also added a check that work is new before generating "New work" log.
|
||||
|
||||
Added target diff to getwork new block log.
|
||||
|
||||
Changed share ratio in share result log to simple fraction, no longer %.
|
||||
|
||||
Added debug log to display mininginfo, use -D.
|
||||
|
||||
v3.12.4.5
|
||||
|
||||
Issue #246: better stale share detection for getwork, and enhanced logging
|
||||
|
@@ -311,7 +311,7 @@ bool register_m7m_algo( algo_gate_t *gate )
|
||||
{
|
||||
gate->optimizations = SHA_OPT;
|
||||
init_m7m_ctx();
|
||||
gate->scanhash = (void*)scanhash_m7m_hash;
|
||||
gate->scanhash = (void*)&scanhash_m7m_hash;
|
||||
gate->build_stratum_request = (void*)&std_be_build_stratum_request;
|
||||
gate->work_decode = (void*)&std_be_work_decode;
|
||||
gate->submit_getwork_result = (void*)&std_be_submit_getwork_result;
|
||||
|
@@ -706,13 +706,13 @@ extern int scanhash_scrypt( struct work *work, uint32_t max_nonce,
|
||||
if ( rc )
|
||||
for ( i = 0; i < throughput; i++ )
|
||||
{
|
||||
if ( unlikely( valid_hash( hash + i * 8, ptarget ) ) )
|
||||
if ( unlikely( valid_hash( hash + i * 8, ptarget ) ) )
|
||||
{
|
||||
pdata[19] = data[i * 20 + 19];
|
||||
test_hash_and_submit( work, hash, mythr );
|
||||
// submit_lane_solution( work, hash, mythr, i );
|
||||
submit_solution( work, hash + i * 8, mythr );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} while ( likely( ( n < ( max_nonce - throughput ) ) && !(*restart) ) );
|
||||
|
||||
*hashes_done = n - pdata[19];
|
||||
|
20
configure
vendored
20
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.12.4.5.
|
||||
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.12.6.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
@@ -577,8 +577,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='cpuminer-opt'
|
||||
PACKAGE_TARNAME='cpuminer-opt'
|
||||
PACKAGE_VERSION='3.12.4.5'
|
||||
PACKAGE_STRING='cpuminer-opt 3.12.4.5'
|
||||
PACKAGE_VERSION='3.12.6'
|
||||
PACKAGE_STRING='cpuminer-opt 3.12.6'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1332,7 +1332,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures cpuminer-opt 3.12.4.5 to adapt to many kinds of systems.
|
||||
\`configure' configures cpuminer-opt 3.12.6 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1404,7 +1404,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of cpuminer-opt 3.12.4.5:";;
|
||||
short | recursive ) echo "Configuration of cpuminer-opt 3.12.6:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1509,7 +1509,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
cpuminer-opt configure 3.12.4.5
|
||||
cpuminer-opt configure 3.12.6
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by cpuminer-opt $as_me 3.12.4.5, which was
|
||||
It was created by cpuminer-opt $as_me 3.12.6, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2993,7 +2993,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='cpuminer-opt'
|
||||
VERSION='3.12.4.5'
|
||||
VERSION='3.12.6'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@@ -6690,7 +6690,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by cpuminer-opt $as_me 3.12.4.5, which was
|
||||
This file was extended by cpuminer-opt $as_me 3.12.6, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -6756,7 +6756,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
cpuminer-opt config.status 3.12.4.5
|
||||
cpuminer-opt config.status 3.12.6
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
AC_INIT([cpuminer-opt], [3.12.4.5])
|
||||
AC_INIT([cpuminer-opt], [3.12.6])
|
||||
|
||||
AC_PREREQ([2.59c])
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
472
cpu-miner.c
472
cpu-miner.c
@@ -102,6 +102,7 @@ static int opt_fail_pause = 10;
|
||||
static int opt_time_limit = 0;
|
||||
int opt_timeout = 300;
|
||||
static int opt_scantime = 5;
|
||||
const int min_scantime = 1;
|
||||
//static const bool opt_time = true;
|
||||
enum algos opt_algo = ALGO_NULL;
|
||||
char* opt_param_key = NULL;
|
||||
@@ -160,7 +161,7 @@ uint32_t rejected_share_count = 0;
|
||||
uint32_t stale_share_count = 0;
|
||||
uint32_t solved_block_count = 0;
|
||||
double *thr_hashrates;
|
||||
double global_hashrate = 0;
|
||||
double global_hashrate = 0.;
|
||||
double stratum_diff = 0.;
|
||||
double net_diff = 0.;
|
||||
double net_hashrate = 0.;
|
||||
@@ -194,6 +195,8 @@ static uint64_t stale_sum = 0;
|
||||
static uint64_t reject_sum = 0;
|
||||
static double norm_diff_sum = 0.;
|
||||
static uint32_t last_block_height = 0;
|
||||
static double highest_share = 0; // all shares include discard and reject
|
||||
static double lowest_share = 9e99; // lowest accepted
|
||||
//static bool new_job = false;
|
||||
static double last_targetdiff = 0.;
|
||||
#if !(defined(__WINDOWS__) || defined(_WIN64) || defined(_WIN32))
|
||||
@@ -216,6 +219,20 @@ char* lp_id;
|
||||
|
||||
static void workio_cmd_free(struct workio_cmd *wc);
|
||||
|
||||
static void format_affinity_map( char *map_str, uint64_t map )
|
||||
{
|
||||
int n = num_cpus < 64 ? num_cpus : 64;
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
if ( map & 1 ) map_str[i] = '!';
|
||||
else map_str[i] = '.';
|
||||
map >>= 1;
|
||||
}
|
||||
memset( &map_str[i], 0, 64 - i );
|
||||
}
|
||||
|
||||
#ifdef __linux /* Linux specific policy and affinity management */
|
||||
#include <sched.h>
|
||||
|
||||
@@ -436,9 +453,6 @@ static bool work_decode( const json_t *val, struct work *work )
|
||||
if ( !allow_mininginfo )
|
||||
net_diff = algo_gate.calc_network_diff( work );
|
||||
work->targetdiff = target_to_diff( work->target );
|
||||
// for api stats, on longpoll pools
|
||||
// This needs cleanup, stratum_diff doean't apply solo mining
|
||||
// and targetdiff is redundant, same as net_diff.
|
||||
stratum_diff = last_targetdiff = work->targetdiff;
|
||||
work->sharediff = 0;
|
||||
algo_gate.decode_extra_data( work, &net_blocks );
|
||||
@@ -489,6 +503,10 @@ static bool get_mininginfo( CURL *curl, struct work *work )
|
||||
if ( key && json_is_integer( key ) )
|
||||
net_blocks = json_integer_value( key );
|
||||
|
||||
if ( opt_debug )
|
||||
applog(LOG_INFO,"Mining info: diff %.5g, net_hashrate %f, height %d",
|
||||
net_diff, net_hashrate, net_blocks );
|
||||
|
||||
if ( !work->height )
|
||||
{
|
||||
// complete missing data from getwork
|
||||
@@ -891,6 +909,7 @@ static inline void sprintf_et( char *str, int seconds )
|
||||
}
|
||||
|
||||
const double exp32 = 4294967296.; // 2**32
|
||||
const double exp48 = 4294967296. * 65536.; // 2**48
|
||||
const double exp64 = 4294967296. * 4294967296.; // 2**64
|
||||
|
||||
struct share_stats_t
|
||||
@@ -935,6 +954,7 @@ void report_summary_log( bool force )
|
||||
uint64_t accepts = accept_sum; accept_sum = 0;
|
||||
uint64_t rejects = reject_sum; reject_sum = 0;
|
||||
uint64_t stales = stale_sum; stale_sum = 0;
|
||||
|
||||
memcpy( &start_time, &five_min_start, sizeof start_time );
|
||||
memcpy( &five_min_start, &now, sizeof now );
|
||||
|
||||
@@ -945,12 +965,10 @@ void report_summary_log( bool force )
|
||||
|
||||
double share_time = (double)et.tv_sec + (double)et.tv_usec / 1e6;
|
||||
double ghrate = global_hashrate;
|
||||
|
||||
double shrate = share_time == 0. ? 0. : exp32 * last_targetdiff
|
||||
* (double)(accepts) / share_time;
|
||||
double sess_hrate = uptime.tv_sec == 0. ? 0. : exp32 * norm_diff_sum
|
||||
/ (double)uptime.tv_sec;
|
||||
|
||||
double submit_rate = share_time == 0. ? 0. : (double)submits*60. / share_time;
|
||||
char shr_units[4] = {0};
|
||||
char ghr_units[4] = {0};
|
||||
@@ -976,7 +994,7 @@ void report_summary_log( bool force )
|
||||
|
||||
if ( accepted_share_count < submitted_share_count )
|
||||
{
|
||||
double lost_ghrate = uptime.tv_sec == 0. ? 0.
|
||||
double lost_ghrate = uptime.tv_sec == 0 ? 0.
|
||||
: exp32 * last_targetdiff
|
||||
* (double)(submitted_share_count - accepted_share_count )
|
||||
/ (double)uptime.tv_sec;
|
||||
@@ -1002,8 +1020,11 @@ void report_summary_log( bool force )
|
||||
applog2( LOG_INFO,"Rejected %6d %6d",
|
||||
rejects, rejected_share_count );
|
||||
if ( solved_block_count )
|
||||
applog2( LOG_INFO,"Blocks solved %6d",
|
||||
applog2( LOG_INFO,"Blocks Solved %6d",
|
||||
solved_block_count );
|
||||
applog2( LOG_INFO, "Hi/Lo Share Diff %.5g / %.5g",
|
||||
highest_share, lowest_share );
|
||||
|
||||
}
|
||||
|
||||
bool lowdiff_debug = false;
|
||||
@@ -1053,11 +1074,15 @@ static int share_result( int result, struct work *work,
|
||||
}
|
||||
|
||||
share_ratio = my_stats.net_diff == 0. ? 0. : my_stats.share_diff /
|
||||
my_stats.net_diff * 100.;
|
||||
my_stats.net_diff;
|
||||
// check result
|
||||
if ( likely( result ) )
|
||||
{
|
||||
accepted_share_count++;
|
||||
if ( my_stats.share_diff < lowest_share )
|
||||
lowest_share = my_stats.share_diff;
|
||||
if ( my_stats.share_diff > highest_share )
|
||||
highest_share = my_stats.share_diff;
|
||||
sprintf( sres, "S%d", stale_share_count );
|
||||
sprintf( rres, "R%d", rejected_share_count );
|
||||
if unlikely( ( my_stats.net_diff > 0. )
|
||||
@@ -1078,7 +1103,8 @@ static int share_result( int result, struct work *work,
|
||||
{
|
||||
sprintf( ares, "A%d", accepted_share_count );
|
||||
sprintf( bres, "B%d", solved_block_count );
|
||||
if ( work ) stale = work->stale;
|
||||
stale = work ? work->data[ algo_gate.ntime_index ]
|
||||
!= g_work.data[ algo_gate.ntime_index ] : false;
|
||||
if ( reason ) stale = stale || strstr( reason, "Invalid job id" );
|
||||
if ( stale )
|
||||
{
|
||||
@@ -1091,7 +1117,7 @@ static int share_result( int result, struct work *work,
|
||||
rejected_share_count++;
|
||||
sprintf( sres, "S%d", stale_share_count );
|
||||
sprintf( rres, "Rejected %d" , rejected_share_count );
|
||||
lowdiff_debug = true;
|
||||
// lowdiff_debug = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,41 +1164,38 @@ static int share_result( int result, struct work *work,
|
||||
if ( !opt_quiet )
|
||||
{
|
||||
if ( have_stratum )
|
||||
applog2( LOG_INFO, "Diff %.5g (%.3g%), %sBlock %d, %sJob %s",
|
||||
applog2( LOG_INFO, "Diff %.5g (%.3g), %sBlock %d" CL_N ", %sJob %s",
|
||||
my_stats.share_diff, share_ratio, bcol, stratum.block_height,
|
||||
scol, my_stats.job_id );
|
||||
else
|
||||
applog2( LOG_INFO, "Diff %.5g (%.3g%), %sBlock %d",
|
||||
my_stats.share_diff, share_ratio, bcol, stratum.block_height );
|
||||
{
|
||||
uint64_t height = work ? work->height : last_block_height;
|
||||
applog2( LOG_INFO, "Diff %.5g (%.3g), %sBlock %d",
|
||||
my_stats.share_diff, share_ratio, bcol, height );
|
||||
}
|
||||
}
|
||||
|
||||
if ( unlikely( reason && !result ) )
|
||||
if ( unlikely( opt_debug || !( opt_quiet || result || stale ) ) )
|
||||
{
|
||||
if ( !( opt_quiet || stale ) )
|
||||
{
|
||||
uint32_t str[8];
|
||||
|
||||
if ( reason )
|
||||
applog( LOG_WARNING, "Reject reason: %s", reason );
|
||||
|
||||
uint32_t str1[8], str2[8];
|
||||
char str3[65];
|
||||
|
||||
// display share hash and target for troubleshooting
|
||||
diff_to_target( str1, my_stats.share_diff );
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
be32enc( str2 + i, str1[7 - i] );
|
||||
bin2hex( str3, (unsigned char*)str2, 12 );
|
||||
applog2( LOG_INFO, "Share diff: %.5g, Hash: %s...",
|
||||
my_stats.share_diff, str3 );
|
||||
|
||||
diff_to_target( str1, my_stats.target_diff );
|
||||
for ( int i = 0; i < 8; i++ )
|
||||
be32enc( str2 + i, str1[7 - i] );
|
||||
bin2hex( str3, (unsigned char*)str2, 12 );
|
||||
applog2( LOG_INFO, "Target diff: %.5g, Targ: %s...",
|
||||
my_stats.target_diff, str3 );
|
||||
|
||||
// display share hash and target for troubleshooting
|
||||
diff_to_target( str, my_stats.share_diff );
|
||||
applog2( LOG_INFO, "Hash: %08x%08x%08x%08x...",
|
||||
str[7], str[6], str[5], str[4] );
|
||||
uint32_t *targ;
|
||||
if ( work )
|
||||
targ = work->target;
|
||||
else
|
||||
{
|
||||
diff_to_target( str, my_stats.target_diff );
|
||||
targ = &str[0];
|
||||
}
|
||||
|
||||
if ( unlikely( opt_reset_on_stale && stale ) )
|
||||
stratum_need_reset = true;
|
||||
applog2( LOG_INFO, "Target: %08x%08x%08x%08x...",
|
||||
targ[7], targ[6], targ[5], targ[4] );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1318,30 +1341,6 @@ char* std_malloc_txs_request( struct work *work )
|
||||
|
||||
static bool submit_upstream_work( CURL *curl, struct work *work )
|
||||
{
|
||||
work->stale = false;
|
||||
// Submit anyway, discardring here messes up the stats
|
||||
if ( !have_stratum && allow_mininginfo )
|
||||
{
|
||||
struct work mining_info;
|
||||
get_mininginfo( curl, &mining_info );
|
||||
if ( work->height < mining_info.height )
|
||||
{
|
||||
if ( !opt_quiet )
|
||||
applog( LOG_WARNING, "Block %u already solved, current block %d",
|
||||
work->height, mining_info.height );
|
||||
work->stale = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* pass if the previous hash is not the current previous hash */
|
||||
if ( !( work->stale || submit_old )
|
||||
&& memcmp( &work->data[1], &g_work.data[1], 32 ) )
|
||||
{
|
||||
if ( !opt_quiet )
|
||||
applog( LOG_WARNING, "Stale work detected, submitting anyway" );
|
||||
work->stale = true;
|
||||
}
|
||||
|
||||
if ( have_stratum )
|
||||
{
|
||||
char req[JSON_BUF_LEN];
|
||||
@@ -1462,47 +1461,61 @@ start:
|
||||
else
|
||||
rc = work_decode( json_object_get( val, "result" ), work );
|
||||
|
||||
if ( opt_protocol && rc )
|
||||
if ( rc )
|
||||
{
|
||||
timeval_subtract( &diff, &tv_end, &tv_start );
|
||||
applog( LOG_DEBUG, "got new work in %.2f ms",
|
||||
( 1000.0 * diff.tv_sec ) + ( 0.001 * diff.tv_usec ) );
|
||||
}
|
||||
|
||||
json_decref( val );
|
||||
// store work height in solo
|
||||
get_mininginfo(curl, work);
|
||||
|
||||
applog( LOG_BLUE, "New block %d, diff %.5g", work->height, net_diff );
|
||||
|
||||
if ( !opt_quiet && net_diff && net_hashrate )
|
||||
{
|
||||
double miner_hr = 0.;
|
||||
pthread_mutex_lock( &stats_lock );
|
||||
|
||||
for ( int i = 0; i < opt_n_threads; i++ )
|
||||
miner_hr += thr_hashrates[i];
|
||||
global_hashrate = miner_hr;
|
||||
|
||||
pthread_mutex_unlock( &stats_lock );
|
||||
|
||||
if ( miner_hr )
|
||||
if ( opt_protocol )
|
||||
{
|
||||
double net_hr = net_hashrate;
|
||||
char net_hr_units[4] = {0};
|
||||
char miner_hr_units[4] = {0};
|
||||
char net_ttf[32];
|
||||
char miner_ttf[32];
|
||||
|
||||
sprintf_et( net_ttf, net_diff * exp32 / net_hr );
|
||||
sprintf_et( miner_ttf, net_diff * exp32 / miner_hr );
|
||||
scale_hash_for_display ( &miner_hr, miner_hr_units );
|
||||
scale_hash_for_display ( &net_hr, net_hr_units );
|
||||
applog2(LOG_INFO, "Miner TTF @ %.2f %sh/s %s, net TTF @ %.2f %sh/s %s",
|
||||
miner_hr, miner_hr_units, miner_ttf,
|
||||
net_hr, net_hr_units, net_ttf );
|
||||
timeval_subtract( &diff, &tv_end, &tv_start );
|
||||
applog( LOG_DEBUG, "got new work in %.2f ms",
|
||||
( 1000.0 * diff.tv_sec ) + ( 0.001 * diff.tv_usec ) );
|
||||
}
|
||||
}
|
||||
|
||||
json_decref( val );
|
||||
// store work height in solo
|
||||
get_mininginfo(curl, work);
|
||||
|
||||
if ( work->height > last_block_height )
|
||||
{
|
||||
last_block_height = work->height;
|
||||
applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Target Diff %.5g, Ntime %08x",
|
||||
work->height, net_diff, work->targetdiff,
|
||||
bswap_32( work->data[ algo_gate.ntime_index ] ) );
|
||||
|
||||
if ( !opt_quiet && net_diff && net_hashrate )
|
||||
{
|
||||
double miner_hr = 0.;
|
||||
pthread_mutex_lock( &stats_lock );
|
||||
|
||||
for ( int i = 0; i < opt_n_threads; i++ )
|
||||
miner_hr += thr_hashrates[i];
|
||||
global_hashrate = miner_hr;
|
||||
|
||||
pthread_mutex_unlock( &stats_lock );
|
||||
|
||||
if ( miner_hr )
|
||||
{
|
||||
double net_hr = net_hashrate;
|
||||
char net_hr_units[4] = {0};
|
||||
char miner_hr_units[4] = {0};
|
||||
char net_ttf[32];
|
||||
char miner_ttf[32];
|
||||
|
||||
sprintf_et( net_ttf, ( work->targetdiff * exp32 ) / net_hr );
|
||||
sprintf_et( miner_ttf, ( work->targetdiff * exp32 ) / miner_hr );
|
||||
scale_hash_for_display ( &miner_hr, miner_hr_units );
|
||||
scale_hash_for_display ( &net_hr, net_hr_units );
|
||||
applog2( LOG_INFO,
|
||||
"Miner TTF @ %.2f %sh/s %s, Net TTF @ %.2f %sh/s %s",
|
||||
miner_hr, miner_hr_units, miner_ttf,
|
||||
net_hr, net_hr_units, net_ttf );
|
||||
}
|
||||
}
|
||||
} // work->height > last_block_height
|
||||
else if ( memcmp( &work->data[1], &g_work.data[1], 32 ) )
|
||||
applog( LOG_BLUE, "New Work, Ntime %08lx",
|
||||
bswap_32( work->data[ algo_gate.ntime_index ] ) );
|
||||
} // rc
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1553,8 +1566,6 @@ static bool workio_get_work( struct workio_cmd *wc, CURL *curl )
|
||||
if ( !tq_push(wc->thr->q, ret_work ) )
|
||||
free( ret_work );
|
||||
|
||||
report_summary_log( false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1697,13 +1708,14 @@ err_out:
|
||||
// double precision floating point with 15 decimal digits precision.
|
||||
static inline double u256_to_double( const uint64_t *u )
|
||||
{
|
||||
const double exp64 = 4294967296.0 * 4294967296.0; // 2**64
|
||||
return ( ( u[3] * exp64 + u[2] ) * exp64 + u[1] ) * exp64 + u[0];
|
||||
}
|
||||
*/
|
||||
|
||||
static void update_submit_stats( struct work *work, const void *hash )
|
||||
{
|
||||
// work->sharediff = hash ? exp32 / ( (uint64_t*)hash )[3] : 0.;
|
||||
|
||||
pthread_mutex_lock( &stats_lock );
|
||||
|
||||
submitted_share_count++;
|
||||
@@ -1720,57 +1732,28 @@ static void update_submit_stats( struct work *work, const void *hash )
|
||||
pthread_mutex_unlock( &stats_lock );
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void work_set_target_ratio( struct work* work, const void *hash )
|
||||
{
|
||||
submitted_share_count++;
|
||||
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
|
||||
/ (double)( ((uint64_t*)work->target)[3] );
|
||||
// work->sharediff = likely( hash ) ? target_to_diff( (uint32_t*)hash ) : 0.;
|
||||
|
||||
// collect some share stats
|
||||
// Frequent share submission combined with high latency can caused
|
||||
// shares to be submitted faster than they are acked. If severe enough
|
||||
// it can overflow the queue and overwrite stats for a share.
|
||||
pthread_mutex_lock( &stats_lock );
|
||||
|
||||
share_stats[ s_put_ptr ].share_count = submitted_share_count;
|
||||
gettimeofday( &share_stats[ s_put_ptr ].submit_time, NULL );
|
||||
share_stats[ s_put_ptr ].share_diff = work->sharediff;
|
||||
share_stats[ s_put_ptr ].net_diff = net_diff;
|
||||
share_stats[ s_put_ptr ].stratum_diff = stratum_diff;
|
||||
share_stats[ s_put_ptr ].target_diff = work->targetdiff;
|
||||
if ( have_stratum )
|
||||
strncpy( share_stats[ s_put_ptr ].job_id, work->job_id, 30 );
|
||||
s_put_ptr = stats_ptr_incr( s_put_ptr );
|
||||
|
||||
pthread_mutex_unlock( &stats_lock );
|
||||
}
|
||||
|
||||
bool submit_solution( struct work *work, const void *hash,
|
||||
struct thr_info *thr )
|
||||
{
|
||||
if ( likely( submit_work( thr, work ) ) )
|
||||
work->sharediff = hash ? exp32 / ( (uint64_t*)hash )[3] : 0.;
|
||||
|
||||
if ( likely( submit_work( thr, work ) ) )
|
||||
{
|
||||
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
|
||||
/ (double)( ((uint64_t*)work->target)[3] );
|
||||
// work->sharediff = likely( hash ) ? target_to_diff( (uint32_t*)hash ) : 0.;
|
||||
update_submit_stats( work, hash );
|
||||
// submitted_share_count++;
|
||||
// work_set_target_ratio( work, hash );
|
||||
|
||||
if ( !opt_quiet )
|
||||
{
|
||||
if ( have_stratum )
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d, job %s",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->job_id );
|
||||
else
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d",
|
||||
submitted_share_count, work->sharediff, work->height );
|
||||
if ( have_stratum )
|
||||
applog( LOG_NOTICE, "%d Submitted Diff %.5g, Block %d, Job %s",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->job_id );
|
||||
else
|
||||
applog( LOG_NOTICE, "%d Submitted Diff %.5g, Block %d, Ntime %08x",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->data[ algo_gate.ntime_index ] );
|
||||
}
|
||||
|
||||
if ( lowdiff_debug )
|
||||
if ( unlikely( lowdiff_debug ) )
|
||||
{
|
||||
uint32_t* h = (uint32_t*)hash;
|
||||
uint32_t* t = (uint32_t*)work->target;
|
||||
@@ -1782,32 +1765,30 @@ bool submit_solution( struct work *work, const void *hash,
|
||||
return true;
|
||||
}
|
||||
else
|
||||
applog( LOG_WARNING, "%d failed to submit share, thread %d",
|
||||
submitted_share_count, thr->id );
|
||||
applog( LOG_WARNING, "%d failed to submit share", submitted_share_count );
|
||||
return false;
|
||||
}
|
||||
|
||||
// deprecated, use submit_solution
|
||||
bool submit_lane_solution( struct work *work, const void *hash,
|
||||
struct thr_info *thr, const int lane )
|
||||
{
|
||||
if ( likely( submit_work( thr, work ) ) )
|
||||
{
|
||||
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
|
||||
/ (double)( ((uint64_t*)work->target)[3] );
|
||||
// work->sharediff = likely( hash ) ? target_to_diff( (uint32_t*)hash ) : 0.;
|
||||
work->sharediff = hash ? exp32 / ( (uint64_t*)hash )[3] : 0.;
|
||||
|
||||
if ( likely( submit_work( thr, work ) ) )
|
||||
{
|
||||
update_submit_stats( work, hash );
|
||||
// submitted_share_count++;
|
||||
// work_set_target_ratio( work, hash );
|
||||
|
||||
if ( !opt_quiet )
|
||||
{
|
||||
if ( have_stratum )
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d, job %s",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->job_id );
|
||||
else
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d",
|
||||
submitted_share_count, work->sharediff, work->height );
|
||||
if ( have_stratum )
|
||||
applog( LOG_NOTICE, "%d Submitted Diff %.5g, Block %d, Job %s",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->job_id );
|
||||
else
|
||||
applog( LOG_NOTICE, "%d Submitted Diff %.5g, Block %d, Ntime %08x",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->data[ algo_gate.ntime_index ] );
|
||||
}
|
||||
|
||||
if ( lowdiff_debug )
|
||||
@@ -1822,55 +1803,11 @@ bool submit_lane_solution( struct work *work, const void *hash,
|
||||
return true;
|
||||
}
|
||||
else
|
||||
applog( LOG_WARNING, "%d failed to submit share, thread %d, lane %d",
|
||||
submitted_share_count, thr->id, lane );
|
||||
applog( LOG_WARNING, "%d failed to submit share", submitted_share_count );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// The new way, replaces fulltest and submit_solution
|
||||
bool test_hash_and_submit( struct work *work, const void *hash,
|
||||
struct thr_info *thr )
|
||||
{
|
||||
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
|
||||
/ (double)( ((uint64_t*)work->target)[3] );
|
||||
|
||||
// work->sharediff = likely( hash ) ? target_to_diff( (uint32_t*)hash ) : 0.;
|
||||
if ( work->sharediff >= work->targetdiff )
|
||||
{
|
||||
if ( likely( submit_work( thr, work ) ) )
|
||||
{
|
||||
update_submit_stats( work, hash );
|
||||
|
||||
if ( !opt_quiet )
|
||||
{
|
||||
if ( have_stratum )
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d, job %s",
|
||||
submitted_share_count, work->sharediff, work->height,
|
||||
work->job_id );
|
||||
else
|
||||
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d",
|
||||
submitted_share_count, work->sharediff, work->height );
|
||||
}
|
||||
|
||||
if ( lowdiff_debug )
|
||||
{
|
||||
uint32_t* h = (uint32_t*)hash;
|
||||
uint32_t* t = (uint32_t*)work->target;
|
||||
applog(LOG_INFO,"Hash[7:0]: %08x %08x %08x %08x %08x %08x %08x %08x",
|
||||
h[7],h[6],h[5],h[4],h[3],h[2],h[1],h[0]);
|
||||
applog(LOG_INFO,"Targ[7:0]: %08x %08x %08x %08x %08x %08x %08x %08x",
|
||||
t[7],t[6],t[5],t[4],t[3],t[2],t[1],t[0]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
applog( LOG_WARNING, "%d failed to submit share, thread %d",
|
||||
submitted_share_count, thr->id );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wanna_mine(int thr_id)
|
||||
{
|
||||
bool state = true;
|
||||
@@ -2020,6 +1957,8 @@ static void *miner_thread( void *userdata )
|
||||
if (!opt_benchmark && opt_priority == 0)
|
||||
{
|
||||
setpriority(PRIO_PROCESS, 0, 19);
|
||||
if ( !thr_id && !opt_quiet )
|
||||
applog(LOG_INFO, "Miner thread priority %d (nice 19)", opt_priority );
|
||||
drop_policy();
|
||||
}
|
||||
else
|
||||
@@ -2036,9 +1975,9 @@ static void *miner_thread( void *userdata )
|
||||
case 4: prio = -10; break;
|
||||
case 5: prio = -15;
|
||||
}
|
||||
if (opt_debug)
|
||||
applog(LOG_DEBUG, "Thread %d priority %d (nice %d)", thr_id,
|
||||
opt_priority, prio );
|
||||
if ( !( thr_id || opt_quiet ) )
|
||||
applog( LOG_INFO, "Miner thread priority %d (nice %d)",
|
||||
opt_priority, prio );
|
||||
#endif
|
||||
setpriority(PRIO_PROCESS, 0, prio);
|
||||
if ( opt_priority == 0 )
|
||||
@@ -2117,13 +2056,13 @@ static void *miner_thread( void *userdata )
|
||||
}
|
||||
else
|
||||
{
|
||||
int min_scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
|
||||
int scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
|
||||
pthread_mutex_lock( &g_work_lock );
|
||||
|
||||
if ( time(NULL) - g_work_time >= min_scantime
|
||||
if ( time(NULL) - g_work_time >= scantime
|
||||
|| *nonceptr >= end_nonce )
|
||||
{
|
||||
if ( unlikely( !get_work( mythr, &g_work ) ) )
|
||||
if ( unlikely( !get_work( mythr, &g_work ) ) )
|
||||
{
|
||||
applog( LOG_ERR, "work retrieval failed, exiting "
|
||||
"mining thread %d", thr_id );
|
||||
@@ -2131,7 +2070,8 @@ static void *miner_thread( void *userdata )
|
||||
goto out;
|
||||
}
|
||||
g_work_time = time(NULL);
|
||||
}
|
||||
restart_threads();
|
||||
}
|
||||
algo_gate.get_new_work( &work, &g_work, thr_id, &end_nonce );
|
||||
|
||||
pthread_mutex_unlock( &g_work_lock );
|
||||
@@ -2598,10 +2538,8 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
algo_gate.set_work_data_endian( g_work );
|
||||
g_work->height = sctx->block_height;
|
||||
g_work->targetdiff = sctx->job.diff
|
||||
/ ( opt_target_factor * opt_diff_factor );
|
||||
/ ( opt_target_factor * opt_diff_factor );
|
||||
diff_to_target( g_work->target, g_work->targetdiff );
|
||||
// work_set_target( g_work, sctx->job.diff
|
||||
// / ( opt_target_factor * opt_diff_factor ) );
|
||||
|
||||
pthread_mutex_unlock( &sctx->work_lock );
|
||||
|
||||
@@ -2625,13 +2563,13 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
pthread_mutex_unlock( &stats_lock );
|
||||
|
||||
if ( stratum_diff != sctx->job.diff )
|
||||
applog( LOG_BLUE, "New stratum diff %g, block %d, job %s",
|
||||
applog( LOG_BLUE, "New Diff %g, Block %d, Job %s",
|
||||
sctx->job.diff, sctx->block_height, g_work->job_id );
|
||||
else if ( last_block_height != sctx->block_height )
|
||||
applog( LOG_BLUE, "New block %d, job %s",
|
||||
sctx->block_height, g_work->job_id );
|
||||
applog( LOG_BLUE, "New Block %d, Job %s",
|
||||
sctx->block_height, g_work->job_id );
|
||||
else if ( g_work->job_id )
|
||||
applog( LOG_BLUE,"New job %s", g_work->job_id );
|
||||
applog( LOG_BLUE,"New Job %s", g_work->job_id );
|
||||
|
||||
// Update data and calculate new estimates.
|
||||
if ( ( stratum_diff != sctx->job.diff )
|
||||
@@ -2648,7 +2586,7 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
if ( !opt_quiet )
|
||||
{
|
||||
applog2( LOG_INFO, "Diff: Net %.5g, Stratum %.5g, Target %.5g",
|
||||
net_diff, stratum_diff, last_targetdiff );
|
||||
net_diff, stratum_diff, g_work->targetdiff );
|
||||
|
||||
if ( likely( hr > 0. ) )
|
||||
{
|
||||
@@ -2656,10 +2594,10 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
char block_ttf[32];
|
||||
char share_ttf[32];
|
||||
|
||||
sprintf_et( block_ttf, net_diff * exp32 / hr );
|
||||
sprintf_et( share_ttf, last_targetdiff * exp32 / hr );
|
||||
sprintf_et( block_ttf, ( net_diff * exp32 ) / hr );
|
||||
sprintf_et( share_ttf, g_work->targetdiff * exp32 / hr );
|
||||
scale_hash_for_display ( &hr, hr_units );
|
||||
applog2( LOG_INFO, "TTF @ %.2f %sh/s: block %s, share %s",
|
||||
applog2( LOG_INFO, "TTF @ %.2f %sh/s: Block %s, Share %s",
|
||||
hr, hr_units, block_ttf, share_ttf );
|
||||
|
||||
if ( !multipool && last_block_height > session_first_block )
|
||||
@@ -2673,13 +2611,13 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
if ( net_diff && net_ttf )
|
||||
{
|
||||
double net_hr = net_diff * exp32 / net_ttf;
|
||||
char net_ttf_str[32];
|
||||
// char net_ttf_str[32];
|
||||
char net_hr_units[4] = {0};
|
||||
|
||||
sprintf_et( net_ttf_str, net_ttf );
|
||||
// sprintf_et( net_ttf_str, net_ttf );
|
||||
scale_hash_for_display ( &net_hr, net_hr_units );
|
||||
applog2( LOG_INFO, "Net TTF @ %.2f %sh/s: %s",
|
||||
net_hr, net_hr_units, net_ttf_str );
|
||||
applog2( LOG_INFO, "Net hash rate (est) %.2f %sh/s",
|
||||
net_hr, net_hr_units );
|
||||
}
|
||||
}
|
||||
} // hr > 0
|
||||
@@ -2690,12 +2628,12 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
|
||||
static void *stratum_thread(void *userdata )
|
||||
{
|
||||
struct thr_info *mythr = (struct thr_info *) userdata;
|
||||
char *s;
|
||||
char *s = NULL;
|
||||
|
||||
stratum.url = (char*) tq_pop(mythr->q, NULL);
|
||||
if (!stratum.url)
|
||||
goto out;
|
||||
applog( LOG_INFO, "Stratum connect %s", short_url );
|
||||
applog( LOG_BLUE, "Stratum connect %s", short_url );
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -2755,30 +2693,26 @@ static void *stratum_thread(void *userdata )
|
||||
restart_threads();
|
||||
}
|
||||
|
||||
if ( stratum_socket_full( &stratum, opt_timeout ) )
|
||||
if ( likely( stratum_socket_full( &stratum, opt_timeout ) ) )
|
||||
{
|
||||
s = stratum_recv_line(&stratum);
|
||||
if ( !s )
|
||||
if ( likely( s = stratum_recv_line( &stratum ) ) )
|
||||
{
|
||||
if ( likely( !stratum_handle_method( &stratum, s ) ) )
|
||||
stratum_handle_response( s );
|
||||
free( s );
|
||||
}
|
||||
else
|
||||
{
|
||||
applog(LOG_WARNING, "Stratum connection interrupted");
|
||||
stratum_disconnect( &stratum );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = NULL;
|
||||
applog(LOG_ERR, "Stratum connection timeout");
|
||||
stratum_disconnect( &stratum );
|
||||
}
|
||||
|
||||
if ( s )
|
||||
{
|
||||
if ( !stratum_handle_method( &stratum, s ) )
|
||||
stratum_handle_response( s );
|
||||
free( s );
|
||||
}
|
||||
else
|
||||
{
|
||||
// stratum_errors++;
|
||||
// check if this redundant
|
||||
stratum_disconnect( &stratum );
|
||||
}
|
||||
} // loop
|
||||
out:
|
||||
return NULL;
|
||||
@@ -3415,7 +3349,7 @@ bool check_cpu_capability ()
|
||||
" with VC++ 2013\n");
|
||||
#elif defined(__GNUC__)
|
||||
" with GCC");
|
||||
printf(" %d.%d.%d.\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
printf(" %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
#else
|
||||
printf(".\n");
|
||||
#endif
|
||||
@@ -3638,8 +3572,8 @@ int main(int argc, char *argv[])
|
||||
pthread_mutex_init( &stratum.work_lock, NULL );
|
||||
|
||||
flags = !opt_benchmark
|
||||
&& ( strncmp( rpc_url, "https:", 6 )
|
||||
|| strncasecmp(rpc_url, "stratum+tcps://", 15 ) )
|
||||
|| ( strncasecmp( rpc_url, "https:", 6 )
|
||||
&& strncasecmp( rpc_url, "stratum+tcps://", 15 ) )
|
||||
? ( CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL )
|
||||
: CURL_GLOBAL_ALL;
|
||||
if ( curl_global_init( flags ) )
|
||||
@@ -3682,26 +3616,29 @@ int main(int argc, char *argv[])
|
||||
if (opt_priority > 0)
|
||||
{
|
||||
DWORD prio = NORMAL_PRIORITY_CLASS;
|
||||
switch (opt_priority) {
|
||||
case 1:
|
||||
prio = BELOW_NORMAL_PRIORITY_CLASS;
|
||||
switch (opt_priority)
|
||||
{
|
||||
case 1:
|
||||
prio = BELOW_NORMAL_PRIORITY_CLASS;
|
||||
break;
|
||||
case 3:
|
||||
prio = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||
case 3:
|
||||
prio = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||
break;
|
||||
case 4:
|
||||
prio = HIGH_PRIORITY_CLASS;
|
||||
case 4:
|
||||
prio = HIGH_PRIORITY_CLASS;
|
||||
break;
|
||||
case 5:
|
||||
prio = REALTIME_PRIORITY_CLASS;
|
||||
case 5:
|
||||
prio = REALTIME_PRIORITY_CLASS;
|
||||
}
|
||||
SetPriorityClass(GetCurrentProcess(), prio);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
if ( num_cpus != opt_n_threads )
|
||||
applog( LOG_INFO,"%u CPU cores available, %u miner threads selected.",
|
||||
applog( LOG_INFO,"%u CPU cores available, %u miner threads selected",
|
||||
num_cpus, opt_n_threads );
|
||||
*/
|
||||
|
||||
// To be confirmed with more than 64 cpus
|
||||
if ( opt_affinity != -1 )
|
||||
@@ -3734,6 +3671,13 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
}
|
||||
|
||||
if ( !opt_quiet && ( opt_n_threads < num_cpus ) )
|
||||
{
|
||||
char affinity_map[64];
|
||||
format_affinity_map( affinity_map, opt_affinity );
|
||||
applog( LOG_INFO, "CPU affinity [%s]", affinity_map );
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
if (use_syslog)
|
||||
openlog("cpuminer", LOG_PID, LOG_USER);
|
||||
@@ -3850,13 +3794,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
applog(LOG_INFO, "%d miner threads started, "
|
||||
"using '%s' algorithm.",
|
||||
opt_n_threads,
|
||||
algo_names[opt_algo]);
|
||||
applog( LOG_INFO, "%d of %d miner threads started using '%s' algorithm",
|
||||
opt_n_threads, num_cpus, algo_names[opt_algo] );
|
||||
|
||||
/* main loop - simply wait for workio thread to exit */
|
||||
pthread_join(thr_info[work_thr_id].pth, NULL);
|
||||
applog(LOG_WARNING, "workio thread dead, exiting.");
|
||||
pthread_join( thr_info[work_thr_id].pth, NULL );
|
||||
applog( LOG_WARNING, "workio thread dead, exiting." );
|
||||
return 0;
|
||||
}
|
||||
|
10
miner.h
10
miner.h
@@ -323,6 +323,7 @@ int timeval_subtract( struct timeval *result, struct timeval *x,
|
||||
// diff_to_hash = 2**32 = 0x100000000 = 4294967296 = exp32;
|
||||
|
||||
const double exp32; // 2**32
|
||||
const double exp48; // 2**48
|
||||
const double exp64; // 2**64
|
||||
|
||||
bool fulltest( const uint32_t *hash, const uint32_t *target );
|
||||
@@ -345,13 +346,16 @@ struct thr_info {
|
||||
|
||||
//struct thr_info *thr_info;
|
||||
|
||||
void test_hash_and_submit( struct work *work, const void *hash,
|
||||
struct thr_info *thr );
|
||||
|
||||
bool submit_solution( struct work *work, const void *hash,
|
||||
struct thr_info *thr );
|
||||
|
||||
// deprecated
|
||||
bool submit_lane_solution( struct work *work, const void *hash,
|
||||
struct thr_info *thr, const int lane );
|
||||
|
||||
bool test_hash_and_submit( struct work*, const void*, struct thr_info* );
|
||||
|
||||
bool submit_work( struct thr_info *thr, const struct work *work_in );
|
||||
|
||||
|
||||
@@ -869,7 +873,7 @@ Options:\n\
|
||||
zr5 Ziftr\n\
|
||||
-N, --param-n N parameter for scrypt based algos\n\
|
||||
-R, --patam-r R parameter for scrypt based algos\n\
|
||||
-K, --param-key Key parameter for algos that use it\n\
|
||||
-K, --param-key Key (pers) parameter for algos that use it\n\
|
||||
-o, --url=URL URL of mining server\n\
|
||||
-O, --userpass=U:P username:password pair for mining server\n\
|
||||
-u, --user=USERNAME username for mining server\n\
|
||||
|
46
util.c
46
util.c
@@ -983,6 +983,7 @@ int timeval_subtract(struct timeval *result, struct timeval *x,
|
||||
return x->tv_sec < y->tv_sec;
|
||||
}
|
||||
|
||||
// deprecated, use test_hash_and_submit
|
||||
// Use this when deinterleaved
|
||||
// do 64 bit test 4 iterations
|
||||
inline bool valid_hash( const void *hash, const void *target )
|
||||
@@ -999,6 +1000,7 @@ inline bool valid_hash( const void *hash, const void *target )
|
||||
return true;
|
||||
}
|
||||
|
||||
// deprecated, use test_hash_and_submit
|
||||
bool fulltest( const uint32_t *hash, const uint32_t *target )
|
||||
{
|
||||
int i;
|
||||
@@ -1039,16 +1041,19 @@ bool fulltest( const uint32_t *hash, const uint32_t *target )
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
void diff_to_target(uint32_t *target, double diff)
|
||||
{
|
||||
uint64_t m;
|
||||
int k;
|
||||
|
||||
for (k = 6; k > 0 && diff > 1.0; k--)
|
||||
diff /= 4294967296.0;
|
||||
diff /= exp32;
|
||||
|
||||
m = (uint64_t)(4294901760.0 / diff);
|
||||
// diff /= 4294967296.0;
|
||||
|
||||
// m = (uint64_t)(4294901760.0 / diff);
|
||||
|
||||
m = (uint64_t)(exp32 / diff);
|
||||
|
||||
if (m == 0 && k == 6)
|
||||
memset(target, 0xff, 32);
|
||||
@@ -1058,30 +1063,6 @@ void diff_to_target(uint32_t *target, double diff)
|
||||
target[k + 1] = (uint32_t)(m >> 32);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void diff_to_target(uint32_t *target, double diff)
|
||||
{
|
||||
uint64_t *t = (uint64_t*)target;
|
||||
uint64_t m;
|
||||
int k;
|
||||
|
||||
// static const double exp64 = (double)0xffffffffffffffff + 1.;
|
||||
for ( k = 3; k > 0 && diff > 1.0; k-- )
|
||||
diff /= exp64;
|
||||
|
||||
m = (uint64_t)( 0xffff0000 / diff );
|
||||
|
||||
if unlikely( m == 0 && k == 3 )
|
||||
memset( t, 0xff, 32 );
|
||||
else
|
||||
{
|
||||
memset( t, 0, 32 );
|
||||
t[k] = m;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// deprecated
|
||||
void work_set_target(struct work* work, double diff)
|
||||
@@ -1090,6 +1071,15 @@ void work_set_target(struct work* work, double diff)
|
||||
work->targetdiff = diff;
|
||||
}
|
||||
|
||||
double target_to_diff( uint32_t* target )
|
||||
{
|
||||
uint64_t *targ = (uint64_t*)target;
|
||||
// extract 64 bits from target[ 240:176 ]
|
||||
uint64_t m = ( targ[3] << 16 ) | ( targ[2] >> 48 );
|
||||
return m ? (exp48-1.) / (double)m : 0.;
|
||||
}
|
||||
|
||||
/*
|
||||
double target_to_diff(uint32_t* target)
|
||||
{
|
||||
uchar* tgt = (uchar*) target;
|
||||
@@ -1103,11 +1093,13 @@ double target_to_diff(uint32_t* target)
|
||||
(uint64_t)tgt[23] << 8 |
|
||||
(uint64_t)tgt[22] << 0;
|
||||
|
||||
|
||||
if (!m)
|
||||
return 0.;
|
||||
else
|
||||
return (double)0x0000ffff00000000/m;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#define socket_blocks() (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
|
Reference in New Issue
Block a user