Commit 54f1b80824eecdd53a22aaa347f792b5b6c8e647

Con Kolivas 2012-07-14T22:19:55

Free the scratchbuf memory allocated in scrypt and don't check if CPUs are sick since they can't be. Prepare for khash hash rates in display.

diff --git a/cgminer.c b/cgminer.c
index f5044e2..6002927 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3394,9 +3394,13 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	double utility, efficiency = 0.0;
 	static double local_mhashes_done = 0;
 	static double rolling = 0;
-	double local_mhashes = (double)hashes_done / 1000000.0;
+	double local_mhashes;
 	bool showlog = false;
 
+	if (opt_scrypt)
+		local_mhashes = (double)hashes_done / 1000.0;
+	else
+		local_mhashes = (double)hashes_done / 1000000.0;
 	/* Update the last time this thread reported in */
 	if (thr_id >= 0) {
 		gettimeofday(&thr_info[thr_id].last, NULL);
@@ -3472,9 +3476,9 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
 	efficiency = total_getworks ? total_accepted * 100.0 / total_getworks : 0.0;
 
-	sprintf(statusline, "%s(%ds):%.1f (avg):%.1f Mh/s | Q:%d  A:%d  R:%d  HW:%d  E:%.0f%%  U:%.1f/m",
+	sprintf(statusline, "%s(%ds):%.1f (avg):%.1f %sh/s | Q:%d  A:%d  R:%d  HW:%d  E:%.0f%%  U:%.1f/m",
 		want_per_device_stats ? "ALL " : "",
-		opt_log_interval, rolling, total_mhashes_done / total_secs,
+		opt_log_interval, rolling, total_mhashes_done / total_secs, opt_scrypt ? "K" : "M",
 		total_getworks, total_accepted, total_rejected, hw_errors, efficiency, utility);
 
 
@@ -4604,6 +4608,10 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			if (thr->getwork || *denable == DEV_DISABLED)
 				continue;
 
+#ifdef WANT_CPUMINE
+			if (!strcmp(cgpu->api->dname, "cpu"))
+				continue;
+#endif
 			if (cgpu->rolling < WATCHDOG_LOW_HASH)
 				cgpu->low_count++;
 			else
diff --git a/scrypt.c b/scrypt.c
index 569eeb9..4334bcf 100644
--- a/scrypt.c
+++ b/scrypt.c
@@ -434,19 +434,20 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char *pmidstate, unsig
 		data[19] = n;
 		tmp_hash7 = scrypt_1024_1_1_256_sp(data, scratchbuf);
 
-		if (tmp_hash7 <= Htarg) {
+		if (unlikely(tmp_hash7 <= Htarg)) {
 			((uint32_t *)pdata)[19] = byteswap(n);
 			*last_nonce = n;
 			ret = true;
 			break;
 		}
 
-		if ((n >= max_nonce) || thr->work_restart) {
+		if (unlikely((n >= max_nonce) || thr->work_restart)) {
 			*last_nonce = n;
 			break;
 		}
 	}
 out_ret:
+	free(scratchbuf);;
 	return ret;
 }