Browse Source

Merge commit '97bad1e' into update_avalon_20130524

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
db7dcd6e64
2 changed files with 10 additions and 2 deletions
  1. 9 2
      miner.c
  2. 1 0
      miner.h

+ 9 - 2
miner.c

@@ -7009,10 +7009,14 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
 {
 {
 	thread_reportout(mythr);
 	thread_reportout(mythr);
 	do {
 	do {
-		struct work *work = get_work(mythr);
+		struct work *work;
 
 
 		wr_lock(&cgpu->qlock);
 		wr_lock(&cgpu->qlock);
-		HASH_ADD_INT(cgpu->queued_work, id, work);
+		if (HASH_COUNT(cgpu->queued_work) == cgpu->queued_count) {
+			work = get_work(mythr);
+			//work->device_diff = MIN(drv->max_diff, work->work_difficulty);
+			HASH_ADD_INT(cgpu->queued_work, id, work);
+		}
 		wr_unlock(&cgpu->qlock);
 		wr_unlock(&cgpu->qlock);
 		/* The queue_full function should be used by the driver to
 		/* The queue_full function should be used by the driver to
 		 * actually place work items on the physical device if it
 		 * actually place work items on the physical device if it
@@ -7032,6 +7036,7 @@ struct work *get_queued(struct cgpu_info *cgpu)
 	HASH_ITER(hh, cgpu->queued_work, work, tmp) {
 	HASH_ITER(hh, cgpu->queued_work, work, tmp) {
 		if (!work->queued) {
 		if (!work->queued) {
 			work->queued = true;
 			work->queued = true;
+			cgpu->queued_count++;
 			ret = work;
 			ret = work;
 			break;
 			break;
 		}
 		}
@@ -7082,6 +7087,8 @@ struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate,
 void work_completed(struct cgpu_info *cgpu, struct work *work)
 void work_completed(struct cgpu_info *cgpu, struct work *work)
 {
 {
 	wr_lock(&cgpu->qlock);
 	wr_lock(&cgpu->qlock);
+	if (work->queued)
+		cgpu->queued_count--;
 	HASH_DEL(cgpu->queued_work, work);
 	HASH_DEL(cgpu->queued_work, work);
 	wr_unlock(&cgpu->qlock);
 	wr_unlock(&cgpu->qlock);
 	free_work(work);
 	free_work(work);

+ 1 - 0
miner.h

@@ -537,6 +537,7 @@ struct cgpu_info {
 
 
 	pthread_rwlock_t qlock;
 	pthread_rwlock_t qlock;
 	struct work *queued_work;
 	struct work *queued_work;
+	unsigned int queued_count;
 };
 };
 
 
 extern void renumber_cgpu(struct cgpu_info *);
 extern void renumber_cgpu(struct cgpu_info *);