try to prevent gpu pauses
This commit is contained in:
parent
402e416853
commit
3ed36f285b
34
cpu-miner.c
34
cpu-miner.c
@ -460,11 +460,14 @@ static bool submit_upstream_work(CURL *curl, struct work *work)
|
|||||||
bool rc = false;
|
bool rc = false;
|
||||||
|
|
||||||
/* pass if the previous hash is not the current previous hash */
|
/* pass if the previous hash is not the current previous hash */
|
||||||
|
pthread_mutex_lock(&g_work_lock);
|
||||||
if (memcmp(work->data + 1, g_work.data + 1, 32)) {
|
if (memcmp(work->data + 1, g_work.data + 1, 32)) {
|
||||||
|
pthread_mutex_unlock(&g_work_lock);
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
applog(LOG_DEBUG, "DEBUG: stale work detected, discarding");
|
applog(LOG_DEBUG, "DEBUG: stale work detected, discarding");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&g_work_lock);
|
||||||
|
|
||||||
if (have_stratum) {
|
if (have_stratum) {
|
||||||
uint32_t sent;
|
uint32_t sent;
|
||||||
@ -894,6 +897,7 @@ static void *miner_thread(void *userdata)
|
|||||||
struct timeval tv_start, tv_end, diff;
|
struct timeval tv_start, tv_end, diff;
|
||||||
int64_t max64;
|
int64_t max64;
|
||||||
uint64_t umax64;
|
uint64_t umax64;
|
||||||
|
bool extrajob = false;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// &work.data[19]
|
// &work.data[19]
|
||||||
@ -901,13 +905,24 @@ static void *miner_thread(void *userdata)
|
|||||||
uint32_t *nonceptr = (uint32_t*) (((char*)work.data) + wcmplen);
|
uint32_t *nonceptr = (uint32_t*) (((char*)work.data) + wcmplen);
|
||||||
|
|
||||||
if (have_stratum) {
|
if (have_stratum) {
|
||||||
while (time(NULL) >= (g_work_time + opt_scantime) && !work_done)
|
uint32_t sleeptime = 0;
|
||||||
usleep(500*1000);
|
while (!work_done && time(NULL) >= (g_work_time + opt_scantime)) {
|
||||||
work_done = false;
|
sleeptime++;
|
||||||
pthread_mutex_lock(&g_work_lock);
|
usleep(50*1000);
|
||||||
|
if (sleeptime > 5) {
|
||||||
|
extrajob = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sleeptime)
|
||||||
|
applog(LOG_DEBUG, "sleeptime: %u ms", sleeptime*100);
|
||||||
nonceptr = (uint32_t*) (((char*)work.data) + wcmplen);
|
nonceptr = (uint32_t*) (((char*)work.data) + wcmplen);
|
||||||
if ((*nonceptr) >= end_nonce)
|
pthread_mutex_lock(&g_work_lock);
|
||||||
|
extrajob |= work_done;
|
||||||
|
if ((*nonceptr) >= end_nonce || extrajob) {
|
||||||
|
work_done = false;
|
||||||
stratum_gen_work(&stratum, &g_work);
|
stratum_gen_work(&stratum, &g_work);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int min_scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
|
int min_scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
|
||||||
/* obtain new work from internal workio thread */
|
/* obtain new work from internal workio thread */
|
||||||
@ -946,11 +961,11 @@ static void *miner_thread(void *userdata)
|
|||||||
(*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr
|
(*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr
|
||||||
} else
|
} else
|
||||||
(*nonceptr)++; //??
|
(*nonceptr)++; //??
|
||||||
pthread_mutex_unlock(&g_work_lock);
|
|
||||||
work_restart[thr_id].restart = 0;
|
work_restart[thr_id].restart = 0;
|
||||||
|
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
applog(LOG_WARNING, "job %s %08x", g_work.job_id, (*nonceptr));
|
applog(LOG_WARNING, "job %s %08x", g_work.job_id, (*nonceptr));
|
||||||
|
pthread_mutex_unlock(&g_work_lock);
|
||||||
|
|
||||||
/* adjust max_nonce to meet target scan time */
|
/* adjust max_nonce to meet target scan time */
|
||||||
if (have_stratum)
|
if (have_stratum)
|
||||||
@ -962,15 +977,18 @@ static void *miner_thread(void *userdata)
|
|||||||
max64 *= (int64_t)thr_hashrates[thr_id];
|
max64 *= (int64_t)thr_hashrates[thr_id];
|
||||||
|
|
||||||
if (max64 <= 0) {
|
if (max64 <= 0) {
|
||||||
|
/* should not be set too high,
|
||||||
|
else you can miss multiple nounces */
|
||||||
switch (opt_algo) {
|
switch (opt_algo) {
|
||||||
case ALGO_JACKPOT:
|
case ALGO_JACKPOT:
|
||||||
max64 = 0x1fffLL;
|
max64 = 0x1fffLL;
|
||||||
break;
|
break;
|
||||||
case ALGO_BLAKECOIN:
|
case ALGO_BLAKECOIN:
|
||||||
max64 = 0x3ffffffLL;
|
max64 = 0x3ffffffLL;
|
||||||
|
break;
|
||||||
case ALGO_BLAKE:
|
case ALGO_BLAKE:
|
||||||
/* based on the 750Ti hashrate (100kH) */
|
/* based on the 750Ti hashrate (100kH) */
|
||||||
max64 = 0x3ffffffLL;
|
max64 = 0x1ffffffLL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
max64 = 0xfffffLL;
|
max64 = 0xfffffLL;
|
||||||
@ -1008,7 +1026,7 @@ static void *miner_thread(void *userdata)
|
|||||||
work_restart[thr_id].restart = 1;
|
work_restart[thr_id].restart = 1;
|
||||||
hashlog_purge_old();
|
hashlog_purge_old();
|
||||||
// wait a bit for a new job...
|
// wait a bit for a new job...
|
||||||
sleep(1);
|
usleep(500*1000);
|
||||||
(*nonceptr) = end_nonce + 1;
|
(*nonceptr) = end_nonce + 1;
|
||||||
work_done = true;
|
work_done = true;
|
||||||
continue;
|
continue;
|
||||||
|
7
util.c
7
util.c
@ -1020,7 +1020,7 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params)
|
|||||||
int merkle_count, i;
|
int merkle_count, i;
|
||||||
json_t *merkle_arr;
|
json_t *merkle_arr;
|
||||||
unsigned char **merkle;
|
unsigned char **merkle;
|
||||||
int ntime;
|
int ntime, hoffset;
|
||||||
|
|
||||||
job_id = json_string_value(json_array_get(params, 0));
|
job_id = json_string_value(json_array_get(params, 0));
|
||||||
prevhash = json_string_value(json_array_get(params, 1));
|
prevhash = json_string_value(json_array_get(params, 1));
|
||||||
@ -1078,7 +1078,8 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params)
|
|||||||
hex2bin(sctx->job.coinbase, coinb1, coinb1_size);
|
hex2bin(sctx->job.coinbase, coinb1, coinb1_size);
|
||||||
memcpy(sctx->job.coinbase + coinb1_size, sctx->xnonce1, sctx->xnonce1_size);
|
memcpy(sctx->job.coinbase + coinb1_size, sctx->xnonce1, sctx->xnonce1_size);
|
||||||
|
|
||||||
sctx->bloc_height = le16dec((uint8_t*) sctx->job.coinbase + 43);
|
hoffset = coinb1_size - 15; // 43;
|
||||||
|
sctx->bloc_height = le16dec((uint8_t*) sctx->job.coinbase + hoffset);
|
||||||
if (!sctx->job.job_id || strcmp(sctx->job.job_id, job_id))
|
if (!sctx->job.job_id || strcmp(sctx->job.job_id, job_id))
|
||||||
memset(sctx->job.xnonce2, 0, sctx->xnonce2_size);
|
memset(sctx->job.xnonce2, 0, sctx->xnonce2_size);
|
||||||
hex2bin(sctx->job.xnonce2 + sctx->xnonce2_size, coinb2, coinb2_size);
|
hex2bin(sctx->job.xnonce2 + sctx->xnonce2_size, coinb2, coinb2_size);
|
||||||
@ -1125,7 +1126,7 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
|
|||||||
sctx->next_diff = diff;
|
sctx->next_diff = diff;
|
||||||
pthread_mutex_unlock(&sctx->work_lock);
|
pthread_mutex_unlock(&sctx->work_lock);
|
||||||
|
|
||||||
applog(LOG_INFO, "Stratum difficulty set to %g", diff);
|
applog(LOG_WARNING, "Stratum difficulty set to %g", diff);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user