Browse Source

Merge commit '67f89ef' into cg_merges_20130619a

Conflicts:
	api.c
	miner.c
	usbutils.c
	usbutils.h
Luke Dashjr 12 years ago
parent
commit
c39a7fd8f8
4 changed files with 19 additions and 10 deletions
  1. 3 3
      api.c
  2. 1 2
      driver-opencl.c
  3. 13 5
      miner.c
  4. 2 0
      miner.h

+ 3 - 3
api.c

@@ -1485,7 +1485,7 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	char buf[TMPBUFSIZ];
 	int n = 0, i;
 
-	cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
+	cgpu_utility(cgpu);
 
 	rd_lock(&devices_lock);
 	for (i = 0; i < total_devices; ++i) {
@@ -1519,7 +1519,7 @@ static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	char buf[TMPBUFSIZ];
 	int n = 0, i;
 
-	cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
+	cgpu_utility(cgpu);
 
 	rd_lock(&devices_lock);
 	for (i = 0; i < total_devices; ++i) {
@@ -1536,7 +1536,7 @@ static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	root = api_add_string(root, "Status", status2str(cgpu->status), false);
 	if (cgpu->temp)
 		root = api_add_temp(root, "Temperature", &cgpu->temp, false);
-	double mhs = cgpu->total_mhashes / total_secs;
+	double mhs = cgpu->total_mhashes / cgpu_runtime(cgpu);
 	root = api_add_mhs(root, "MHS av", &mhs, false);
 	char mhsname[27];
 	sprintf(mhsname, "MHS %ds", opt_log_interval);

+ 1 - 2
driver-opencl.c

@@ -265,7 +265,6 @@ extern void enable_curses(void);
 #endif
 
 extern int mining_threads;
-extern double total_secs;
 extern int opt_g_threads;
 extern bool ping;
 extern bool opt_loginput;
@@ -856,7 +855,7 @@ retry:
 		bool mhash_base = true;
 
 		displayed_rolling = cgpu->rolling;
-		displayed_total = cgpu->total_mhashes / total_secs;
+		displayed_total = cgpu->total_mhashes / cgpu_runtime(cgpu);
 		if (displayed_rolling < 1) {
 			displayed_rolling *= 1000;
 			displayed_total *= 1000;

+ 13 - 5
miner.c

@@ -2208,6 +2208,12 @@ double stats_elapsed(struct cgminer_stats *stats)
 	return elapsed;
 }
 
+double cgpu_utility(struct cgpu_info *cgpu)
+{
+	double dev_runtime = cgpu_runtime(cgpu);
+	return cgpu->utility = cgpu->accepted / dev_runtime * 60;
+}
+
 /* Convert a uint64_t value into a truncated string for displaying with its
  * associated suitable for Mega, Giga etc. Buf array needs to be long enough */
 static void suffix_string(uint64_t val, char *buf, int sigdigits)
@@ -2377,12 +2383,14 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 	enum h2bs_fmt hashrate_style = for_curses ? H2B_SHORT : H2B_SPACED;
 	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[hashrate_style]];
 	char rejpcbuf[6];
+	double dev_runtime;
 	
 	if (!opt_show_procs)
 		cgpu = cgpu->device;
 	
-	cgpu->utility = cgpu->accepted / total_secs * 60;
-	cgpu->utility_diff1 = cgpu->diff_accepted / total_secs * 60;
+	dev_runtime = cgpu_runtime(cgpu);
+	cgpu_utility(cgpu);
+	cgpu->utility_diff1 = cgpu->diff_accepted / dev_runtime * 60;
 	
 	double rolling = cgpu->rolling;
 	double mhashes = cgpu->total_mhashes;
@@ -2397,8 +2405,8 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 	if (!opt_show_procs)
 		for (struct cgpu_info *slave = cgpu; (slave = slave->next_proc); )
 		{
-			slave->utility = slave->accepted / total_secs * 60;
-			slave->utility_diff1 = slave->diff_accepted / total_secs * 60;
+			slave->utility = slave->accepted / dev_runtime * 60;
+			slave->utility_diff1 = slave->diff_accepted / dev_runtime * 60;
 			
 			rolling += slave->rolling;
 			mhashes += slave->total_mhashes;
@@ -2414,7 +2422,7 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 	ti_hashrate_bufstr(
 		(char*[]){cHr, aHr, uHr},
 		1e6*rolling,
-		1e6*mhashes / total_secs,
+		1e6*mhashes / dev_runtime,
 		utility_to_hashrate(wutil),
 		hashrate_style);
 

+ 2 - 0
miner.h

@@ -1265,6 +1265,8 @@ extern void wlogprint(const char *f, ...) FORMAT_SYNTAX_CHECK(printf, 1, 2);
 extern int curses_int(const char *query);
 extern char *curses_input(const char *query);
 extern double stats_elapsed(struct cgminer_stats *);
+#define cgpu_runtime(cgpu)  stats_elapsed(&((cgpu)->cgminer_stats))
+extern double cgpu_utility(struct cgpu_info *);
 extern void kill_work(void);
 extern int prioritize_pools(char *param, int *pid);
 extern void validate_pool_priorities(void);