mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 14:58:01 +00:00
Code movement. Update stats counter more frequently.
This commit is contained in:
parent
5b6e9a92f1
commit
89a05600ba
32
cpu-miner.c
32
cpu-miner.c
@ -25,6 +25,7 @@
|
|||||||
enum {
|
enum {
|
||||||
STAT_SLEEP_INTERVAL = 10,
|
STAT_SLEEP_INTERVAL = 10,
|
||||||
POW_SLEEP_INTERVAL = 1,
|
POW_SLEEP_INTERVAL = 1,
|
||||||
|
STAT_CTR_INTERVAL = 10000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool opt_verbose;
|
static bool opt_verbose;
|
||||||
@ -70,6 +71,17 @@ struct work {
|
|||||||
BIGNUM *target;
|
BIGNUM *target;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ___constant_swab32(x) ((u32)( \
|
||||||
|
(((u32)(x) & (u32)0x000000ffUL) << 24) | \
|
||||||
|
(((u32)(x) & (u32)0x0000ff00UL) << 8) | \
|
||||||
|
(((u32)(x) & (u32)0x00ff0000UL) >> 8) | \
|
||||||
|
(((u32)(x) & (u32)0xff000000UL) >> 24)))
|
||||||
|
|
||||||
|
static inline uint32_t swab32(uint32_t v)
|
||||||
|
{
|
||||||
|
return ___constant_swab32(v);
|
||||||
|
}
|
||||||
|
|
||||||
static void databuf_free(struct data_buffer *db)
|
static void databuf_free(struct data_buffer *db)
|
||||||
{
|
{
|
||||||
if (!db)
|
if (!db)
|
||||||
@ -325,17 +337,6 @@ static void inc_stats(uint64_t n_hashes)
|
|||||||
pthread_mutex_unlock(&stats_mutex);
|
pthread_mutex_unlock(&stats_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ___constant_swab32(x) ((u32)( \
|
|
||||||
(((u32)(x) & (u32)0x000000ffUL) << 24) | \
|
|
||||||
(((u32)(x) & (u32)0x0000ff00UL) << 8) | \
|
|
||||||
(((u32)(x) & (u32)0x00ff0000UL) >> 8) | \
|
|
||||||
(((u32)(x) & (u32)0xff000000UL) >> 24)))
|
|
||||||
|
|
||||||
static inline uint32_t swab32(uint32_t v)
|
|
||||||
{
|
|
||||||
return ___constant_swab32(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void runhash(void *state, void *input, const void *init)
|
static void runhash(void *state, void *input, const void *init)
|
||||||
{
|
{
|
||||||
memcpy(state, init, 32);
|
memcpy(state, init, 32);
|
||||||
@ -354,6 +355,7 @@ static uint32_t scanhash(unsigned char *midstate, unsigned char *data,
|
|||||||
uint32_t *hash32 = (uint32_t *) hash;
|
uint32_t *hash32 = (uint32_t *) hash;
|
||||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
|
unsigned long stat_ctr = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
n = *nonce;
|
n = *nonce;
|
||||||
@ -376,8 +378,14 @@ static uint32_t scanhash(unsigned char *midstate, unsigned char *data,
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stat_ctr++;
|
||||||
|
if (stat_ctr >= STAT_CTR_INTERVAL) {
|
||||||
|
inc_stats(STAT_CTR_INTERVAL);
|
||||||
|
stat_ctr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((n & 0xffffff) == 0) {
|
if ((n & 0xffffff) == 0) {
|
||||||
inc_stats(n);
|
inc_stats(stat_ctr);
|
||||||
|
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
fprintf(stderr, "DBG: end of nonce range\n");
|
fprintf(stderr, "DBG: end of nonce range\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user