The second_run bool in libbitfury should be per device. Microoptimise its and job_switched usage, removing the unused results array for NF1 devices.
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
diff --git a/driver-bitfury.h b/driver-bitfury.h
index e802915..d3a3435 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -86,8 +86,8 @@ struct bitfury_info {
struct bitfury_payload opayload;
unsigned newbuf[17];
unsigned oldbuf[17];
- int job_switched;
- unsigned int results[16];
+ bool job_switched;
+ bool second_run;
struct work *work;
struct work *owork;
};
diff --git a/libbitfury.c b/libbitfury.c
index 17f2cc1..bd10ff0 100644
--- a/libbitfury.c
+++ b/libbitfury.c
@@ -293,7 +293,6 @@ bool bitfury_checkresults(struct thr_info *thr, struct work *work, uint32_t nonc
bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
struct bitfury_info *info)
{
- static unsigned second_run;
unsigned *newbuf = info->newbuf;
unsigned *oldbuf = info->oldbuf;
struct bitfury_payload *p = &(info->payload);
@@ -314,25 +313,27 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
info->job_switched = newbuf[16] != oldbuf[16];
- if (second_run && info->job_switched) {
- int i;
+ if (likely(info->second_run)) {
+ if (info->job_switched) {
+ int i;
- for (i = 0; i < 16; i++) {
- if (oldbuf[i] != newbuf[i] && info->owork) {
- uint32_t nonce; //possible nonce
+ for (i = 0; i < 16; i++) {
+ if (oldbuf[i] != newbuf[i] && info->owork) {
+ uint32_t nonce; //possible nonce
- nonce = decnonce(newbuf[i]);
- if (bitfury_checkresults(thr, info->owork, nonce))
- info->nonces++;
+ nonce = decnonce(newbuf[i]);
+ if (bitfury_checkresults(thr, info->owork, nonce))
+ info->nonces++;
+ }
}
- }
- memcpy(op, p, sizeof(struct bitfury_payload));
- memcpy(oldbuf, newbuf, 17 * 4);
- }
+ memcpy(op, p, sizeof(struct bitfury_payload));
+ memcpy(oldbuf, newbuf, 17 * 4);
+ }
+ } else
+ info->second_run = true;
cgsleep_ms(BITFURY_REFRESH_DELAY);
- second_run = 1;
return true;
}