Make sure the work gets attributed to the correct gpu. Add an fflush to stderr to minimise garbled output when multiple threads write at once.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/cpu-miner.c b/cpu-miner.c
index 38fcacb..e340efc 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -826,13 +826,13 @@ static void *miner_thread(void *userdata)
uint64_t max64;
bool rc;
- work.thr_id = thr_id;
/* obtain new work from internal workio thread */
if (unlikely(!get_work(&work))) {
applog(LOG_ERR, "work retrieval failed, exiting "
"mining thread %d", mythr->id);
goto out;
}
+ work.thr_id = thr_id;
hashes_done = 0;
gettimeofday(&tv_start, NULL);
@@ -1034,13 +1034,13 @@ static void *gpuminer_thread(void *userdata)
memset(res, 0, BUFFERSIZE);
gettimeofday(&tv_workstart, NULL);
- work->thr_id = thr_id;
/* obtain new work from internal workio thread */
if (unlikely(!get_work(work))) {
applog(LOG_ERR, "work retrieval failed, exiting "
"gpu mining thread %d", mythr->id);
goto out;
}
+ work->thr_id = thr_id;
precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
work->blk.nonce = 0;
diff --git a/util.c b/util.c
index b6c3c60..f7c8cc4 100644
--- a/util.c
+++ b/util.c
@@ -95,6 +95,7 @@ void applog(int prio, const char *fmt, ...)
vfprintf(stderr, f, ap); /* atomic write to stderr */
}
va_end(ap);
+ fflush(stderr);
}
static void databuf_free(struct data_buffer *db)