Add local thread count to info, store hw error count, and make share submission debug only.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
diff --git a/cpu-miner.c b/cpu-miner.c
index 2d6e233..89a7654 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -149,6 +149,7 @@ static pthread_mutex_t get_lock;
static double total_mhashes_done;
static struct timeval total_tv_start, total_tv_end;
static int accepted, rejected;
+int hw_errors;
struct option_help {
@@ -336,6 +337,7 @@ static bool submit_upstream_work(CURL *curl, const struct work *work)
json_t *val, *res;
char s[345];
bool rc = false;
+ const int thr_id = work->thr_id;
/* build hex string */
hexstr = bin2hex(work->data, sizeof(work->data));
@@ -365,12 +367,17 @@ static bool submit_upstream_work(CURL *curl, const struct work *work)
* rejected values but the chance of two submits completing at the
* same time is zero so there is no point adding extra locking */
if (json_is_true(res)) {
+ thr_info[thr_id].accepted++;
accepted++;
- applog(LOG_INFO, "PROOF OF WORK RESULT: true (yay!!!)");
+ if (opt_debug)
+ applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)");
} else {
+ thr_info[thr_id].rejected++;
rejected++;
- applog(LOG_INFO, "PROOF OF WORK RESULT: false (booooo)");
+ if (opt_debug)
+ applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)");
}
+ applog(LOG_INFO, "Thread: %d Accepted: %d Rejected: %d HW errors: %d", thr_id, thr_info[thr_id].accepted, thr_info[thr_id].rejected, thr_info[thr_id].hw_errors);
json_decref(val);
@@ -561,9 +568,9 @@ static void hashmeter(int thr_id, struct timeval *diff,
timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
total_secs = (double)total_diff.tv_sec +
((double)total_diff.tv_usec / 1000000.0);
- applog(LOG_INFO, "[%.2f | %.2f Mhash/s] [%d Accepted] [%d Rejected]",
+ applog(LOG_INFO, "[%.2f | %.2f Mhash/s] [%d Accepted] [%d Rejected] [%d HW errors]",
local_mhashes_done / local_secs,
- total_mhashes_done / total_secs, accepted, rejected);
+ total_mhashes_done / total_secs, accepted, rejected, hw_errors);
local_mhashes_done = 0;
}
@@ -677,6 +684,8 @@ static bool submit_work_async(struct thr_info *thr, const struct work *work_in)
}
memcpy(&sd->work_in, work_in, sizeof(struct work));
+ /* Pass the thread id to the work struct for per-thread accounting */
+ sd->work_in.thr_id = thr->id;
if (pthread_create(&sd->pth, NULL, submit_work, (void *)sd)) {
applog(LOG_ERR, "Failed to create submit_thread");
@@ -810,7 +819,8 @@ static void *miner_thread(void *userdata)
/* if nonce found, submit work */
if (unlikely(rc)) {
- applog(LOG_INFO, "CPU %d found something?", cpu_from_thr_id(thr_id));
+ if (opt_debug)
+ applog(LOG_DEBUG, "CPU %d found something?", cpu_from_thr_id(thr_id));
if (!submit_work_async(mythr, &work))
break;
}
@@ -960,7 +970,8 @@ static void *gpuminer_thread(void *userdata)
{ applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed."); goto out; }
for (i = 0; i < 127; i++) {
if (res[i]) {
- applog(LOG_INFO, "GPU %d found something?", gpu_from_thr_id(thr_id));
+ if (opt_debug)
+ applog(LOG_DEBUG, "GPU %d found something?", gpu_from_thr_id(thr_id));
postcalc_hash_async(mythr, work, res[i]);
} else
break;
diff --git a/findnonce.c b/findnonce.c
index de83701..8cc21c8 100644
--- a/findnonce.c
+++ b/findnonce.c
@@ -200,8 +200,12 @@ static void *postcalc_hash(void *userdata)
}
}
out:
- if (unlikely(best_g == ~0))
- applog(LOG_ERR, "No best_g found! Error in OpenCL code?");
+ if (unlikely(best_g == ~0)) {
+ if (opt_debug)
+ applog(LOG_DEBUG, "No best_g found! Error in OpenCL code?");
+ hw_errors++;
+ thr->hw_errors++;
+ }
free(pcd);
}
diff --git a/miner.h b/miner.h
index a179e1d..bb42cb5 100644
--- a/miner.h
+++ b/miner.h
@@ -114,6 +114,9 @@ struct thr_info {
int id;
pthread_t pth;
struct thread_q *q;
+ int accepted;
+ int rejected;
+ int hw_errors;
};
static inline uint32_t swab32(uint32_t v)
@@ -195,6 +198,7 @@ struct work_restart {
};
extern pthread_mutex_t time_lock;
+extern int hw_errors;
extern bool use_syslog;
extern struct thr_info *thr_info;
extern int longpoll_thr_id;
@@ -224,6 +228,8 @@ struct work {
uint32_t res_nonce;
uint32_t valid;
dev_blk_ctx blk;
+
+ int thr_id;
};
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);