Merge pull request #538 from kanoi/master bab additions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
diff --git a/driver-bab.c b/driver-bab.c
index e09d5f2..eaf7d42 100644
--- a/driver-bab.c
+++ b/driver-bab.c
@@ -2252,6 +2252,7 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
{
struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
uint64_t history_good[BAB_MAXCHIPS], history_bad[BAB_MAXCHIPS];
+ uint64_t his_good_tot, his_bad_tot;
double history_elapsed[BAB_MAXCHIPS], diff;
bool elapsed_is_good[BAB_MAXCHIPS];
int speeds[BAB_CHIP_SPEEDS];
@@ -2261,7 +2262,7 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
int spi_work, chip_work, i, to, j, sp, bank, chip_off;
struct timeval now;
double elapsed, ghs;
- float ghs_sum, ghs_tot;
+ float ghs_sum, his_ghs_tot;
float tot, hw;
K_ITEM *item;
@@ -2331,7 +2332,7 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
}
K_RUNLOCK(babinfo->nfree_list);
- ghs_tot = 0;
+ his_ghs_tot = 0;
for (i = 0; i < babinfo->chips; i += CHIPS_PER_STAT) {
to = i + CHIPS_PER_STAT - 1;
if (to >= babinfo->chips)
@@ -2545,10 +2546,21 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
snprintf(buf, sizeof(buf), "Sum History GHs "FMT_RANGE, i, to);
root = api_add_avg(root, buf, &ghs_sum, true);
- ghs_tot += ghs_sum;
+ his_ghs_tot += ghs_sum;
}
- root = api_add_avg(root, "Total History GHs", &ghs_tot, true);
+ root = api_add_avg(root, "Total History GHs", &his_ghs_tot, true);
+
+ his_good_tot = his_bad_tot = 0;
+ for (i = 0; i < babinfo->chips; i++) {
+ his_good_tot += history_good[i];
+ his_bad_tot += history_bad[i];
+ }
+ if (his_good_tot + his_bad_tot)
+ tot = 100.0 * (float)his_bad_tot / (float)(his_good_tot + his_bad_tot);
+ else
+ tot = 0.0;
+ root = api_add_avg(root, "Total History HW%", &tot, true);
for (sp = 0; sp < BAB_CHIP_SPEEDS; sp++) {
if (sp < (BAB_CHIP_SPEEDS - 1))
@@ -2732,11 +2744,36 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
static void bab_get_statline_before(char *buf, size_t bufsiz, struct cgpu_info *babcgpu)
{
struct bab_info *babinfo = (struct bab_info *)(babcgpu->device_data);
+#if UPDATE_HISTORY
+ struct timeval now;
+ double elapsed;
+ int i, dead = 0;
+
+ cgtime(&now);
+ elapsed = tdiff(&now, &(babcgpu->dev_start_tv));
+ // At least get 15s of nonces before saying anything is dead
+ if (elapsed > 15.0) {
+ K_RLOCK(babinfo->nfree_list);
+ for (i = 0; i < babinfo->chips; i++) {
+ if (babinfo->good_nonces[i]->count == 0 &&
+ babinfo->bad_nonces[i]->count > 1)
+ dead++;
+ }
+ K_RUNLOCK(babinfo->nfree_list);
+ }
+
+ tailsprintf(buf, bufsiz, "%d.%02d.%03d D:%03d | ",
+ babinfo->banks,
+ babinfo->boards,
+ babinfo->chips,
+ dead);
+#else
tailsprintf(buf, bufsiz, "B:%d B:%02d C:%03d | ",
babinfo->banks,
babinfo->boards,
babinfo->chips);
+#endif
}
#endif