Browse Source

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.

Con Kolivas 13 years ago
parent
commit
54f1b80824
2 changed files with 14 additions and 5 deletions
  1. 11 3
      cgminer.c
  2. 3 2
      scrypt.c

+ 11 - 3
cgminer.c

@@ -3394,9 +3394,13 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	double utility, efficiency = 0.0;
 	double utility, efficiency = 0.0;
 	static double local_mhashes_done = 0;
 	static double local_mhashes_done = 0;
 	static double rolling = 0;
 	static double rolling = 0;
-	double local_mhashes = (double)hashes_done / 1000000.0;
+	double local_mhashes;
 	bool showlog = false;
 	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 */
 	/* Update the last time this thread reported in */
 	if (thr_id >= 0) {
 	if (thr_id >= 0) {
 		gettimeofday(&thr_info[thr_id].last, NULL);
 		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;
 	utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
 	efficiency = total_getworks ? total_accepted * 100.0 / total_getworks : 0.0;
 	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 " : "",
 		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);
 		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)
 			if (thr->getwork || *denable == DEV_DISABLED)
 				continue;
 				continue;
 
 
+#ifdef WANT_CPUMINE
+			if (!strcmp(cgpu->api->dname, "cpu"))
+				continue;
+#endif
 			if (cgpu->rolling < WATCHDOG_LOW_HASH)
 			if (cgpu->rolling < WATCHDOG_LOW_HASH)
 				cgpu->low_count++;
 				cgpu->low_count++;
 			else
 			else

+ 3 - 2
scrypt.c

@@ -434,19 +434,20 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char *pmidstate, unsig
 		data[19] = n;
 		data[19] = n;
 		tmp_hash7 = scrypt_1024_1_1_256_sp(data, scratchbuf);
 		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);
 			((uint32_t *)pdata)[19] = byteswap(n);
 			*last_nonce = n;
 			*last_nonce = n;
 			ret = true;
 			ret = true;
 			break;
 			break;
 		}
 		}
 
 
-		if ((n >= max_nonce) || thr->work_restart) {
+		if (unlikely((n >= max_nonce) || thr->work_restart)) {
 			*last_nonce = n;
 			*last_nonce = n;
 			break;
 			break;
 		}
 		}
 	}
 	}
 out_ret:
 out_ret:
+	free(scratchbuf);;
 	return ret;
 	return ret;
 }
 }