Browse Source

Simplify submit_nonce loop and avoid potentially missing FOUND - 1 entry. Reported by Luke-Jr.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
8171ceab85
  1. 54
      findnonce.c

54
findnonce.c

@ -161,29 +161,13 @@ struct pc_data {
pthread_t pth; pthread_t pth;
}; };
static void *postcalc_hash(void *userdata) static void send_nonce(struct pc_data *pcd, cl_uint nonce)
{ {
struct pc_data *pcd = (struct pc_data *)userdata;
struct thr_info *thr = pcd->thr;
dev_blk_ctx *blk = &pcd->work->blk; dev_blk_ctx *blk = &pcd->work->blk;
struct work *work = pcd->work; struct thr_info *thr = pcd->thr;
cl_uint A, B, C, D, E, F, G, H; cl_uint A, B, C, D, E, F, G, H;
struct work *work = pcd->work;
cl_uint W[16]; cl_uint W[16];
cl_uint nonce = 0;
int entry = 0;
pthread_detach(pthread_self());
cycle:
while (entry < FOUND) {
if (pcd->res[entry]) {
nonce = pcd->res[entry++];
break;
}
entry++;
}
if (entry == FOUND)
goto out;
A = blk->cty_a; B = blk->cty_b; A = blk->cty_a; B = blk->cty_b;
C = blk->cty_c; D = blk->cty_d; C = blk->cty_c; D = blk->cty_d;
@ -215,20 +199,40 @@ cycle:
FR(48); PFR(56); FR(48); PFR(56);
if (likely(H == 0xA41F32E7)) { if (likely(H == 0xA41F32E7)) {
if (unlikely(submit_nonce(thr, work, nonce) == false)) { if (unlikely(submit_nonce(thr, work, nonce) == false))
applog(LOG_ERR, "Failed to submit work, exiting"); applog(LOG_ERR, "Failed to submit work, exiting");
goto out;
}
} else { } else {
if (opt_debug) if (opt_debug)
applog(LOG_DEBUG, "No best_g found! Error in OpenCL code?"); applog(LOG_DEBUG, "No best_g found! Error in OpenCL code?");
hw_errors++; hw_errors++;
thr->cgpu->hw_errors++; thr->cgpu->hw_errors++;
} }
if (entry < FOUND) }
goto cycle;
out: static void *postcalc_hash(void *userdata)
{
struct pc_data *pcd = (struct pc_data *)userdata;
struct thr_info *thr = pcd->thr;
int entry = 0, nonces = 0;
pthread_detach(pthread_self());
do {
if (pcd->res[entry]) {
send_nonce(pcd, pcd->res[entry]);
nonces++;
}
} while (++entry < FOUND);
free(pcd); free(pcd);
if (unlikely(!nonces)) {
if (opt_debug)
applog(LOG_DEBUG, "No nonces found! Error in OpenCL code?");
hw_errors++;
thr->cgpu->hw_errors++;
}
return NULL; return NULL;
} }

Loading…
Cancel
Save