Browse Source

get_master_rolling_hashrate -> get_proc_rolling_hashrate
The concept of calculate driver's own rolling hashrate only for
the "master" device is flawed. Better to do it in more general way
and implement driver's own rolling hashrate on per-processor basis.

Vitalii Demianets 11 years ago
parent
commit
e303de6eb4
4 changed files with 11 additions and 17 deletions
  1. 1 4
      api.c
  2. 8 8
      driver-titan.c
  3. 1 4
      miner.c
  4. 1 1
      miner.h

+ 1 - 4
api.c

@@ -1486,7 +1486,7 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 		if (proc->deven != DEV_DISABLED)
 			enabled = true;
 		total_mhashes += proc->total_mhashes;
-		rolling += proc->rolling;
+		rolling += proc->drv->get_proc_rolling_hashrate ? proc->drv->get_proc_rolling_hashrate(proc) : proc->rolling;
 		utility += proc->utility;
 		accepted += proc->accepted;
 		rejected += proc->rejected;
@@ -1513,9 +1513,6 @@ void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson,
 			break;
 	}
 
-	if ((!per_proc) && (cgpu->device == cgpu) && (cgpu->drv->get_master_rolling_hashrate))
-		rolling = cgpu->drv->get_master_rolling_hashrate(cgpu);
-
 	root = api_add_int(root, "PGA", &n, true);
 	root = api_add_device_identifier(root, cgpu);
 	root = api_add_string(root, "Enabled", bool2str(enabled), false);

+ 8 - 8
driver-titan.c

@@ -129,17 +129,17 @@ static void knc_titan_zero_stats(struct cgpu_info *cgpu)
 	}
 }
 
-static double knc_titan_get_device_rolling_hashrate(struct cgpu_info *device)
+static double knc_titan_get_die_rolling_hashrate(struct cgpu_info *device)
 {
-	int asic = ((struct knc_titan_die *)device->thr[0]->cgpu_data)->asicno;
+	struct knc_titan_die *die = device->thr[0]->cgpu_data;
+	int asicno = die->asicno;
+	int dieno = die->dieno;
 	struct knc_titan_info *knc = device->device_data;
 	double hashrate = 0.0;
-	int dieno, i;
+	int i;
 
-	for (dieno = 0; dieno < KNC_TITAN_DIES_PER_ASIC; ++dieno) {
-		for (i = 0; i < HASHES_BUF_ENTRIES; ++i) {
-			hashrate += (double)knc->dies[asic][dieno].hashes_buf[i] / 1.0e6;
-		}
+	for (i = 0; i < HASHES_BUF_ENTRIES; ++i) {
+		hashrate += (double)knc->dies[asicno][dieno].hashes_buf[i] / 1.0e6;
 	}
 
 	return hashrate / ((double)(HASHES_BUF_ENTRIES * HASHES_BUF_ONE_ENTRY_TIME));
@@ -947,7 +947,7 @@ struct device_drv knc_titan_drv =
 	.prepare_work = knc_titan_prepare_work,
 
 	/* additional statistics */
-	.get_master_rolling_hashrate = knc_titan_get_device_rolling_hashrate,
+	.get_proc_rolling_hashrate = knc_titan_get_die_rolling_hashrate,
 	.zero_stats = knc_titan_zero_stats,
 
 	/* TUI support - e.g. setting clock via UI */

+ 1 - 4
miner.c

@@ -4159,7 +4159,7 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 			slave->utility = slave->accepted / dev_runtime * 60;
 			slave->utility_diff1 = slave->diff_accepted / dev_runtime * 60;
 			
-			rolling += slave->rolling;
+			rolling += drv->get_proc_rolling_hashrate ? drv->get_proc_rolling_hashrate(slave) : slave->rolling;
 			mhashes += slave->total_mhashes;
 			if (opt_weighed_stats)
 			{
@@ -4184,9 +4184,6 @@ void get_statline3(char *buf, size_t bufsz, struct cgpu_info *cgpu, bool for_cur
 		}
 	}
 
-	if ((cgpu->device == cgpu) && (drv->get_master_rolling_hashrate))
-		rolling = drv->get_master_rolling_hashrate(cgpu);
-
 	double wtotal = (waccepted + wnotaccepted);
 	
 	multi_format_unit_array2(

+ 1 - 1
miner.h

@@ -337,7 +337,7 @@ struct device_drv {
 	void (*proc_tui_wlogprint_choices)(struct cgpu_info *);
 	const char *(*proc_tui_handle_choice)(struct cgpu_info *, int input);
 	void (*zero_stats)(struct cgpu_info *);
-	double (*get_master_rolling_hashrate)(struct cgpu_info *);
+	double (*get_proc_rolling_hashrate)(struct cgpu_info *);
 
 	// Thread-specific functions
 	bool (*thread_prepare)(struct thr_info *);