Make sure correct thread id is in work struct and correct cpu is set for per-cpu data.
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 47 48 49 50 51 52 53 54 55
diff --git a/cpu-miner.c b/cpu-miner.c
index 0290c6d..f67b384 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -750,7 +750,7 @@ static inline int cpu_from_thr_id(int thr_id)
static void *miner_thread(void *userdata)
{
struct thr_info *mythr = userdata;
- int thr_id = mythr->id;
+ const int thr_id = mythr->id;
uint32_t max_nonce = 0xffffff;
/* Set worker threads to nice 19 and then preferentially to SCHED_IDLE
@@ -777,6 +777,7 @@ static void *miner_thread(void *userdata)
"mining thread %d", mythr->id);
goto out;
}
+ work.thr_id = thr_id;
hashes_done = 0;
gettimeofday(&tv_start, NULL);
@@ -966,7 +967,6 @@ static void *gpuminer_thread(void *userdata)
while (1) {
struct timeval tv_end, tv_workstart;
- unsigned int i;
/* This finish flushes the readbuffer set with CL_FALSE later */
clFinish(clState->commandQueue);
@@ -985,6 +985,7 @@ static void *gpuminer_thread(void *userdata)
"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;
@@ -1475,7 +1476,7 @@ int main (int argc, char *argv[])
thr = &thr_info[i];
thr->id = i;
- if (! (i % opt_g_threads)) {
+ if (! (i % opt_n_threads)) {
thr->cgpu = calloc(1, sizeof(struct cgpu_info));
if (unlikely(!thr->cgpu)) {
applog(LOG_ERR, "Failed to calloc cgpu_info");
@@ -1483,7 +1484,7 @@ int main (int argc, char *argv[])
}
thr->cgpu->cpu_gpu = cpu_from_thr_id(i);
} else
- thr->cgpu = thr_info[cpu_from_thr_id(i - (i % opt_g_threads))].cgpu;
+ thr->cgpu = thr_info[cpu_from_thr_id(i - (i % opt_n_threads))].cgpu;
thr->q = tq_new();
if (!thr->q)