Browse Source

Add the choice of hash loop to the device driver, defaulting to hash_sole_work if none is specified.

Con Kolivas 13 years ago
parent
commit
fda6d46e95
2 changed files with 15 additions and 2 deletions
  1. 4 2
      cgminer.c
  2. 11 0
      miner.h

+ 4 - 2
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.
  * 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
  * Work creation and destruction is not done from within this function
  * directly. */
  * 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;
 	const long cycle = opt_log_interval / 5 ? : 1;
 	struct timeval tv_start = {0, 0}, tv_end;
 	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");
 	applog(LOG_DEBUG, "Popping ping in miner thread");
 	tq_pop(mythr->q, NULL); /* Wait for a ping to start */
 	tq_pop(mythr->q, NULL); /* Wait for a ping to start */
 
 
-	hash_sole_work(mythr);
+	drv->hash_work(mythr);
 out:
 out:
 	drv->thread_shutdown(mythr);
 	drv->thread_shutdown(mythr);
 
 
@@ -6647,6 +6647,8 @@ void fill_device_api(struct cgpu_info *cgpu)
 		drv->thread_shutdown = &noop_thread_shutdown;
 		drv->thread_shutdown = &noop_thread_shutdown;
 	if (!drv->thread_enable)
 	if (!drv->thread_enable)
 		drv->thread_enable = &noop_thread_enable;
 		drv->thread_enable = &noop_thread_enable;
+	if (!drv->hash_work)
+		drv->hash_work = &hash_sole_work;
 	if (!drv->flush_work)
 	if (!drv->flush_work)
 		drv->flush_work = &noop_flush_work;
 		drv->flush_work = &noop_flush_work;
 	if (!drv->queue_full)
 	if (!drv->queue_full)

+ 11 - 0
miner.h

@@ -297,8 +297,18 @@ struct device_drv {
 	uint64_t (*can_limit_work)(struct thr_info *);
 	uint64_t (*can_limit_work)(struct thr_info *);
 	bool (*thread_init)(struct thr_info *);
 	bool (*thread_init)(struct thr_info *);
 	bool (*prepare_work)(struct thr_info *, struct work *);
 	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 (*scanhash)(struct thr_info *, struct work *, int64_t);
 	int64_t (*scanwork)(struct thr_info *);
 	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 *);
 	bool (*queue_full)(struct cgpu_info *);
 	void (*flush_work)(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 get_datestamp(char *, struct timeval *);
 extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 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 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 tailsprintf(char *f, const char *fmt, ...);
 extern void wlogprint(const char *f, ...);
 extern void wlogprint(const char *f, ...);
 extern int curses_int(const char *query);
 extern int curses_int(const char *query);