Browse Source

Revert broken scrypt diff1 measurement fix attempts

This reverts 807148b699b841144c08d96b683b05a816c83dfe, 87e9ba1649890f15fb11a392091ce2fbb1c33139, and a8fdcc77e49dd2d1c4de05fb43ff1d7a429bb29f
Luke Dashjr 12 years ago
parent
commit
9ddc4e0e44
3 changed files with 34 additions and 38 deletions
  1. 9 9
      api.c
  2. 20 24
      miner.c
  3. 5 5
      miner.h

+ 9 - 9
api.c

@@ -1476,7 +1476,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 	enum alive status = cgpu->status;
 	float temp = -1;
 	int accepted = 0, rejected = 0, stale = 0, hw_errors = 0;
-	double diff1 = 0, bad_diff1 = 0;
+	int diff1 = 0, bad_nonces = 0;
 	double diff_accepted = 0, diff_rejected = 0, diff_stale = 0;
 	int last_share_pool = -1;
 	time_t last_share_pool_time = -1, last_device_valid_work = -1;
@@ -1498,7 +1498,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 		diff_accepted += proc->diff_accepted;
 		diff_rejected += proc->diff_rejected;
 		diff_stale += proc->diff_stale;
-		bad_diff1 += proc->bad_diff1;
+		bad_nonces += proc->bad_nonces;
 		if (status != proc->status)
 			status = LIFE_MIXED;
 		if (proc->temp > temp)
@@ -1540,7 +1540,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 	}
 	root = api_add_mhtotal(root, "Total MH", &total_mhashes, false);
 	double work_utility = diff1 / runtime * 60;
-	root = api_add_diff(root, "Diff1 Work", &diff1, false);
+	root = api_add_int(root, "Diff1 Work", &diff1, false);
 	root = api_add_utility(root, "Work Utility", &work_utility, false);
 	root = api_add_diff(root, "Difficulty Accepted", &diff_accepted, false);
 	root = api_add_diff(root, "Difficulty Rejected", &diff_rejected, false);
@@ -1549,8 +1549,8 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 		root = api_add_diff(root, "Last Share Difficulty", &last_share_diff, false);
 	if (last_device_valid_work != -1)
 		root = api_add_time(root, "Last Valid Work", &last_device_valid_work, false);
-	double hwp = (bad_diff1 + diff1) ?
-			(double)(bad_diff1) / (double)(bad_diff1 + diff1) : 0;
+	double hwp = (bad_nonces + diff1) ?
+			(double)(bad_nonces) / (double)(bad_nonces + diff1) : 0;
 	root = api_add_percent(root, "Device Hardware%", &hwp, false);
 	double rejp = diff1 ?
 			(double)(diff_rejected) / (double)(diff1) : 0;
@@ -1971,7 +1971,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 		root = api_add_uint(root, "Remote Failures", &(pool->remotefail_occasions), false);
 		root = api_add_escape(root, "User", pool->rpc_user, false);
 		root = api_add_time(root, "Last Share Time", &(pool->last_share_time), false);
-		root = api_add_diff(root, "Diff1 Shares", &(pool->diff1), false);
+		root = api_add_int(root, "Diff1 Shares", &(pool->diff1), false);
 		if (pool->rpc_proxy) {
 			root = api_add_escape(root, "Proxy", pool->rpc_proxy, false);
 		} else {
@@ -2050,14 +2050,14 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
 	root = api_add_uint(root, "Remote Failures", &(total_ro), true);
 	root = api_add_uint(root, "Network Blocks", &(new_blocks), true);
 	root = api_add_mhtotal(root, "Total MH", &(total_mhashes_done), true);
-	root = api_add_diff(root, "Diff1 Work", &total_diff1, true);
+	root = api_add_int(root, "Diff1 Work", &total_diff1, true);
 	root = api_add_utility(root, "Work Utility", &(work_utility), false);
 	root = api_add_diff(root, "Difficulty Accepted", &(total_diff_accepted), true);
 	root = api_add_diff(root, "Difficulty Rejected", &(total_diff_rejected), true);
 	root = api_add_diff(root, "Difficulty Stale", &(total_diff_stale), true);
 	root = api_add_uint64(root, "Best Share", &(best_diff), true);
-	double hwp = (total_bad_diff1 + total_diff1) ?
-			(double)(total_bad_diff1) / (double)(total_bad_diff1 + total_diff1) : 0;
+	double hwp = (total_bad_nonces + total_diff1) ?
+			(double)(total_bad_nonces) / (double)(total_bad_nonces + total_diff1) : 0;
 	root = api_add_percent(root, "Device Hardware%", &hwp, false);
 	double rejp = total_diff1 ?
 			(double)(total_diff_rejected) / (double)(total_diff1) : 0;

+ 20 - 24
miner.c

@@ -159,10 +159,8 @@ int opt_g_threads = -1;
 #ifdef USE_SCRYPT
 static char detect_algo = 1;
 bool opt_scrypt;
-float nonce_diff = 1;
 #else
 static char detect_algo;
-const float nonce_diff = 1;
 #endif
 bool opt_restart = true;
 
@@ -278,10 +276,10 @@ static struct work *submit_waiting;
 notifier_t submit_waiting_notifier;
 
 int hw_errors;
-int total_accepted, total_rejected;
+int total_accepted, total_rejected, total_diff1;
+int total_bad_nonces;
 int total_getworks, total_stale, total_discarded;
 uint64_t total_bytes_rcvd, total_bytes_sent;
-double total_diff1, total_bad_diff1;
 double total_diff_accepted, total_diff_rejected, total_diff_stale;
 static int staged_rollable;
 unsigned int new_blocks;
@@ -3039,7 +3037,7 @@ static void adj_width(int var, int *length);
 static int awidth = 1, rwidth = 1, swidth = 1, hwwidth = 1;
 
 static
-void format_statline(char *buf, size_t bufsz, const char *cHr, const char *aHr, const char *uHr, int accepted, int rejected, int stale, int wnotaccepted, int waccepted, int hwerrs, int bad_diff1, int allnonces)
+void format_statline(char *buf, size_t bufsz, const char *cHr, const char *aHr, const char *uHr, int accepted, int rejected, int stale, int wnotaccepted, int waccepted, int hwerrs, int badnonces, int allnonces)
 {
 	char rejpcbuf[6];
 	char bnbuf[6];
@@ -3049,7 +3047,7 @@ void format_statline(char *buf, size_t bufsz, const char *cHr, const char *aHr,
 	adj_width(stale, &swidth);
 	adj_width(hwerrs, &hwwidth);
 	percentf4(rejpcbuf, sizeof(rejpcbuf), wnotaccepted, waccepted);
-	percentf3(bnbuf, sizeof(bnbuf), bad_diff1, allnonces);
+	percentf3(bnbuf, sizeof(bnbuf), badnonces, allnonces);
 	
 	tailsprintf(buf, bufsz, "%s/%s/%s | A:%*d R:%*d+%*d(%s) HW:%*d/%s",
 	            cHr, aHr, uHr,
@@ -3110,8 +3108,8 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 	double waccepted = cgpu->diff_accepted;
 	double wnotaccepted = cgpu->diff_rejected + cgpu->diff_stale;
 	int hwerrs = cgpu->hw_errors;
-	double bad_diff1 = cgpu->bad_diff1;
-	double good_diff1 = cgpu->diff1;
+	int badnonces = cgpu->bad_nonces;
+	int goodnonces = cgpu->diff1;
 	
 	if (!opt_show_procs)
 	{
@@ -3131,8 +3129,8 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 			waccepted += slave->diff_accepted;
 			wnotaccepted += slave->diff_rejected + slave->diff_stale;
 			hwerrs += slave->hw_errors;
-			bad_diff1 += slave->bad_diff1;
-			good_diff1 += slave->diff1;
+			badnonces += slave->bad_nonces;
+			goodnonces += slave->diff1;
 		}
 	}
 	
@@ -3145,7 +3143,7 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 		3,
 		1e6*rolling,
 		1e6*mhashes / dev_runtime,
-		utility_to_hashrate(good_diff1 * (wtotal ? (waccepted / wtotal) : 1) * 60 / dev_runtime));
+		utility_to_hashrate(goodnonces * (wtotal ? (waccepted / wtotal) : 1) * 60 / dev_runtime));
 
 	// Processor representation
 #ifdef HAVE_CURSES
@@ -3243,13 +3241,13 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 		                accepted, rejected, stale,
 		                wnotaccepted, waccepted,
 		                hwerrs,
-		                bad_diff1, bad_diff1 + good_diff1);
+		                badnonces, badnonces + goodnonces);
 	}
 	else
 #endif
 	{
 		percentf4(rejpcbuf, sizeof(rejpcbuf), wnotaccepted, waccepted);
-		percentf4(bnbuf, sizeof(bnbuf), bad_diff1, good_diff1);
+		percentf4(bnbuf, sizeof(bnbuf), badnonces, goodnonces);
 		tailsprintf(buf, bufsz, "%ds:%s avg:%s u:%s | A:%d R:%d+%d(%s) HW:%d/%s",
 			opt_log_interval,
 			cHr, aHr, uHr,
@@ -6422,7 +6420,7 @@ void zero_stats(void)
 	total_ro = 0;
 	total_secs = 1.0;
 	total_diff1 = 0;
-	total_bad_diff1 = 0;
+	total_bad_nonces = 0;
 	found_blocks = 0;
 	total_diff_accepted = 0;
 	total_diff_rejected = 0;
@@ -6485,7 +6483,7 @@ void zero_stats(void)
 		cgpu->utility = 0.0;
 		cgpu->utility_diff1 = 0;
 		cgpu->last_share_pool_time = 0;
-		cgpu->bad_diff1 = 0;
+		cgpu->bad_nonces = 0;
 		cgpu->diff1 = 0;
 		cgpu->diff_accepted = 0;
 		cgpu->diff_rejected = 0;
@@ -7457,7 +7455,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
 		                total_stale,
 		                total_diff_rejected + total_diff_stale, total_diff_accepted,
 		                hw_errors,
-		                total_bad_diff1, total_bad_diff1 + total_diff1);
+		                total_bad_nonces, total_bad_nonces + total_diff1);
 		unlock_curses();
 	}
 #endif
@@ -7467,7 +7465,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	uHr[5] = ' ';
 	
 	percentf4(rejpcbuf, sizeof(rejpcbuf), total_diff_rejected + total_diff_stale, total_diff_accepted);
-	percentf4(bnbuf, sizeof(bnbuf), total_bad_diff1, total_diff1);
+	percentf4(bnbuf, sizeof(bnbuf), total_bad_nonces, total_diff1);
 	
 	snprintf(logstatusline, sizeof(logstatusline),
 	         "%s%ds:%s avg:%s u:%s | A:%d R:%d+%d(%s) HW:%d/%s",
@@ -8606,8 +8604,8 @@ void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_
 	++cgpu->hw_errors;
 	if (bad_nonce_p)
 	{
-		total_bad_diff1 += nonce_diff;
-		cgpu->bad_diff1 += nonce_diff;
+		++total_bad_nonces;
+		++cgpu->bad_nonces;
 	}
 	mutex_unlock(&stats_lock);
 
@@ -8679,9 +8677,9 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 		}
 	
 	mutex_lock(&stats_lock);
-	total_diff1       += nonce_diff;
-	thr ->cgpu->diff1 += nonce_diff;
-	work->pool->diff1 += nonce_diff;
+	total_diff1++;
+	thr->cgpu->diff1++;
+	work->pool->diff1++;
 	thr->cgpu->last_device_valid_work = time(NULL);
 	mutex_unlock(&stats_lock);
 	
@@ -10939,8 +10937,6 @@ int main(int argc, char *argv[])
 		applog(LOG_NOTICE, "Detected scrypt algorithm");
 		opt_scrypt = true;
 	}
-	if (opt_scrypt)
-		nonce_diff = 1. / 0x10000;
 #endif
 	detect_algo = 0;
 

+ 5 - 5
miner.h

@@ -499,7 +499,7 @@ struct cgpu_info {
 	int accepted;
 	int rejected;
 	int stale;
-	double bad_diff1;
+	int bad_nonces;
 	int hw_errors;
 	double rolling;
 	double total_mhashes;
@@ -555,7 +555,7 @@ struct cgpu_info {
 	int gpu_powertune;
 	float gpu_vddc;
 #endif
-	double diff1;
+	int diff1;
 	double diff_accepted;
 	double diff_rejected;
 	double diff_stale;
@@ -1098,11 +1098,11 @@ extern double total_rolling;
 extern double total_mhashes_done;
 extern unsigned int new_blocks;
 extern unsigned int found_blocks;
-extern int total_accepted, total_rejected;
+extern int total_accepted, total_rejected, total_diff1;;
+extern int total_bad_nonces;
 extern int total_getworks, total_stale, total_discarded;
 extern uint64_t total_bytes_rcvd, total_bytes_sent;
 #define total_bytes_xfer (total_bytes_rcvd + total_bytes_sent)
-extern double total_diff1, total_bad_diff1;
 extern double total_diff_accepted, total_diff_rejected, total_diff_stale;
 extern unsigned int local_work;
 extern unsigned int total_go, total_ro;
@@ -1204,7 +1204,7 @@ struct pool {
 	int seq_rejects;
 	int seq_getfails;
 	int solved;
-	double diff1;
+	int diff1;
 	char diff[8];
 	int quota;
 	int quota_gcd;