Skip to content

Commit

Permalink
Merge pull request #219 from fancyIX/feature/#218
Browse files Browse the repository at this point in the history
Feature/#218
  • Loading branch information
fancyIX authored Jan 3, 2021
2 parents 4f2931f + 4859dc4 commit 5a61ce0
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 19 deletions.
5 changes: 5 additions & 0 deletions algorithm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,11 @@ static algorithm_settings_t algos[] = {
A_NEOSCRYPT("neoscrypt"),
#undef A_NEOSCRYPT

#define A_NEOSCRYPT_XAYA(a) \
{ a, ALGO_NEOSCRYPT_XAYA, "", 1, 65536, 65536, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x0000ffffUL, 0, -1, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, neoscrypt_regenhash, NULL, NULL, queue_neoscrypt_kernel, gen_hash, append_neoscrypt_compiler_options }
A_NEOSCRYPT_XAYA("neoscrypt-xaya"),
#undef A_NEOSCRYPT_XAYA

#define A_PLUCK(a) \
{ a, ALGO_PLUCK, "", 1, 65536, 65536, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x0000ffffUL, 0, -1, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, pluck_regenhash, NULL, NULL, queue_pluck_kernel, gen_hash, append_neoscrypt_compiler_options }
A_PLUCK("pluck"),
Expand Down
1 change: 1 addition & 0 deletions algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef enum {
ALGO_FRESH,
ALGO_WHIRL,
ALGO_NEOSCRYPT,
ALGO_NEOSCRYPT_XAYA,
ALGO_WHIRLPOOLX,
ALGO_LYRA2RE,
ALGO_LYRA2REV2,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
m4_define([v_maj], [0])
m4_define([v_min], [7])
m4_define([v_mic], [2])
m4_define([v_rev], [0])
m4_define([v_rev], [1])
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic-v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])])
m4_define([lt_rev], m4_eval(v_maj + v_min))
Expand Down
4 changes: 2 additions & 2 deletions driver-opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
if (clState->goffset)
p_global_work_offset = (size_t *)&work->blk.nonce;

if (gpu->algorithm.type != ALGO_MTP && gpu->algorithm.type != ALGO_YESCRYPT_NAVI && gpu->algorithm.type != ALGO_YESCRYPT && gpu->algorithm.type != ALGO_NEOSCRYPT) {
if (gpu->algorithm.type != ALGO_MTP && gpu->algorithm.type != ALGO_YESCRYPT_NAVI && gpu->algorithm.type != ALGO_YESCRYPT && gpu->algorithm.type != ALGO_NEOSCRYPT && gpu->algorithm.type != ALGO_NEOSCRYPT_XAYA) {
if (gpu->algorithm.type == ALGO_ARGON2D) {
const uint32_t throughput = gpu->throughput;
const size_t global[] = { 16, throughput };
Expand Down Expand Up @@ -1672,7 +1672,7 @@ clSetKernelArg(clState->yescrypt_gpu_hash_k1, 2, sizeof(uint32_t), &offset);
return -1;
}
}
if (gpu->algorithm.type == ALGO_NEOSCRYPT) {
if (gpu->algorithm.type == ALGO_NEOSCRYPT || gpu->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
cl_uint threads = globalThreads[0];
size_t worksize = globalThreads[0];

Expand Down
8 changes: 4 additions & 4 deletions ocl.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
}

// neoscrypt TC
if (cgpu->algorithm.type == ALGO_NEOSCRYPT && !cgpu->opt_tc) {
if ((cgpu->algorithm.type == ALGO_NEOSCRYPT || cgpu->algorithm.type == ALGO_NEOSCRYPT_XAYA) && !cgpu->opt_tc) {
size_t glob_thread_count;
long max_int;
unsigned char type = 0;
Expand Down Expand Up @@ -835,7 +835,7 @@ if (algorithm->type == ALGO_MTP) {
applog(LOG_ERR, "Error %d: Creating Kernel \"yescrypt_gpu_hash_k2c_r8\" from program. (clCreateKernel)", status);
return NULL;
}
} else if (algorithm->type == ALGO_NEOSCRYPT) {
} else if (algorithm->type == ALGO_NEOSCRYPT || algorithm->type == ALGO_NEOSCRYPT_XAYA) {
clState->neoscrypt_gpu_hash_start=clCreateKernel(clState->program, "neoscrypt_gpu_hash_start", &status);
if (status != CL_SUCCESS) {
applog(LOG_ERR, "Error %d: Creating Kernel \"neoscrypt_gpu_hash_start\" from program. (clCreateKernel)", status);
Expand Down Expand Up @@ -920,7 +920,7 @@ if (algorithm->type == ALGO_YESCRYPT || algorithm->type == ALGO_YESCRYPT_NAVI) {

if (algorithm->rw_buffer_size < 0) {
// calc buffer size for neoscrypt
if (algorithm->type == ALGO_NEOSCRYPT) {
if (algorithm->type == ALGO_NEOSCRYPT || algorithm->type == ALGO_NEOSCRYPT_XAYA) {
/* The scratch/pad-buffer needs 32kBytes memory per thread. */
bufsize = NEOSCRYPT_SCRATCHBUF_SIZE * cgpu->thread_concurrency;
buf1size = 32 * 8 * cgpu->thread_concurrency;
Expand Down Expand Up @@ -1062,7 +1062,7 @@ if (algorithm->type == ALGO_YESCRYPT || algorithm->type == ALGO_YESCRYPT_NAVI) {
return NULL;
}
}
else if (algorithm->type == ALGO_YESCRYPT || algorithm->type == ALGO_YESCRYPT_NAVI || algorithm->type == ALGO_NEOSCRYPT) {
else if (algorithm->type == ALGO_YESCRYPT || algorithm->type == ALGO_YESCRYPT_NAVI || algorithm->type == ALGO_NEOSCRYPT || algorithm->type == ALGO_NEOSCRYPT_XAYA) {
clState->buffer1 = clCreateBuffer(clState->context, CL_MEM_READ_WRITE, buf1size, NULL, &status);
if (status != CL_SUCCESS && !clState->buffer1) {
applog(LOG_DEBUG, "Error %d: clCreateBuffer (buffer1), decrease TC or increase LG", status);
Expand Down
45 changes: 36 additions & 9 deletions sgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ static double get_work_blockdiff(const struct work *work)
return 0;//work->network_diff;
}
// Neoscrypt has the data reversed
if (work->pool->algorithm.type == ALGO_NEOSCRYPT) {
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
diff64 = bswap_64(((uint64_t)(be32toh(*((uint32_t *)(work->data + 72))) & 0xFFFFFF00)) << 8);
numerator = (double)work->pool->algorithm.diff_numerator;
}
Expand Down Expand Up @@ -3148,7 +3148,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, char *curl_err_s

/* build hex string - Make sure to restrict to 80 bytes for Neoscrypt */
int datasize = 128;
if (work->pool->algorithm.type == ALGO_NEOSCRYPT) datasize = 80;
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) datasize = 80;
else if (work->pool->algorithm.type == ALGO_CRE) datasize = 168;
else if (work->pool->algorithm.type == ALGO_DECRED) {
datasize = 192;
Expand Down Expand Up @@ -3509,7 +3509,7 @@ static void calc_diff(struct work *work, double known)

applog(LOG_DEBUG, "calc_diff() algorithm = %s", work->pool->algorithm.name);
// Neoscrypt
if (work->pool->algorithm.type == ALGO_NEOSCRYPT) {
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
dcut64 = (double)*((uint64_t *)(work->target + 22));
}
else {
Expand Down Expand Up @@ -5831,7 +5831,7 @@ static void *stratum_sthread(void *userdata)
applog(LOG_DEBUG, "stratum_sthread() algorithm = %s", pool->algorithm.name);

// Neoscrypt is little endian
if (pool->algorithm.type == ALGO_NEOSCRYPT) {
if (pool->algorithm.type == ALGO_NEOSCRYPT || pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
nonce = htobe32(*((uint32_t *)(work->data + 76)));
//*((uint32_t *)nonce2) = htole32(work->nonce2);
}
Expand Down Expand Up @@ -6653,6 +6653,33 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
/* Add the time encoded in big endianess. */
hex2bin((unsigned char *)&temp, pool->swork.ntime, 4);

/* Add the nbits (big endianess). */
((uint32_t *)work->data)[17] = be32toh(temp);
hex2bin((unsigned char *)&temp, pool->swork.nbit, 4);
((uint32_t *)work->data)[18] = be32toh(temp);
((uint32_t *)work->data)[20] = 0x80000000;
((uint32_t *)work->data)[31] = 0x00000280;
} else if (pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
/* Incoming data is in little endian. */
memcpy(merkle_root, merkle_sha, 32);

uint32_t temp = pool->merkle_offset / sizeof(uint32_t), i;
/* Put version (4 byte) + prev_hash (4 byte* 8) but big endian encoded
* into work. */
for (i = 0; i < temp; ++i) {
((uint32_t *)work->data)[i] = be32toh(((uint32_t *)pool->header_bin)[i]);
}

/* Now add the merkle_root (4 byte* 8), but it is encoded in little endian. */
temp += 8;

for (j = 0; i < temp; ++i, ++j) {
((uint32_t *)work->data)[i] = bswap_32(le32toh(((uint32_t *)merkle_root)[j]));
}

/* Add the time encoded in big endianess. */
hex2bin((unsigned char *)&temp, pool->swork.ntime, 4);

/* Add the nbits (big endianess). */
((uint32_t *)work->data)[17] = be32toh(temp);
hex2bin((unsigned char *)&temp, pool->swork.nbit, 4);
Expand Down Expand Up @@ -6764,7 +6791,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
}

// For Neoscrypt use set_target_neoscrypt() function
if (pool->algorithm.type == ALGO_NEOSCRYPT) {
if (pool->algorithm.type == ALGO_NEOSCRYPT || pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
set_target_neoscrypt(work->target, work->sdiff, work->thr_id);
} else if (pool->algorithm.type == ALGO_MTP){
memcpy(work->target, pool->Target, 32);
Expand Down Expand Up @@ -7042,7 +7069,7 @@ static unsigned long compare_pool_settings(struct pool *oldpool, struct pool *ne

//thread-concurrency
// neoscrypt - if not specified set TC to 0 so that TC will be calculated by intensity settings
if (newpool->algorithm.type == ALGO_NEOSCRYPT) {
if (newpool->algorithm.type == ALGO_NEOSCRYPT || newpool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
opt2 = ((empty_string(newpool->thread_concurrency))?"0":get_pool_setting(newpool->thread_concurrency, default_profile.thread_concurrency));
}
// otherwise use pool/profile setting or default to default profile setting
Expand Down Expand Up @@ -7188,7 +7215,7 @@ static void apply_switcher_options(unsigned long options, struct pool *pool)
if(opt_isset(options, SWITCHER_APPLY_TC))
{
// neoscrypt - if not specified set TC to 0 so that TC will be calculated by intensity settings
if (pool->algorithm.type == ALGO_NEOSCRYPT) {
if (pool->algorithm.type == ALGO_NEOSCRYPT || pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
opt = ((empty_string(pool->thread_concurrency))?"0":get_pool_setting(pool->thread_concurrency, default_profile.thread_concurrency));
}
// otherwise use pool/profile setting or default to default profile setting
Expand Down Expand Up @@ -7726,7 +7753,7 @@ bool test_nonce(struct work *work, uint32_t nonce)
rebuild_nonce(work, nonce);

// for Neoscrypt, the diff1targ value is in work->target
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_PLUCK
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_NEOSCRYPT_XAYA || work->pool->algorithm.type == ALGO_PLUCK
|| work->pool->algorithm.type == ALGO_YESCRYPT || work->pool->algorithm.type == ALGO_YESCRYPT_MULTI
|| work->pool->algorithm.type == ALGO_YESCRYPT_NAVI
|| work->pool->algorithm.type == ALGO_ARGON2D) {
Expand Down Expand Up @@ -7888,7 +7915,7 @@ static void hash_sole_work(struct thr_info *mythr)
} else if (drv->working_diff > work->work_difficulty)
drv->working_diff = work->work_difficulty;

if (work->pool->algorithm.type == ALGO_NEOSCRYPT) {
if (work->pool->algorithm.type == ALGO_NEOSCRYPT || work->pool->algorithm.type == ALGO_NEOSCRYPT_XAYA) {
set_target_neoscrypt(work->device_target, work->device_diff, work->thr_id);
} else {
if (work->pool->algorithm.type == ALGO_ETHASH)
Expand Down
6 changes: 3 additions & 3 deletions winbuild/dist/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
//
#endif
//
#define VERSION "v0.7.2"
#define VERSION "v0.7.2-1"
#define PACKAGE_NAME "sgminer"
#define PACKAGE_TARNAME "sgminer"
#define PACKAGE_VERSION "0.7.2"
#define PACKAGE_STRING "sgminer 0.7.2"
#define PACKAGE_VERSION "0.7.2-1"
#define PACKAGE_STRING "sgminer 0.7.2-1"
#define PACKAGE "sgminer"
//
#define SGMINER_PREFIX ""
Expand Down

0 comments on commit 5a61ce0

Please sign in to comment.