Initialise devices before attempting to connect to pools to allow their thread prepare function to be called before having to connect to pools.
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/cgminer.c b/cgminer.c
index b0fadb1..e59a46c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -8110,6 +8110,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;
@@ -8167,40 +8198,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);
- }
- }
- }
-
- cgtime(&total_tv_start);
- cgtime(&total_tv_end);
-
watchpool_thr_id = 2;
thr = &control_thr[watchpool_thr_id];
/* start watchpool thread */