Only report threads in and out in queued work devices across a get work since the rest happens asynchronously and the get work is what the device might be waiting on.
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
diff --git a/cgminer.c b/cgminer.c
index 089b29e..5ccc1b7 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4665,6 +4665,10 @@ static void *api_thread(void *userdata)
return NULL;
}
+/* Sole work devices are serialised wrt calling get_work so they report in on
+ * each pass through their scanhash function as well as in get_work whereas
+ * queued work devices work asynchronously so get them to report in and out
+ * only across get_work. */
static void thread_reportin(struct thr_info *thr)
{
thr->getwork = false;
@@ -5668,6 +5672,7 @@ static struct work *get_work(struct thr_info *thr, const int thr_id)
{
struct work *work = NULL;
+ thread_reportout(thr);
applog(LOG_DEBUG, "Popping work from get queue to get work");
while (!work) {
work = hash_pop();
@@ -5783,8 +5788,6 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
submit_work_async(work, &tv_work_found);
out:
- thread_reportin(thr);
-
return ret;
}
@@ -6132,9 +6135,7 @@ void hash_queued_work(struct thr_info *mythr)
fill_queue(mythr, cgpu, drv, thr_id);
- thread_reportin(mythr);
hashes = drv->scanwork(mythr);
- thread_reportout(mythr);
if (unlikely(hashes == -1 )) {
applog(LOG_ERR, "%s %d failure, disabling!", drv->name, cgpu->device_id);
@@ -6176,12 +6177,12 @@ void *miner_thread(void *userdata)
snprintf(threadname, 24, "miner/%d", thr_id);
RenameThread(threadname);
+ thread_reportout(mythr);
if (!drv->thread_init(mythr)) {
dev_error(cgpu, REASON_THREAD_FAIL_INIT);
goto out;
}
- thread_reportout(mythr);
applog(LOG_DEBUG, "Waiting on sem in miner thread");
cgsem_wait(&mythr->sem);