Create the hash queued work variant for use with devices that are fast enough to require a queue.
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
diff --git a/cgminer.c b/cgminer.c
index 931e16a..6c28a4d 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5595,6 +5595,53 @@ static void hash_sole_work(struct thr_info *mythr)
}
}
+/* This version of hash work is for devices that are fast enough to always
+ * perform a full nonce range and need a queue to maintain the device busy.
+ * Work creation and destruction is not done from within this function
+ * directly. */
+static void hash_queued_work(struct thr_info *mythr)
+{
+ const long cycle = opt_log_interval / 5 ? : 1;
+ struct timeval tv_start = {0, 0}, tv_end;
+ struct cgpu_info *cgpu = mythr->cgpu;
+ struct device_drv *drv = cgpu->drv;
+ const int thr_id = mythr->id;
+ int64_t hashes_done = 0;
+
+ while (42) {
+ struct timeval diff;
+ int64_t hashes;
+
+ mythr->work_restart = false;
+
+ //fill_queue(mythr, cgpu, drv, thr_id);
+
+ thread_reportin(mythr);
+ hashes = drv->scanwork(mythr);
+ if (unlikely(hashes == -1 )) {
+ applog(LOG_ERR, "%s %d failure, disabling!", drv->name, cgpu->device_id);
+ cgpu->deven = DEV_DISABLED;
+ dev_error(cgpu, REASON_THREAD_ZERO_HASH);
+ mt_disable(mythr, thr_id, drv);
+ }
+
+ hashes_done += hashes;
+ gettimeofday(&tv_end, NULL);
+ timersub(&tv_end, &tv_start, &diff);
+ if (diff.tv_sec >= cycle) {
+ hashmeter(thr_id, &diff, hashes_done);
+ hashes_done = 0;
+ memcpy(&tv_start, &tv_end, sizeof(struct timeval));
+ }
+
+ //if (unlikely(mythr->work_restart))
+ // flush_queue(mythr, cgpu);
+
+ if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED))
+ mt_disable(mythr, thr_id, drv);
+ }
+}
+
void *miner_thread(void *userdata)
{
struct thr_info *mythr = userdata;
diff --git a/miner.h b/miner.h
index 70a379f..f68707a 100644
--- a/miner.h
+++ b/miner.h
@@ -298,6 +298,7 @@ struct device_drv {
bool (*thread_init)(struct thr_info *);
bool (*prepare_work)(struct thr_info *, struct work *);
int64_t (*scanhash)(struct thr_info *, struct work *, int64_t);
+ int64_t (*scanwork)(struct thr_info *);
void (*hw_error)(struct thr_info *);
void (*thread_shutdown)(struct thr_info *);
void (*thread_enable)(struct thr_info *);