From 79521fe8f075e072e807742f4c67cd7b9158bedc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Nov 2013 09:43:31 +1100 Subject: [PATCH] Initialise devices before attempting to connect to pools to allow their thread prepare function to be called before having to connect to pools. Conflicts: cgminer.c --- cgminer.c | 69 +++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 38 deletions(-) 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 */