Browse Source

Split part of minerloop_async into do_process_results, and don't allow api->job_get_results to return hashes

Luke Dashjr 13 years ago
parent
commit
32f07b8a3c
2 changed files with 28 additions and 23 deletions
  1. 26 22
      miner.c
  2. 2 1
      miner.h

+ 26 - 22
miner.c

@@ -6815,16 +6815,34 @@ void do_job_start(struct thr_info *mythr, struct timeval *tvp_now)
 	api->job_start(mythr);
 	api->job_start(mythr);
 }
 }
 
 
+bool do_process_results(struct thr_info *mythr, struct timeval *tvp_now, struct work *work)
+{
+	struct cgpu_info *proc = mythr->cgpu;
+	const struct device_api *api = proc->api;
+	struct timeval tv_hashes;
+	int64_t hashes = 0;
+	
+	if (api->job_process_results)
+		hashes = api->job_process_results(mythr, work);
+	thread_reportin(mythr);
+	
+	if (hashes)
+	{
+		timersub(tvp_now, &mythr->tv_prev_job_start, &tv_hashes);
+		if (!hashes_done(mythr, hashes, &tv_hashes, api->can_limit_work ? &mythr->_max_nonce : NULL))
+			return false;
+	}
+	
+	return true;
+}
+
 void minerloop_async(struct thr_info *mythr)
 void minerloop_async(struct thr_info *mythr)
 {
 {
 	const int thr_id = mythr->id;
 	const int thr_id = mythr->id;
 	struct cgpu_info *cgpu = mythr->cgpu;
 	struct cgpu_info *cgpu = mythr->cgpu;
 	const struct device_api *api = cgpu->api;
 	const struct device_api *api = cgpu->api;
-	struct timeval tv_start, tv_end;
-	struct timeval tv_hashes;
 	struct timeval tv_now;
 	struct timeval tv_now;
 	struct timeval tv_timeout, *tvp_timeout;
 	struct timeval tv_timeout, *tvp_timeout;
-	int64_t hashes;
 	struct work *work;
 	struct work *work;
 	const bool primary = (!mythr->device_thread) || mythr->primary_thread;
 	const bool primary = (!mythr->device_thread) || mythr->primary_thread;
 	struct cgpu_info *proc;
 	struct cgpu_info *proc;
@@ -6857,16 +6875,12 @@ disabled: ;
 				bool keepgoing = (proc->deven == DEV_ENABLED && !mythr->pause);
 				bool keepgoing = (proc->deven == DEV_ENABLED && !mythr->pause);
 				thread_reportin(mythr);
 				thread_reportin(mythr);
 				prev_job_work = mythr->work;
 				prev_job_work = mythr->work;
-				tv_start = mythr->tv_jobstart;
+				mythr->tv_prev_job_start = mythr->tv_jobstart;
 				if (likely(keepgoing))
 				if (likely(keepgoing))
 					if (!do_job_prepare(mythr, &tv_now))
 					if (!do_job_prepare(mythr, &tv_now))
 						goto disabled;
 						goto disabled;
-				if (likely(prev_job_work))
-				{
-					hashes = -101;
-					if (api->job_get_results)
-						hashes = api->job_get_results(mythr, prev_job_work);
-				}
+				if (likely(prev_job_work) && api->job_get_results)
+					api->job_get_results(mythr, prev_job_work);
 				gettimeofday(&tv_now, NULL);  // NOTE: Can go away when fully async
 				gettimeofday(&tv_now, NULL);  // NOTE: Can go away when fully async
 				if (likely(keepgoing))
 				if (likely(keepgoing))
 					do_job_start(mythr, &tv_now);
 					do_job_start(mythr, &tv_now);
@@ -6877,18 +6891,8 @@ disabled: ;
 					mythr->tv_morework.tv_sec = -1;
 					mythr->tv_morework.tv_sec = -1;
 				}
 				}
 				if (likely(prev_job_work))
 				if (likely(prev_job_work))
-				{
-					if (api->job_process_results)
-						hashes = api->job_process_results(mythr, prev_job_work);
-					thread_reportin(mythr);
-					
-					if (hashes != -101)
-					{
-						timersub(&tv_now, &tv_start, &tv_hashes);
-						if (!hashes_done(mythr, hashes, &tv_hashes, api->can_limit_work ? &mythr->_max_nonce : NULL))
-							goto disabled;
-					}
-				}
+					if (!do_process_results(mythr, &tv_now, prev_job_work))
+						goto disabled;
 			}
 			}
 			
 			
 			if (mythr->tv_poll.tv_sec != -1 && timercmp(&mythr->tv_poll, &tv_now, <))
 			if (mythr->tv_poll.tv_sec != -1 && timercmp(&mythr->tv_poll, &tv_now, <))

+ 2 - 1
miner.h

@@ -304,7 +304,7 @@ struct device_api {
 	// Job-specific functions (only with minerloop_async!)
 	// Job-specific functions (only with minerloop_async!)
 	bool (*job_prepare)(struct thr_info*, struct work*, uint64_t);
 	bool (*job_prepare)(struct thr_info*, struct work*, uint64_t);
 	void (*job_start)(struct thr_info*);
 	void (*job_start)(struct thr_info*);
-	int64_t (*job_get_results)(struct thr_info*, struct work*);
+	void (*job_get_results)(struct thr_info*, struct work*);
 	int64_t (*job_process_results)(struct thr_info*, struct work*);  // return value ignored if job_get_results is used
 	int64_t (*job_process_results)(struct thr_info*, struct work*);  // return value ignored if job_get_results is used
 };
 };
 
 
@@ -560,6 +560,7 @@ struct thr_info {
 	struct work *work;
 	struct work *work;
 	struct work *next_work;
 	struct work *next_work;
 	struct timeval tv_morework;
 	struct timeval tv_morework;
+	struct timeval tv_prev_job_start;
 	struct timeval tv_jobstart;
 	struct timeval tv_jobstart;
 	struct timeval tv_poll;
 	struct timeval tv_poll;
 	int notifier[2];
 	int notifier[2];