Browse Source

Bugfix: Skip processing (non-)result when changing work

This also simplifies firstrun/changework into a single jobrunning bool
Luke Dashjr 14 years ago
parent
commit
297509bd1e
1 changed files with 11 additions and 19 deletions
  1. 11 19
      driver-icarus.c

+ 11 - 19
driver-icarus.c

@@ -254,10 +254,9 @@ static void icarus_detect()
 }
 
 struct icarus_state {
-	bool firstrun;
+	bool jobrunning;
 	struct timeval tv_workstart;
 	struct work last_work;
-	bool changework;
 };
 
 static bool icarus_prepare(struct thr_info *thr)
@@ -272,7 +271,6 @@ static bool icarus_prepare(struct thr_info *thr)
 
 	struct icarus_state *state;
 	thr->cgpu_data = state = calloc(1, sizeof(*state));
-	state->firstrun = true;
 
 	return true;
 }
@@ -309,20 +307,14 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 		return 0;
 	}
 
-	if (!state->firstrun) {
-		if (state->changework)
-			state->changework = false;
-		else
-		{
-			/* Icarus will return 8 bytes nonces or nothing */
-			lret = icarus_gets(nonce_bin, sizeof(nonce_bin), fd, wr);
-			if (lret && *wr) {
-				// The prepared work is invalid, and the current work is abandoned
-				// Go back to the main loop to get the next work, and stuff
-				// Returning to the main loop will clear work_restart, so use a flag...
-				state->changework = true;
-				return 1;
-			}
+	if (likely(state->jobrunning)) {
+		/* Icarus will return 8 bytes nonces or nothing */
+		lret = icarus_gets(nonce_bin, sizeof(nonce_bin), fd, wr);
+		if (lret && *wr) {
+			// The prepared work is invalid, and the current work is abandoned
+			// Go back to the main loop to get the next work, and stuff
+			state->jobrunning = false;
+			return 1;
 		}
 
 		gettimeofday(&tv_end, NULL);
@@ -352,8 +344,8 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 
 	work->blk.nonce = 0xffffffff;
 
-	if (state->firstrun) {
-		state->firstrun = false;
+	if (unlikely(!state->jobrunning)) {
+		state->jobrunning = true;
 		memcpy(&state->last_work, work, sizeof(state->last_work));
 		return 1;
 	}