Make the log show what the thread is: cpu or gpu and what number.
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
diff --git a/cpu-miner.c b/cpu-miner.c
index 89a7654..5f597f8 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -337,7 +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;
+ struct cgpu_info *cgpu = thr_info[work->thr_id].cgpu;
/* build hex string */
hexstr = bin2hex(work->data, sizeof(work->data));
@@ -367,17 +367,18 @@ 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++;
+ cgpu->accepted++;
accepted++;
if (opt_debug)
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)");
} else {
- thr_info[thr_id].rejected++;
+ cgpu->rejected++;
rejected++;
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);
+ applog(LOG_INFO, "%sPU: %d Accepted: %d Rejected: %d HW errors: %d",
+ cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, cgpu->accepted, cgpu->rejected, cgpu->hw_errors);
json_decref(val);
@@ -1397,9 +1398,20 @@ int main (int argc, char *argv[])
/* start GPU mining threads */
for (i = 0; i < gpu_threads; i++) {
int gpu = i % nDevs;
- thr = &thr_info[i];
+ thr = &thr_info[i];
thr->id = i;
+ if (! (i % opt_g_threads)) {
+ thr->cgpu = calloc(1, sizeof(struct cgpu_info));
+ if (unlikely(!thr->cgpu)) {
+ applog(LOG_ERR, "Failed to calloc cgpu_info");
+ return 1;
+ }
+ thr->cgpu->is_gpu = 1;
+ thr->cgpu->cpu_gpu = gpu;
+ } else
+ thr->cgpu = thr_info[i - (i % opt_g_threads)].cgpu;
+
thr->q = tq_new();
if (!thr->q)
return 1;
@@ -1426,6 +1438,16 @@ int main (int argc, char *argv[])
thr = &thr_info[i];
thr->id = i;
+ if (! (i % opt_g_threads)) {
+ thr->cgpu = calloc(1, sizeof(struct cgpu_info));
+ if (unlikely(!thr->cgpu)) {
+ applog(LOG_ERR, "Failed to calloc cgpu_info");
+ return 1;
+ }
+ thr->cgpu->cpu_gpu = cpu_from_thr_id(i);
+ } else
+ thr->cgpu = thr_info[cpu_from_thr_id(i - (i % opt_g_threads))].cgpu;
+
thr->q = tq_new();
if (!thr->q)
return 1;
diff --git a/findnonce.c b/findnonce.c
index 8cc21c8..ca9b12f 100644
--- a/findnonce.c
+++ b/findnonce.c
@@ -204,7 +204,7 @@ out:
if (opt_debug)
applog(LOG_DEBUG, "No best_g found! Error in OpenCL code?");
hw_errors++;
- thr->hw_errors++;
+ thr->cgpu->hw_errors++;
}
free(pcd);
}
diff --git a/miner.h b/miner.h
index bb42cb5..a0913f2 100644
--- a/miner.h
+++ b/miner.h
@@ -110,13 +110,19 @@ enum {
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
+struct cgpu_info {
+ int is_gpu;
+ int cpu_gpu;
+ int accepted;
+ int rejected;
+ int hw_errors;
+};
+
struct thr_info {
int id;
pthread_t pth;
struct thread_q *q;
- int accepted;
- int rejected;
- int hw_errors;
+ struct cgpu_info *cgpu;
};
static inline uint32_t swab32(uint32_t v)