Skip to content

Commit

Permalink
add HW error check
Browse files Browse the repository at this point in the history
  • Loading branch information
NaN-git committed Aug 31, 2016
1 parent 8331a09 commit 2e0f796
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions algorithm.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ static cl_int queue_ethash_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u
cl_ulong DAGSize = EthGetDAGSize(blk->work->EpochNumber);
cl_uint DAGItems = (cl_uint)(DAGSize / 64);

le_target = *(cl_ulong *)(blk->work->target + 24);
le_target = *(cl_ulong *)(blk->work->device_target + 24);

// DO NOT flip80.
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 32, blk->work->data, 0, NULL, NULL);
Expand Down Expand Up @@ -1162,7 +1162,7 @@ static algorithm_settings_t algos[] = {
{ "blake256r14", ALGO_BLAKE, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x00000000UL, 0, 128, 0, blake256_regenhash, precalc_hash_blake256, queue_blake_kernel, gen_hash, NULL },
{ "vanilla", ALGO_VANILLA, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x000000ffUL, 0, 128, 0, blakecoin_regenhash, precalc_hash_blakecoin, queue_blake_kernel, gen_hash, NULL },

{ "ethash", ALGO_ETHASH, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x00000000UL, 0, 128, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, append_ethash_compiler_options },
{ "ethash", ALGO_ETHASH, "", (1ULL << 32), (1ULL << 32), 1, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x00000000UL, 0, 128, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, ethash_regenhash, NULL, queue_ethash_kernel, gen_hash, append_ethash_compiler_options },
// Terminator (do not remove)
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL }
};
Expand Down
2 changes: 1 addition & 1 deletion algorithm/ethash.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ void ethash_regenhash(struct work *work)
char *DbgHash = bin2hex(work->hash, 32);

applog(LOG_DEBUG, "Regenhash result: %s.", DbgHash);
applog(LOG_DEBUG, "Last ulong: 0x%016llX.", __builtin_bswap64(*((uint64_t *)(work->hash + 0))));
applog(LOG_DEBUG, "Last ulong: 0x%016llX.", bswap_64(*((uint64_t *)(work->hash + 0))));
free(DbgHash);
}
39 changes: 22 additions & 17 deletions sgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3164,7 +3164,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, char *curl_err_s
if(work->pool->algorithm.type == ALGO_ETHASH)
{
s = (char *)malloc(sizeof(char) * (128 + 16 + 512));
uint64_t tmp = __builtin_bswap64(work->Nonce);
uint64_t tmp = bswap_64(work->Nonce);
char *ASCIIMixHash = bin2hex(work->mixhash, 32);
char *ASCIIPoWHash = bin2hex(work->data, 32);
char *ASCIINonce = bin2hex(&tmp, 8);
Expand Down Expand Up @@ -5725,7 +5725,7 @@ static void *stratum_sthread(void *userdata)

applog(LOG_DEBUG, "stratum_sthread() algorithm = %s", pool->algorithm.name);

uint64_t tmp = __builtin_bswap64(work->Nonce);
uint64_t tmp = bswap_64(work->Nonce);
char *ASCIIMixHash = bin2hex(work->mixhash, 32);
char *ASCIIPoWHash = bin2hex(work->data, 32);
char *ASCIINonce = bin2hex(&tmp, 8);
Expand Down Expand Up @@ -7339,12 +7339,14 @@ bool test_nonce(struct work *work, uint32_t nonce)
|| work->pool->algorithm.type == ALGO_YESCRYPT || work->pool->algorithm.type == ALGO_YESCRYPT_MULTI) {
diff1targ = ((uint32_t *)work->target)[7];
}
else if (work->pool->algorithm.type == ALGO_ETHASH) {
uint64_t target = *(uint64_t*) (work->device_target + 24);
return (bswap_64(*(uint64_t*) work->hash) <= target);
}
else {
diff1targ = work->pool->algorithm.diff1targ;
}

if(work->pool->algorithm.type == ALGO_ETHASH) return(true);

return (le32toh(*hash_32) <= diff1targ);
}

Expand Down Expand Up @@ -7380,17 +7382,13 @@ bool submit_tested_work(struct thr_info *thr, struct work *work)
struct work *work_out;
update_work_stats(thr, work);

if(work->pool->algorithm.type == ALGO_ETHASH)
{
uint64_t LETarget = ((uint64_t *)work->target)[3];

if(__builtin_bswap64(((uint64_t *)work->hash)[0]) > LETarget)
{
applog(LOG_INFO, "%s %d: Share above target", thr->cgpu->drv->name, thr->cgpu->device_id);
applog(LOG_DEBUG, "Share failed 0x%016llX <= 0x%016llX.", __builtin_bswap64(((uint64_t *)work->hash)[3]), LETarget);
return(false);
}

if(work->pool->algorithm.type == ALGO_ETHASH) {
uint64_t LETarget = ((uint64_t *)work->target)[3];

if(bswap_64(((uint64_t *)work->hash)[0]) > LETarget) {
// applog(LOG_INFO, "%s %d: Share above target", thr->cgpu->drv->name, thr->cgpu->device_id);
return(false);
}
}
else if (!fulltest(work->hash, work->target)) {
applog(LOG_INFO, "%s %d: Share above target", thr->cgpu->drv->name,
Expand Down Expand Up @@ -7494,8 +7492,15 @@ static void hash_sole_work(struct thr_info *mythr)

if (work->pool->algorithm.type == ALGO_NEOSCRYPT) {
set_target_neoscrypt(work->device_target, work->device_diff, work->thr_id);
} else if(work->pool->algorithm.type != ALGO_ETHASH) {
set_target(work->device_target, work->device_diff, work->pool->algorithm.diff_multiplier2, work->thr_id);
} else {
if (work->pool->algorithm.type == ALGO_ETHASH) {
double mult = (1 << 26);
work->device_diff = MIN(work->work_difficulty, mult);
*(uint64_t*) (work->device_target + 24) = bits64 / work->device_diff;
work->device_diff /= mult;
}
else
set_target(work->device_target, work->device_diff, work->pool->algorithm.diff_multiplier2, work->thr_id);
}

do {
Expand Down

0 comments on commit 2e0f796

Please sign in to comment.