Add the choice of hash loop to the device driver, defaulting to hash_sole_work if none is specified.
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
diff --git a/cgminer.c b/cgminer.c
index 764a9c6..81e2eb1 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5652,7 +5652,7 @@ static void flush_queue(struct cgpu_info *cgpu)
* 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)
+void hash_queued_work(struct thr_info *mythr)
{
const long cycle = opt_log_interval / 5 ? : 1;
struct timeval tv_start = {0, 0}, tv_end;
@@ -5719,7 +5719,7 @@ void *miner_thread(void *userdata)
applog(LOG_DEBUG, "Popping ping in miner thread");
tq_pop(mythr->q, NULL); /* Wait for a ping to start */
- hash_sole_work(mythr);
+ drv->hash_work(mythr);
out:
drv->thread_shutdown(mythr);
@@ -6647,6 +6647,8 @@ void fill_device_api(struct cgpu_info *cgpu)
drv->thread_shutdown = &noop_thread_shutdown;
if (!drv->thread_enable)
drv->thread_enable = &noop_thread_enable;
+ if (!drv->hash_work)
+ drv->hash_work = &hash_sole_work;
if (!drv->flush_work)
drv->flush_work = &noop_flush_work;
if (!drv->queue_full)
diff --git a/miner.h b/miner.h
index da44dc9..897f01d 100644
--- a/miner.h
+++ b/miner.h
@@ -297,8 +297,18 @@ struct device_drv {
uint64_t (*can_limit_work)(struct thr_info *);
bool (*thread_init)(struct thr_info *);
bool (*prepare_work)(struct thr_info *, struct work *);
+
+ /* Which hash work loop this driver uses. */
+ void (*hash_work)(struct thr_info *);
+ /* Two variants depending on whether the device divides work up into
+ * small pieces or works with whole work items and may or may not have
+ * a queue of its own. */
int64_t (*scanhash)(struct thr_info *, struct work *, int64_t);
int64_t (*scanwork)(struct thr_info *);
+
+ /* Used to extract work from the hash table of queued work and tell
+ * the main loop that it should not add any further work to the table.
+ */
bool (*queue_full)(struct cgpu_info *);
void (*flush_work)(struct cgpu_info *);
@@ -1095,6 +1105,7 @@ struct modminer_fpga_state {
extern void get_datestamp(char *, struct timeval *);
extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern void work_completed(struct cgpu_info *cgpu, struct work *work);
+extern void hash_queued_work(struct thr_info *mythr);
extern void tailsprintf(char *f, const char *fmt, ...);
extern void wlogprint(const char *f, ...);
extern int curses_int(const char *query);