diff --git a/cgminer.c b/cgminer.c index 78b7d00e..481f2a07 100644 --- a/cgminer.c +++ b/cgminer.c @@ -7801,6 +7801,37 @@ int main(int argc, char *argv[]) quit(1, "Failed to calloc mining_thr[%d]", i); } + // Start threads + k = 0; + for (i = 0; i < total_devices; ++i) { + struct cgpu_info *cgpu = devices[i]; + cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1)); + cgpu->thr[cgpu->threads] = NULL; + cgpu->status = LIFE_INIT; + + for (j = 0; j < cgpu->threads; ++j, ++k) { + thr = get_thread(k); + thr->id = k; + thr->cgpu = cgpu; + thr->device_thread = j; + + if (!cgpu->drv->thread_prepare(thr)) + continue; + + if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) + quit(1, "thread %d create failed", thr->id); + + cgpu->thr[j] = thr; + + /* Enable threads for devices set not to mine but disable + * their queue in case we wish to enable them later */ + if (cgpu->deven != DEV_DISABLED) { + applog(LOG_DEBUG, "Pushing sem post to thread %d", thr->id); + cgsem_post(&thr->sem); + } + } + } + if (opt_benchmark) goto begin_bench; @@ -7858,44 +7889,6 @@ begin_bench: cgtime(&total_tv_end); get_datestamp(datestamp, sizeof(datestamp), &total_tv_start); - // Start threads - k = 0; - for (i = 0; i < total_devices; ++i) { - struct cgpu_info *cgpu = devices[i]; - cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1)); - cgpu->thr[cgpu->threads] = NULL; - cgpu->status = LIFE_INIT; - - for (j = 0; j < cgpu->threads; ++j, ++k) { - thr = get_thread(k); - thr->id = k; - thr->cgpu = cgpu; - thr->device_thread = j; - - if (!cgpu->drv->thread_prepare(thr)) - continue; - - if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) - quit(1, "thread %d create failed", thr->id); - - cgpu->thr[j] = thr; - - /* Enable threads for devices set not to mine but disable - * their queue in case we wish to enable them later */ - if (cgpu->deven != DEV_DISABLED) { - applog(LOG_DEBUG, "Pushing sem post to thread %d", thr->id); - cgsem_post(&thr->sem); - } - } - } - - applog(LOG_INFO, "%d gpu miner threads started", gpu_threads); - for (i = 0; i < nDevs; i++) - pause_dynamic_threads(i); - - cgtime(&total_tv_start); - cgtime(&total_tv_end); - watchpool_thr_id = 2; thr = &control_thr[watchpool_thr_id]; /* start watchpool thread */