Skip to content

Commit 42737ac

Browse files
ystarnaudtroky
authored andcommitted
Added Neoscrypt with Wolf9466 improvements.
1 parent 0557017 commit 42737ac

11 files changed

+2286
-89
lines changed

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ sgminer_SOURCES += algorithm/talkcoin.c algorithm/talkcoin.h
6565
sgminer_SOURCES += algorithm/bitblock.c algorithm/bitblock.h
6666
sgminer_SOURCES += algorithm/x14.c algorithm/x14.h
6767
sgminer_SOURCES += algorithm/fresh.c algorithm/fresh.h
68+
sgminer_SOURCES += algorithm/neoscrypt.c algorithm/neoscrypt.h
6869

6970
bin_SCRIPTS = $(top_srcdir)/kernel/*.cl
7071

algorithm.c

+41
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "algorithm/bitblock.h"
3030
#include "algorithm/x14.h"
3131
#include "algorithm/fresh.h"
32+
#include "algorithm/neoscrypt.h"
3233

3334
#include "compat.h"
3435

@@ -92,6 +93,17 @@ static void append_scrypt_compiler_options(struct _build_kernel_data *data, stru
9293
strcat(data->binary_filename, buf);
9394
}
9495

96+
static void append_neoscrypt_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
97+
{
98+
char buf[255];
99+
sprintf(buf, " -D MAX_GLOBAL_THREADS=%u",
100+
(unsigned int)cgpu->thread_concurrency);
101+
strcat(data->compiler_options, buf);
102+
103+
sprintf(buf, "tc%u", (unsigned int)cgpu->thread_concurrency);
104+
strcat(data->binary_filename, buf);
105+
}
106+
95107
static void append_x11_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
96108
{
97109
char buf[255];
@@ -140,6 +152,30 @@ static cl_int queue_scrypt_kernel(struct __clState *clState, struct _dev_blk_ctx
140152
return status;
141153
}
142154

155+
static cl_int queue_neoscrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads)
156+
{
157+
cl_kernel *kernel = &clState->kernel;
158+
unsigned int num = 0;
159+
cl_uint le_target;
160+
cl_int status = 0;
161+
162+
/* This looks like a unnecessary double cast, but to make sure, that
163+
* the target's most significant entry is adressed as a 32-bit value
164+
* and not accidently by something else the double cast seems wise.
165+
* The compiler will get rid of it anyway.
166+
*/
167+
le_target = (cl_uint)le32toh(((uint32_t *)blk->work->/*device_*/target)[7]);
168+
memcpy(clState->cldata, blk->work->data, 80);
169+
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL);
170+
171+
CL_SET_ARG(clState->CLbuffer0);
172+
CL_SET_ARG(clState->outputBuffer);
173+
CL_SET_ARG(clState->padbuffer8);
174+
CL_SET_ARG(le_target);
175+
176+
return status;
177+
}
178+
143179
static cl_int queue_maxcoin_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads)
144180
{
145181
cl_kernel *kernel = &clState->kernel;
@@ -597,6 +633,11 @@ static algorithm_settings_t algos[] = {
597633
A_SCRYPT( "zuikkis" ),
598634
#undef A_SCRYPT
599635

636+
#define A_NEOSCRYPT(a) \
637+
{ a, ALGO_NEOSCRYPT, "", 1, 65536, 65536, 0, 0, 0xFF, 0xFFFF000000000000ULL, 0x0000ffffUL, 0, -1, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, neoscrypt_regenhash, queue_neoscrypt_kernel, gen_hash, append_neoscrypt_compiler_options}
638+
A_NEOSCRYPT("neoscrypt"),
639+
#undef A_NEOSCRYPT
640+
600641
// kernels starting from this will have difficulty calculated by using quarkcoin algorithm
601642
#define A_QUARK(a, b) \
602643
{ a, ALGO_QUARK, "", 256, 256, 256, 0, 0, 0xFF, 0xFFFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, b, queue_sph_kernel, gen_hash, append_x11_compiler_options }

algorithm.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ typedef enum {
2323
ALGO_TWE,
2424
ALGO_FUGUE,
2525
ALGO_NIST,
26-
ALGO_FRESH
26+
ALGO_FRESH,
27+
ALGO_NEOSCRYPT
2728
} algorithm_type_t;
2829

2930
extern const char *algorithm_type_str[];

0 commit comments

Comments
 (0)