Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
- added .cl files for kernel building
- fix on algorithm_settings params and added an alias
- several improvements suggested by bitbandi
  • Loading branch information
pompobit committed Jan 31, 2018
1 parent 01d8a78 commit 6b3f179
Show file tree
Hide file tree
Showing 17 changed files with 785 additions and 24 deletions.
3 changes: 2 additions & 1 deletion algorithm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ static algorithm_settings_t algos[] = {
{ "lbry", ALGO_LBRY, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 2, 4 * 8 * 4194304, 0, lbry_regenhash, NULL, NULL, queue_lbry_kernel, gen_hash, NULL },

{ "pascal", ALGO_PASCAL, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, pascal_regenhash, pascal_midstate, NULL, queue_pascal_kernel, NULL, NULL },
{ "evocoin", ALGO_X11EVO, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, evocoin_regenhash, queue_sph_kernel, gen_hash, append_x11_compiler_options },
{ "evocoin", ALGO_X11EVO, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, evocoin_regenhash, NULL, NULL, queue_sph_kernel, gen_hash, append_x11_compiler_options },


// Terminator (do not remove)
Expand Down Expand Up @@ -1293,6 +1293,7 @@ static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfa
ALGO_ALIAS_NF("nscrypt", "ckolivas", 11);
ALGO_ALIAS_NF("adaptive-nscrypt", "ckolivas", 11);
ALGO_ALIAS_NF("adaptive-n-scrypt", "ckolivas", 11);
ALGO_ALIAS("x11evo", "evocoin");
ALGO_ALIAS("x11mod", "darkcoin-mod");
ALGO_ALIAS("x11", "darkcoin-mod");
ALGO_ALIAS("x11-gost", "sibcoin-mod");
Expand Down
30 changes: 11 additions & 19 deletions algorithm/evocoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
#include "sph/sph_simd.h"
#include "sph/sph_echo.h"

#define INITIAL_DATE 1462060800
#define HASH_FUNC_COUNT 11
#define DEFAULT_NTIME "00000000"
#include "evocoin.h"


/* Move init out of loop, so init once externally, and then use one single memcpy with that bigger memory block */
Expand Down Expand Up @@ -159,6 +157,7 @@ void evocoin_twisted_code(char *result, const char *ntime, char *code)
uint32_t count = getCurrentAlgoSeq(h32, INITIAL_DATE);
getAlgoString(code, count);
sprintf(result, "_%d_%s_", count, code);

}


Expand All @@ -168,11 +167,11 @@ static inline void xhash(void *state, const void *input , const char* ntime)

Xhash_context_holder ctx;

uint32_t hashA[16], hashB[16];
uint32_t hash[16];
memcpy(&ctx, &base_contexts, sizeof(base_contexts));

char completeCode[64];
char resultCode[HASH_FUNC_COUNT + 1];
uint8_t resultCode[HASH_FUNC_COUNT + 1];
evocoin_twisted_code(completeCode, ntime, resultCode);

int i;
Expand All @@ -189,21 +188,14 @@ static inline void xhash(void *state, const void *input , const char* ntime)
idx = elem - '0';

int size;

if (i == 0) {
in = input;
size = 80;
out = hashA;
if(i == 0) {
in=input;
size=80;
out = hash;
}
else {
if (out == hashA) {
in = hashA;
out = hashB;
}
else {
in = hashB;
out = hashA;
}
else {
in = hash;
size = 64;
}

Expand Down
6 changes: 5 additions & 1 deletion algorithm/evocoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

#include "miner.h"

#define INITIAL_DATE 1462060800
#define HASH_FUNC_COUNT 11
#define DEFAULT_NTIME "00000000"

extern int evocoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce);
extern void evocoin_regenhash(struct work *work);
extern void evocoin_twisted_code(char *result, char *ntime, char *code);
extern void evocoin_twisted_code(char *result, const char *ntime, char *code);

#endif /* EVOCOIN_H */
7 changes: 4 additions & 3 deletions ocl/build_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "miner.h"
#include "build_kernel.h"
#include "patch_kernel.h"
#include "../algorithm/evocoin.h"

static char *file_contents(const char *filename, int *length)
{
Expand Down Expand Up @@ -130,7 +131,7 @@ static algorithm_get_settings_t algo[] = {
};


char *generateSource(const char *code)
char *generateSource(const uint8_t *code)
{

char *result;
Expand All @@ -148,10 +149,10 @@ char *generateSource(const char *code)
// start from non-inverted signal
bool curState = false;
int i;
for (i = 0; i < strlen(code); i++) {
for (i = 0; i < HASH_FUNC_COUNT; i++) {

// extract index
char elem = code[i];
uint8_t elem = code[i];
uint8_t idx;
if (elem >= 'A')
idx = elem - 'A' + 10;
Expand Down
50 changes: 50 additions & 0 deletions x11evo/x11evo_blake.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

// blake
{
sph_u64 H0 = SPH_C64(0x6A09E667F3BCC908), H1 = SPH_C64(0xBB67AE8584CAA73B);
sph_u64 H2 = SPH_C64(0x3C6EF372FE94F82B), H3 = SPH_C64(0xA54FF53A5F1D36F1);
sph_u64 H4 = SPH_C64(0x510E527FADE682D1), H5 = SPH_C64(0x9B05688C2B3E6C1F);
sph_u64 H6 = SPH_C64(0x1F83D9ABFB41BD6B), H7 = SPH_C64(0x5BE0CD19137E2179);
sph_u64 S0 = 0, S1 = 0, S2 = 0, S3 = 0;
sph_u64 T0 = SPH_C64(0xFFFFFFFFFFFFFC00) + (80 << 3), T1 = 0xFFFFFFFFFFFFFFFF;;

if ((T0 = SPH_T64(T0 + 1024)) < 1024)
{
T1 = SPH_T64(T1 + 1);
}
sph_u64 M0, M1, M2, M3, M4, M5, M6, M7;
sph_u64 M8, M9, MA, MB, MC, MD, ME, MF;
sph_u64 V0, V1, V2, V3, V4, V5, V6, V7;
sph_u64 V8, V9, VA, VB, VC, VD, VE, VF;
M0 = DEC64BE(block + 0);
M1 = DEC64BE(block + 8);
M2 = DEC64BE(block + 16);
M3 = DEC64BE(block + 24);
M4 = DEC64BE(block + 32);
M5 = DEC64BE(block + 40);
M6 = DEC64BE(block + 48);
M7 = DEC64BE(block + 56);
M8 = DEC64BE(block + 64);
M9 = DEC64BE(block + 72);
M9 &= 0xFFFFFFFF00000000;
M9 ^= SWAP4(gid);
MA = 0x8000000000000000;
MB = 0;
MC = 0;
MD = 1;
ME = 0;
MF = 0x280;

COMPRESS64;

hash.h8[0] = H0;
hash.h8[1] = H1;
hash.h8[2] = H2;
hash.h8[3] = H3;
hash.h8[4] = H4;
hash.h8[5] = H5;
hash.h8[6] = H6;
hash.h8[7] = H7;
}


57 changes: 57 additions & 0 deletions x11evo/x11evo_bmw.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

// bmw
{
sph_u64 BMW_H[16];
for (unsigned u = 0; u < 16; u++)
BMW_H[u] = BMW_IV512[u];

sph_u64 BMW_h1[16], BMW_h2[16];
sph_u64 mv[16];

mv[0] = SWAP8(hash.h8[0]);
mv[1] = SWAP8(hash.h8[1]);
mv[2] = SWAP8(hash.h8[2]);
mv[3] = SWAP8(hash.h8[3]);
mv[4] = SWAP8(hash.h8[4]);
mv[5] = SWAP8(hash.h8[5]);
mv[6] = SWAP8(hash.h8[6]);
mv[7] = SWAP8(hash.h8[7]);
mv[8] = 0x80;
mv[9] = 0;
mv[10] = 0;
mv[11] = 0;
mv[12] = 0;
mv[13] = 0;
mv[14] = 0;
mv[15] = 0x200;
#define M(x) (mv[x])
#define H(x) (BMW_H[x])
#define dH(x) (BMW_h2[x])

FOLDb;

#undef M
#undef H
#undef dH

#define M(x) (BMW_h2[x])
#define H(x) (final_b[x])
#define dH(x) (BMW_h1[x])

FOLDb;

#undef M
#undef H
#undef dH

hash.h8[0] = SWAP8(BMW_h1[8]);
hash.h8[1] = SWAP8(BMW_h1[9]);
hash.h8[2] = SWAP8(BMW_h1[10]);
hash.h8[3] = SWAP8(BMW_h1[11]);
hash.h8[4] = SWAP8(BMW_h1[12]);
hash.h8[5] = SWAP8(BMW_h1[13]);
hash.h8[6] = SWAP8(BMW_h1[14]);
hash.h8[7] = SWAP8(BMW_h1[15]);

}

60 changes: 60 additions & 0 deletions x11evo/x11evo_cubehash.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

// cubehash.h1
{
sph_u32 x0 = SPH_C32(0x2AEA2A61), x1 = SPH_C32(0x50F494D4), x2 = SPH_C32(0x2D538B8B), x3 = SPH_C32(0x4167D83E);
sph_u32 x4 = SPH_C32(0x3FEE2313), x5 = SPH_C32(0xC701CF8C), x6 = SPH_C32(0xCC39968E), x7 = SPH_C32(0x50AC5695);
sph_u32 x8 = SPH_C32(0x4D42C787), x9 = SPH_C32(0xA647A8B3), xa = SPH_C32(0x97CF0BEF), xb = SPH_C32(0x825B4537);
sph_u32 xc = SPH_C32(0xEEF864D2), xd = SPH_C32(0xF22090C4), xe = SPH_C32(0xD0E5CD33), xf = SPH_C32(0xA23911AE);
sph_u32 xg = SPH_C32(0xFCD398D9), xh = SPH_C32(0x148FE485), xi = SPH_C32(0x1B017BEF), xj = SPH_C32(0xB6444532);
sph_u32 xk = SPH_C32(0x6A536159), xl = SPH_C32(0x2FF5781C), xm = SPH_C32(0x91FA7934), xn = SPH_C32(0x0DBADEA9);
sph_u32 xo = SPH_C32(0xD65C8A2B), xp = SPH_C32(0xA5A70E75), xq = SPH_C32(0xB1C62456), xr = SPH_C32(0xBC796576);
sph_u32 xs = SPH_C32(0x1921C8F7), xt = SPH_C32(0xE7989AF1), xu = SPH_C32(0x7795D246), xv = SPH_C32(0xD43E3B44);

x0 ^= SWAP4(hash.h4[1]);
x1 ^= SWAP4(hash.h4[0]);
x2 ^= SWAP4(hash.h4[3]);
x3 ^= SWAP4(hash.h4[2]);
x4 ^= SWAP4(hash.h4[5]);
x5 ^= SWAP4(hash.h4[4]);
x6 ^= SWAP4(hash.h4[7]);
x7 ^= SWAP4(hash.h4[6]);

for (int i = 0; i < 13; i++) {
SIXTEEN_ROUNDS;

if (i == 0) {
x0 ^= SWAP4(hash.h4[9]);
x1 ^= SWAP4(hash.h4[8]);
x2 ^= SWAP4(hash.h4[11]);
x3 ^= SWAP4(hash.h4[10]);
x4 ^= SWAP4(hash.h4[13]);
x5 ^= SWAP4(hash.h4[12]);
x6 ^= SWAP4(hash.h4[15]);
x7 ^= SWAP4(hash.h4[14]);
}
else if (i == 1) {
x0 ^= 0x80;
}
else if (i == 2) {
xv ^= SPH_C32(1);
}
}

hash.h4[0] = x0;
hash.h4[1] = x1;
hash.h4[2] = x2;
hash.h4[3] = x3;
hash.h4[4] = x4;
hash.h4[5] = x5;
hash.h4[6] = x6;
hash.h4[7] = x7;
hash.h4[8] = x8;
hash.h4[9] = x9;
hash.h4[10] = xa;
hash.h4[11] = xb;
hash.h4[12] = xc;
hash.h4[13] = xd;
hash.h4[14] = xe;
hash.h4[15] = xf;

}
69 changes: 69 additions & 0 deletions x11evo/x11evo_echo.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

// echo
{
sph_u64 W00, W01, W10, W11, W20, W21, W30, W31, W40, W41, W50, W51, W60, W61, W70, W71, W80, W81, W90, W91, WA0, WA1, WB0, WB1, WC0, WC1, WD0, WD1, WE0, WE1, WF0, WF1;
sph_u64 Vb00, Vb01, Vb10, Vb11, Vb20, Vb21, Vb30, Vb31, Vb40, Vb41, Vb50, Vb51, Vb60, Vb61, Vb70, Vb71;
Vb00 = Vb10 = Vb20 = Vb30 = Vb40 = Vb50 = Vb60 = Vb70 = 512UL;
Vb01 = Vb11 = Vb21 = Vb31 = Vb41 = Vb51 = Vb61 = Vb71 = 0;

sph_u32 K0 = 512;
sph_u32 K1 = 0;
sph_u32 K2 = 0;
sph_u32 K3 = 0;

W00 = Vb00;
W01 = Vb01;
W10 = Vb10;
W11 = Vb11;
W20 = Vb20;
W21 = Vb21;
W30 = Vb30;
W31 = Vb31;
W40 = Vb40;
W41 = Vb41;
W50 = Vb50;
W51 = Vb51;
W60 = Vb60;
W61 = Vb61;
W70 = Vb70;
W71 = Vb71;
W80 = hash.h8[0];
W81 = hash.h8[1];
W90 = hash.h8[2];
W91 = hash.h8[3];
WA0 = hash.h8[4];
WA1 = hash.h8[5];
WB0 = hash.h8[6];
WB1 = hash.h8[7];
WC0 = 0x80;
WC1 = 0;
WD0 = 0;
WD1 = 0;
WE0 = 0;
WE1 = 0x200000000000000;
WF0 = 0x200;
WF1 = 0;

for (unsigned u = 0; u < 10; u++) {
BIG_ROUND;
}

Vb00 ^= hash.h8[0] ^ W00 ^ W80;
Vb01 ^= hash.h8[1] ^ W01 ^ W81;
Vb10 ^= hash.h8[2] ^ W10 ^ W90;
Vb11 ^= hash.h8[3] ^ W11 ^ W91;
Vb20 ^= hash.h8[4] ^ W20 ^ WA0;
Vb21 ^= hash.h8[5] ^ W21 ^ WA1;
Vb30 ^= hash.h8[6] ^ W30 ^ WB0;
Vb31 ^= hash.h8[7] ^ W31 ^ WB1;

hash.h8[0] = Vb00;
hash.h8[1] = Vb01;
hash.h8[2] = Vb10;
hash.h8[3] = Vb11;
hash.h8[4] = Vb20;
hash.h8[5] = Vb21;
hash.h8[6] = Vb30;
hash.h8[7] = Vb31;

}
7 changes: 7 additions & 0 deletions x11evo/x11evo_footer.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

bool result = (hash.h8[3] <= target);
if (result)
output[output[0xFF]++] = SWAP4(gid);
}

#endif // X11EVO_CL
Loading

0 comments on commit 6b3f179

Please sign in to comment.