Browse Source

Merge commit 'a02dc6f' into cg_merges_20131108a

Conflicts:
	miner.h
Luke Dashjr 12 years ago
parent
commit
dac18f7413
2 changed files with 27 additions and 1 deletions
  1. 24 1
      miner.c
  2. 3 0
      miner.h

+ 24 - 1
miner.c

@@ -8718,6 +8718,13 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
 	} while (drv->queue_full && !drv->queue_full(cgpu));
 	} while (drv->queue_full && !drv->queue_full(cgpu));
 }
 }
 
 
+/* Add a work item to a cgpu's queued hashlist */
+void __add_queued(struct cgpu_info *cgpu, struct work *work)
+{
+	cgpu->queued_count++;
+	HASH_ADD_INT(cgpu->queued_work, id, work);
+}
+
 /* This function is for retrieving one work item from the unqueued pointer and
 /* This function is for retrieving one work item from the unqueued pointer and
  * adding it to the hashtable of queued work. Code using this function must be
  * adding it to the hashtable of queued work. Code using this function must be
  * able to handle NULL as a return which implies there is no work available. */
  * able to handle NULL as a return which implies there is no work available. */
@@ -8728,7 +8735,7 @@ struct work *get_queued(struct cgpu_info *cgpu)
 	wr_lock(&cgpu->qlock);
 	wr_lock(&cgpu->qlock);
 	if (cgpu->unqueued_work) {
 	if (cgpu->unqueued_work) {
 		work = cgpu->unqueued_work;
 		work = cgpu->unqueued_work;
-		HASH_ADD_INT(cgpu->queued_work, id, work);
+		__add_queued(cgpu, work);
 		cgpu->unqueued_work = NULL;
 		cgpu->unqueued_work = NULL;
 	}
 	}
 	wr_unlock(&cgpu->qlock);
 	wr_unlock(&cgpu->qlock);
@@ -8736,6 +8743,22 @@ struct work *get_queued(struct cgpu_info *cgpu)
 	return work;
 	return work;
 }
 }
 
 
+void add_queued(struct cgpu_info *cgpu, struct work *work)
+{
+	wr_lock(&cgpu->qlock);
+	__add_queued(cgpu, work);
+	wr_unlock(&cgpu->qlock);
+}
+
+/* Get fresh work and add it to cgpu's queued hashlist */
+struct work *get_queue_work(struct thr_info *thr, struct cgpu_info *cgpu, int thr_id)
+{
+	struct work *work = get_work(thr);
+
+	add_queued(cgpu, work);
+	return work;
+}
+
 /* This function is for finding an already queued work item in the
 /* This function is for finding an already queued work item in the
  * given que hashtable. Code using this function must be able
  * given que hashtable. Code using this function must be able
  * to handle NULL as a return which implies there is no matching work.
  * to handle NULL as a return which implies there is no matching work.

+ 3 - 0
miner.h

@@ -1410,7 +1410,10 @@ extern enum test_nonce2_result _test_nonce2(struct work *, uint32_t nonce, bool
 #define test_nonce(work, nonce, checktarget)  (_test_nonce2(work, nonce, checktarget) == TNR_GOOD)
 #define test_nonce(work, nonce, checktarget)  (_test_nonce2(work, nonce, checktarget) == TNR_GOOD)
 #define test_nonce2(work, nonce)  (_test_nonce2(work, nonce, true))
 #define test_nonce2(work, nonce)  (_test_nonce2(work, nonce, true))
 extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
+extern void __add_queued(struct cgpu_info *cgpu, struct work *work);
 extern struct work *get_queued(struct cgpu_info *cgpu);
 extern struct work *get_queued(struct cgpu_info *cgpu);
+extern void add_queued(struct cgpu_info *cgpu, struct work *work);
+extern struct work *get_queue_work(struct thr_info *thr, struct cgpu_info *cgpu, int thr_id);
 extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);