Browse Source

Split part of minerloop_async into do_get_results, and a bit other reorganization

Luke Dashjr 13 years ago
parent
commit
187abe9324
2 changed files with 15 additions and 6 deletions
  1. 14 5
      miner.c
  2. 1 1
      miner.h

+ 14 - 5
miner.c

@@ -6812,9 +6812,20 @@ void do_job_start(struct thr_info *mythr, struct timeval *tvp_now)
 		mythr->next_work = NULL;
 	}
 	mythr->tv_jobstart = *tvp_now;
+	thread_reportin(mythr);
 	api->job_start(mythr);
 }
 
+void do_get_results(struct thr_info *mythr, __maybe_unused struct timeval *tvp_now, struct work *work)
+{
+	struct cgpu_info *proc = mythr->cgpu;
+	const struct device_api *api = proc->api;
+	
+	if (api->job_get_results)
+		api->job_get_results(mythr, work);
+	mythr->tv_results_jobstart = mythr->tv_jobstart;
+}
+
 bool do_process_results(struct thr_info *mythr, struct timeval *tvp_now, struct work *work)
 {
 	struct cgpu_info *proc = mythr->cgpu;
@@ -6828,7 +6839,7 @@ bool do_process_results(struct thr_info *mythr, struct timeval *tvp_now, struct
 	
 	if (hashes)
 	{
-		timersub(tvp_now, &mythr->tv_prev_job_start, &tv_hashes);
+		timersub(tvp_now, &mythr->tv_results_jobstart, &tv_hashes);
 		if (!hashes_done(mythr, hashes, &tv_hashes, api->can_limit_work ? &mythr->_max_nonce : NULL))
 			return false;
 	}
@@ -6873,14 +6884,12 @@ void minerloop_async(struct thr_info *mythr)
 					mt_disable_finish(mythr);
 disabled: ;
 				bool keepgoing = (proc->deven == DEV_ENABLED && !mythr->pause);
-				thread_reportin(mythr);
 				prev_job_work = mythr->work;
-				mythr->tv_prev_job_start = mythr->tv_jobstart;
 				if (likely(keepgoing))
 					if (!do_job_prepare(mythr, &tv_now))
 						goto disabled;
-				if (likely(prev_job_work) && api->job_get_results)
-					api->job_get_results(mythr, prev_job_work);
+				if (likely(prev_job_work))
+					do_get_results(mythr, &tv_now, prev_job_work);
 				gettimeofday(&tv_now, NULL);  // NOTE: Can go away when fully async
 				if (likely(keepgoing))
 					do_job_start(mythr, &tv_now);

+ 1 - 1
miner.h

@@ -560,7 +560,7 @@ struct thr_info {
 	struct work *work;
 	struct work *next_work;
 	struct timeval tv_morework;
-	struct timeval tv_prev_job_start;
+	struct timeval tv_results_jobstart;
 	struct timeval tv_jobstart;
 	struct timeval tv_poll;
 	int notifier[2];