Skip to content

Commit 4ba8a68

Browse files
committed
Merged develop branch with master +updates
Moved the develop code to master. Moving forward all updates will be done on master unless it's work on a major feature. This update contains all previous develop code as well as a few new ones that weren't pushed yet: * Added neoscrypt compatibility for xintensity/rawintensity * Neoscrypt now uses correct TC if not specified or set to 0 * Reworked the application of pool settings on algorithm switch which should resolve TC/Intensity changes between algos such as X11 and neoscrypt
1 parent 7f88bab commit 4ba8a68

39 files changed

+9736
-1841
lines changed

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ sgminer_SOURCES += algorithm/talkcoin.c algorithm/talkcoin.h
6666
sgminer_SOURCES += algorithm/bitblock.c algorithm/bitblock.h
6767
sgminer_SOURCES += algorithm/x14.c algorithm/x14.h
6868
sgminer_SOURCES += algorithm/fresh.c algorithm/fresh.h
69+
sgminer_SOURCES += algorithm/whirlcoin.c algorithm/whirlcoin.h
6970
sgminer_SOURCES += algorithm/neoscrypt.c algorithm/neoscrypt.h
7071

7172
bin_SCRIPTS = $(top_srcdir)/kernel/*.cl

algorithm.c

+71-34
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/whirlcoin.h"
3233
#include "algorithm/neoscrypt.h"
3334

3435
#include "compat.h"
@@ -49,7 +50,9 @@ const char *algorithm_type_str[] = {
4950
"Twecoin",
5051
"Fugue256",
5152
"NIST",
52-
"Fresh"
53+
"Fresh",
54+
"Whirlcoin",
55+
"Neoscrypt"
5356
};
5457

5558
void sha256(const unsigned char *message, unsigned int len, unsigned char *digest)
@@ -96,11 +99,11 @@ static void append_scrypt_compiler_options(struct _build_kernel_data *data, stru
9699
static void append_neoscrypt_compiler_options(struct _build_kernel_data *data, struct cgpu_info *cgpu, struct _algorithm_t *algorithm)
97100
{
98101
char buf[255];
99-
sprintf(buf, " -D MAX_GLOBAL_THREADS=%u",
100-
(unsigned int)cgpu->thread_concurrency);
102+
sprintf(buf, " %s-D MAX_GLOBAL_THREADS=%lu ",
103+
((cgpu->lookup_gap > 0)?" -D LOOKUP_GAP=2 ":""), (unsigned long)cgpu->thread_concurrency);
101104
strcat(data->compiler_options, buf);
102-
103-
sprintf(buf, "tc%u", (unsigned int)cgpu->thread_concurrency);
105+
106+
sprintf(buf, "%stc%lu", ((cgpu->lookup_gap > 0)?"lg":""), (unsigned long)cgpu->thread_concurrency);
104107
strcat(data->binary_filename, buf);
105108
}
106109

@@ -158,21 +161,20 @@ static cl_int queue_neoscrypt_kernel(_clState *clState, dev_blk_ctx *blk, __mayb
158161
unsigned int num = 0;
159162
cl_uint le_target;
160163
cl_int status = 0;
161-
164+
162165
/* This looks like a unnecessary double cast, but to make sure, that
163166
* the target's most significant entry is adressed as a 32-bit value
164167
* and not accidently by something else the double cast seems wise.
165-
* The compiler will get rid of it anyway.
166-
*/
168+
* The compiler will get rid of it anyway. */
167169
le_target = (cl_uint)le32toh(((uint32_t *)blk->work->/*device_*/target)[7]);
168170
memcpy(clState->cldata, blk->work->data, 80);
169-
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL);
170-
171+
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);
172+
171173
CL_SET_ARG(clState->CLbuffer0);
172174
CL_SET_ARG(clState->outputBuffer);
173175
CL_SET_ARG(clState->padbuffer8);
174176
CL_SET_ARG(le_target);
175-
177+
176178
return status;
177179
}
178180

@@ -600,6 +602,34 @@ static cl_int queue_fresh_kernel(struct __clState *clState, struct _dev_blk_ctx
600602
return status;
601603
}
602604

605+
static cl_int queue_whirlcoin_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads)
606+
{
607+
cl_kernel *kernel;
608+
cl_ulong le_target;
609+
cl_int status = 0;
610+
611+
le_target = *(cl_ulong *)(blk->work->device_target + 24);
612+
flip80(clState->cldata, blk->work->data);
613+
status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL);
614+
615+
//clbuffer, hashes
616+
kernel = &clState->kernel;
617+
CL_SET_ARG_N(0,clState->CLbuffer0);
618+
CL_SET_ARG_N(1,clState->padbuffer8);
619+
620+
kernel = clState->extra_kernels;
621+
CL_SET_ARG_N(0,clState->padbuffer8);
622+
623+
CL_NEXTKERNEL_SET_ARG_N(0,clState->padbuffer8);
624+
625+
//hashes, output, target
626+
CL_NEXTKERNEL_SET_ARG_N(0,clState->padbuffer8);
627+
CL_SET_ARG_N(1,clState->outputBuffer);
628+
CL_SET_ARG_N(2,le_target);
629+
630+
return status;
631+
}
632+
603633
typedef struct _algorithm_settings_t {
604634
const char *name; /* Human-readable identifier */
605635
algorithm_type_t type; //common algorithm type
@@ -624,23 +654,24 @@ typedef struct _algorithm_settings_t {
624654
static algorithm_settings_t algos[] = {
625655
// kernels starting from this will have difficulty calculated by using litecoin algorithm
626656
#define A_SCRYPT(a) \
627-
{ a, ALGO_SCRYPT, "", 1, 65536, 65536, 0, 0, 0xFF, 0xFFFFFFFFULL, 0x0000ffffUL, 0, -1, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, scrypt_regenhash, queue_scrypt_kernel, gen_hash, append_scrypt_compiler_options}
657+
{ a, ALGO_SCRYPT, "", 1, 65536, 65536, 0, 0, 0xFF, 0xFFFFFFFFULL, 0x0000ffffUL, 0, -1, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, scrypt_regenhash, queue_scrypt_kernel, gen_hash, append_scrypt_compiler_options}
628658
A_SCRYPT( "ckolivas" ),
629659
A_SCRYPT( "alexkarnew" ),
630660
A_SCRYPT( "alexkarnold" ),
631661
A_SCRYPT( "bufius" ),
632662
A_SCRYPT( "psw" ),
633663
A_SCRYPT( "zuikkis" ),
664+
A_SCRYPT( "arebyp" ),
634665
#undef A_SCRYPT
635666

636667
#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}
668+
{ 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}
638669
A_NEOSCRYPT("neoscrypt"),
639670
#undef A_NEOSCRYPT
640671

641672
// kernels starting from this will have difficulty calculated by using quarkcoin algorithm
642673
#define A_QUARK(a, b) \
643-
{ 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 }
674+
{ 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}
644675
A_QUARK( "quarkcoin", quarkcoin_regenhash),
645676
A_QUARK( "qubitcoin", qubitcoin_regenhash),
646677
A_QUARK( "animecoin", animecoin_regenhash),
@@ -649,40 +680,43 @@ static algorithm_settings_t algos[] = {
649680

650681
// kernels starting from this will have difficulty calculated by using bitcoin algorithm
651682
#define A_DARK(a, b) \
652-
{ a, ALGO_X11, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, b, queue_sph_kernel, gen_hash, append_x11_compiler_options }
683+
{ a, ALGO_X11, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, b, queue_sph_kernel, gen_hash, append_x11_compiler_options}
653684
A_DARK( "darkcoin", darkcoin_regenhash),
654685
A_DARK( "inkcoin", inkcoin_regenhash),
655686
A_DARK( "myriadcoin-groestl", myriadcoin_groestl_regenhash),
656687
#undef A_DARK
657688

658689
{ "twecoin", ALGO_TWE, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, twecoin_regenhash, queue_sph_kernel, sha256, NULL},
659-
{ "maxcoin", ALGO_KECCAK, "", 1, 256, 1, 4, 15, 0x0F, 0xFFFFULL, 0x000000ffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, maxcoin_regenhash, queue_maxcoin_kernel, sha256, NULL },
690+
{ "maxcoin", ALGO_KECCAK, "", 1, 256, 1, 4, 15, 0x0F, 0xFFFFULL, 0x000000ffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, maxcoin_regenhash, queue_maxcoin_kernel, sha256, NULL},
660691

661-
{ "darkcoin-mod", ALGO_X11, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, darkcoin_regenhash, queue_darkcoin_mod_kernel, gen_hash, append_x11_compiler_options },
692+
{ "darkcoin-mod", ALGO_X11, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, darkcoin_regenhash, queue_darkcoin_mod_kernel, gen_hash, append_x11_compiler_options},
662693

663-
{ "marucoin", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, marucoin_regenhash, queue_sph_kernel, gen_hash, append_x13_compiler_options },
664-
{ "marucoin-mod", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 12, 8 * 16 * 4194304, 0, marucoin_regenhash, queue_marucoin_mod_kernel, gen_hash, append_x13_compiler_options },
665-
{ "marucoin-modold", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, marucoin_regenhash, queue_marucoin_mod_old_kernel, gen_hash, append_x13_compiler_options },
694+
{ "marucoin", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, marucoin_regenhash, queue_sph_kernel, gen_hash, append_x13_compiler_options},
695+
{ "marucoin-mod", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 12, 8 * 16 * 4194304, 0, marucoin_regenhash, queue_marucoin_mod_kernel, gen_hash, append_x13_compiler_options},
696+
{ "marucoin-modold", ALGO_X13, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, marucoin_regenhash, queue_marucoin_mod_old_kernel, gen_hash, append_x13_compiler_options},
666697

667-
{ "x14", ALGO_X14, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 13, 8 * 16 * 4194304, 0, x14_regenhash, queue_x14_kernel, gen_hash, append_x13_compiler_options },
668-
{ "x14old", ALGO_X14, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, x14_regenhash, queue_x14_old_kernel, gen_hash, append_x13_compiler_options },
698+
{ "x14", ALGO_X14, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 13, 8 * 16 * 4194304, 0, x14_regenhash, queue_x14_kernel, gen_hash, append_x13_compiler_options},
699+
{ "x14old", ALGO_X14, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 8 * 16 * 4194304, 0, x14_regenhash, queue_x14_old_kernel, gen_hash, append_x13_compiler_options},
669700

670-
{ "bitblock", ALGO_X15, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 14, 4 * 16 * 4194304, 0, bitblock_regenhash, queue_bitblock_kernel, gen_hash, append_x13_compiler_options },
671-
{ "bitblockold", ALGO_X15, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 4 * 16 * 4194304, 0, bitblock_regenhash, queue_bitblockold_kernel, gen_hash, append_x13_compiler_options },
701+
{ "bitblock", ALGO_X15, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 14, 4 * 16 * 4194304, 0, bitblock_regenhash, queue_bitblock_kernel, gen_hash, append_x13_compiler_options},
702+
{ "bitblockold", ALGO_X15, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 10, 4 * 16 * 4194304, 0, bitblock_regenhash, queue_bitblockold_kernel, gen_hash, append_x13_compiler_options},
672703

673-
{ "talkcoin-mod", ALGO_NIST, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 4, 8 * 16 * 4194304, 0, talkcoin_regenhash, queue_talkcoin_mod_kernel, gen_hash, append_x11_compiler_options },
704+
{ "talkcoin-mod", ALGO_NIST, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 4, 8 * 16 * 4194304, 0, talkcoin_regenhash, queue_talkcoin_mod_kernel, gen_hash, append_x11_compiler_options},
674705

675-
{ "fresh", ALGO_FRESH, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 4, 4 * 16 * 4194304, 0, fresh_regenhash, queue_fresh_kernel, gen_hash, NULL },
706+
{ "fresh", ALGO_FRESH, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 4, 4 * 16 * 4194304, 0, fresh_regenhash, queue_fresh_kernel, gen_hash, NULL},
676707

677708
// kernels starting from this will have difficulty calculated by using fuguecoin algorithm
678-
#define A_FUGUE(a, b) \
679-
{ a, ALGO_FUGUE, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, b, queue_sph_kernel, sha256, NULL }
680-
A_FUGUE( "fuguecoin", fuguecoin_regenhash),
681-
A_FUGUE( "groestlcoin", groestlcoin_regenhash),
682-
#undef A_FUGUE
709+
#define A_FUGUE(a, b, c) \
710+
{ a, ALGO_FUGUE, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, b, queue_sph_kernel, c, NULL}
711+
A_FUGUE("fuguecoin", fuguecoin_regenhash, sha256),
712+
A_FUGUE("groestlcoin", groestlcoin_regenhash, sha256),
713+
A_FUGUE("diamond", groestlcoin_regenhash, gen_hash),
714+
#undef A_FUGUE
715+
716+
{ "whirlcoin", ALGO_WHIRL, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 3, 8 * 16 * 4194304, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, whirlcoin_regenhash, queue_whirlcoin_kernel, sha256, NULL},
683717

684718
// Terminator (do not remove)
685-
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL }
719+
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}
686720
};
687721

688722
void copy_algorithm_settings(algorithm_t* dest, const char* algo)
@@ -695,7 +729,7 @@ void copy_algorithm_settings(algorithm_t* dest, const char* algo)
695729
if (strcmp(src->name, algo) == 0)
696730
{
697731
strcpy(dest->name, src->name);
698-
dest->kernelfile = src->kernelfile;
732+
dest->kernelfile = src->kernelfile;
699733
dest->type = src->type;
700734

701735
dest->diff_multiplier1 = src->diff_multiplier1;
@@ -751,6 +785,7 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
751785
ALGO_ALIAS("x15old", "bitblockold");
752786
ALGO_ALIAS("nist5", "talkcoin-mod");
753787
ALGO_ALIAS("keccak", "maxcoin");
788+
ALGO_ALIAS("whirlpool", "whirlcoin");
754789

755790
#undef ALGO_ALIAS
756791
#undef ALGO_ALIAS_NF
@@ -760,7 +795,8 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
760795

761796
void set_algorithm(algorithm_t* algo, const char* newname_alias)
762797
{
763-
const char* newname;
798+
const char *newname;
799+
764800
//load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10
765801
uint8_t old_nfactor = ((algo->nfactor)?algo->nfactor:0);
766802
//load previous kernel file name if was applied before algorithm...
@@ -811,5 +847,6 @@ void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)
811847

812848
bool cmp_algorithm(algorithm_t* algo1, algorithm_t* algo2)
813849
{
850+
// return (strcmp(algo1->name, algo2->name) == 0) && (algo1->nfactor == algo2->nfactor);
814851
return (!safe_cmp(algo1->name, algo2->name) && !safe_cmp(algo1->kernelfile, algo2->kernelfile) && (algo1->nfactor == algo2->nfactor));
815852
}

algorithm.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef enum {
2424
ALGO_FUGUE,
2525
ALGO_NIST,
2626
ALGO_FRESH,
27+
ALGO_WHIRL,
2728
ALGO_NEOSCRYPT
2829
} algorithm_type_t;
2930

algorithm/neoscrypt.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,7 @@ void neoscrypt(const uchar *password, uchar *output, uint profile) {
11771177
r = (1 << ((profile >> 5) & 0x7));
11781178
}
11791179

1180-
uchar *stack;
1181-
stack =(uchar*)malloc((N + 3) * r * 2 * SCRYPT_BLOCK_SIZE + stack_align);
1182-
1180+
uchar stack[(N + 3) * r * 2 * SCRYPT_BLOCK_SIZE + stack_align];
11831181
/* X = r * 2 * SCRYPT_BLOCK_SIZE */
11841182
X = (uint *) &stack[stack_align & ~(stack_align - 1)];
11851183
/* Z is a copy of X for ChaCha */
@@ -1287,7 +1285,6 @@ void neoscrypt(const uchar *password, uchar *output, uint profile) {
12871285

12881286
}
12891287

1290-
free(stack);
12911288
}
12921289

12931290
void neoscrypt_regenhash(struct work *work)

algorithm/neoscrypt.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#ifndef NEOSCRYPT_H
22
#define NEOSCRYPT_H
3-
3+
44
#include "miner.h"
55

66
/* The neoscrypt scratch buffer needs 32kBytes memory. */
77
#define NEOSCRYPT_SCRATCHBUF_SIZE (32 * 1024)
8-
98
/* These routines are always available. */
109
extern void neoscrypt_regenhash(struct work *work);
1110
extern void neoscrypt(const unsigned char *input, unsigned char *output, unsigned int profile);

0 commit comments

Comments
 (0)