Skip to content

Commit

Permalink
X16s implem
Browse files Browse the repository at this point in the history
  • Loading branch information
stef2 authored and DumaxFr committed Apr 1, 2018
1 parent 8cc8d65 commit 0bac2bb
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 33 deletions.
3 changes: 1 addition & 2 deletions Algo512/cuda_echo512_shortMsg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Echo512 cuda kernel for short messages
*
* 80 & 64 bytes messages implemented with precalculations
* Code ready for message length from 8 to
*
* Code ready for message length from 8 to 96 bytes
*
* DumaxFr@github 2018
* Based on tpruvot 2018 - GPL code
Expand Down
5 changes: 3 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
Algo256/blake256.cu Algo256/decred.cu Algo256/vanilla.cu Algo256/keccak256.cu \
Algo256/blake2s.cu sph/blake2s.c \
Algo256/bmw.cu Algo256/cuda_bmw.cu \
Algo512/cuda_echo512_shortMsg.cu \
crypto/xmr-rpc.cpp crypto/wildkeccak-cpu.cpp crypto/wildkeccak.cu \
crypto/cryptolight.cu crypto/cryptolight-core.cu crypto/cryptolight-cpu.cpp \
crypto/cryptonight.cu crypto/cryptonight-core.cu crypto/cryptonight-extra.cu \
Expand Down Expand Up @@ -76,7 +77,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
x13/hsr.cu x13/cuda_hsr_sm3.cu x13/sm3.c \
x15/x14.cu x15/x15.cu x15/cuda_x14_shabal512.cu x15/cuda_x15_whirlpool.cu \
x15/whirlpool.cu x15/cuda_x15_whirlpool_sm3.cu \
x16r/x16r.cu x16r/cuda_x16_echo512.cu x16r/cuda_x16_fugue512.cu \
x16r/x16r.cu x16r/cuda_x16_fugue512.cu \
x16r/cuda_x16_shabal512.cu x16r/cuda_x16_simd512_80.cu \
x17/x17.cu x17/hmq17.cu x17/cuda_x17_haval256.cu x17/cuda_x17_sha512.cu \
x11/phi.cu x11/cuda_streebog_maxwell.cu \
Expand Down Expand Up @@ -114,7 +115,7 @@ endif
ccminer_LDADD += -lcuda

nvcc_ARCH :=
#nvcc_ARCH += -gencode=arch=compute_61,code=\"sm_61,compute_61\"
nvcc_ARCH += -gencode=arch=compute_61,code=\"sm_61,compute_61\"
nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
nvcc_ARCH += -gencode=arch=compute_50,code=\"sm_50,compute_50\"
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
Expand Down
10 changes: 6 additions & 4 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ enum sha_algos {
ALGO_X13,
ALGO_X14,
ALGO_X15,
ALGO_X16R,
ALGO_X17,
ALGO_X16R,
ALGO_X16S,
ALGO_X17,
ALGO_VANILLA,
ALGO_VELTOR,
ALGO_WHIRLCOIN,
Expand Down Expand Up @@ -129,8 +130,9 @@ static const char *algo_names[] = {
"x13",
"x14",
"x15",
"x16r",
"x17",
"x16r",
"x16s",
"x17",
"vanilla",
"veltor",
"whirlcoin",
Expand Down
30 changes: 19 additions & 11 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Options:\n\
x14 X14\n\
x15 X15\n\
x16r X16R (Raven)\n\
x16s X16S (Pigeon)\n\
x17 X17\n\
wildkeccak Boolberry\n\
zr5 ZR5 (ZiftrCoin)\n\
Expand Down Expand Up @@ -1706,8 +1707,9 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_LYRA2Z:
case ALGO_TIMETRAVEL:
case ALGO_BITCORE:
case ALGO_X16R:
work_set_target(work, sctx->job.diff / (256.0 * opt_difficulty));
case ALGO_X16R:
case ALGO_X16S:
work_set_target(work, sctx->job.diff / (256.0 * opt_difficulty));
break;
case ALGO_KECCAK:
case ALGO_LYRA2:
Expand Down Expand Up @@ -2501,10 +2503,13 @@ static void *miner_thread(void *userdata)
case ALGO_X15:
rc = scanhash_x15(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_X16R:
rc = scanhash_x16r(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_X17:
case ALGO_X16R:
rc = scanhash_x16x(thr_id, &work, max_nonce, &hashes_done, 'r');
break;
case ALGO_X16S:
rc = scanhash_x16x(thr_id, &work, max_nonce, &hashes_done, 's');
break;
case ALGO_X17:
rc = scanhash_x17(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_ZR5:
Expand Down Expand Up @@ -3866,7 +3871,7 @@ int main(int argc, char *argv[])
// get opt_quiet early
parse_single_opt('q', argc, argv);

printf("*** ccminer " PACKAGE_VERSION " for nVidia GPUs by tpruvot@github ***\n");
printf("*** " PACKAGE_NAME " " PACKAGE_VERSION " for nVidia GPUs by DumaxFr@github ***\n");
if (!opt_quiet) {
const char* arch = is_x64() ? "64-bits" : "32-bits";
#ifdef _MSC_VER
Expand All @@ -3875,10 +3880,13 @@ int main(int argc, char *argv[])
printf(" Built with the nVidia CUDA Toolkit %d.%d %s\n\n",
#endif
CUDART_VERSION/1000, (CUDART_VERSION % 1000)/10, arch);
printf(" Originally based on Christian Buchner and Christian H. project\n");
printf(" Include some kernels from alexis78, djm34, djEzo, tsiv and krnlx.\n\n");
printf("BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo (tpruvot)\n\n");
}
printf(" Based on a tpruvot/ccminer fork\n");
printf(" Originally based on Christian Buchner and Christian H. project\n");
printf(" Include some kernels from alexis78, djm34, djEzo, tsiv and krnlx.\n\n");
printf("BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo (tpruvot)\n\n");
printf("RVN donation address: RQXpsvSaVrGYo4tyGityWDNBQMFcnqANyj (DumaxFr)\n");
printf("BTC donation address: 1AtQXFbnzYTsjzy2bzSH6nPGxqZ32NG42T (DumaxFr)\n\n");
}

rpc_user = strdup("");
rpc_pass = strdup("");
Expand Down
4 changes: 2 additions & 2 deletions compat/ccminer-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
#define PACKAGE_NAME "ccminer"

/* Define to the home page for this package. */
#define PACKAGE_URL "http://github.com/tpruvot/ccminer"
#define PACKAGE_URL "https://github.com/DumaxFr/ccminer"

/* Define to the version of this package. */
#define PACKAGE_VERSION "2.2.5"
#define PACKAGE_VERSION "dumax-0.9.0"

/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([ccminer], [2.2.5], [], [ccminer], [http://github.com/tpruvot/ccminer])
AC_INIT([ccminer], [dumax-0.9.0], [], [ccminer], [https://github.com/DumaxFr/ccminer])

AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM
Expand Down
4 changes: 2 additions & 2 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ extern "C" {
extern int scanhash_x13(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x14(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x15(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_x16x(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, const char variation);
extern int scanhash_x17(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_zr5(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done);

Expand Down Expand Up @@ -925,7 +925,7 @@ extern "C" {
void x13hash(void *output, const void *input);
void x14hash(void *output, const void *input);
void x15hash(void *output, const void *input);
void x16r_hash(void *output, const void *input);
void x16x_hash(void *output, const void *input, const char variation);
void x17hash(void *output, const void *input);
void wildkeccak_hash(void *output, const void *input, uint64_t* scratchpad, uint64_t ssize);
void zr5hash(void *output, const void *input);
Expand Down
2 changes: 1 addition & 1 deletion util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ void print_hash_tests(void)
x15hash(&hash[0], &buf[0]);
printpfx("X15", hash);

x16r_hash(&hash[0], &buf[0]);
x16x_hash(&hash[0], &buf[0], 'r');
printpfx("X16r", hash);

x17hash(&hash[0], &buf[0]);
Expand Down
44 changes: 36 additions & 8 deletions x16r/x16r.cu
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static __thread uint32_t s_ntime = UINT32_MAX;
static __thread bool s_implemented = false;
static __thread char hashOrder[HASH_FUNC_COUNT + 1] = { 0 };

static void getAlgoString(const uint32_t* prevblock, char *output) {
static void getAlgoString16r(const uint32_t* prevblock, char *output) {
char *sptr = output;
uint8_t* data = (uint8_t*)prevblock;

Expand All @@ -95,8 +95,36 @@ static void getAlgoString(const uint32_t* prevblock, char *output) {
*sptr = '\0';
}

// X16R CPU Hash (Validation)
extern "C" void x16r_hash(void *output, const void *input) {
static void getAlgoString16s(const uint32_t* prevblock, char *output) {

char *ptrHash = output;
uint8_t* data = (uint8_t*)prevblock;

strcpy(ptrHash, "0123456789ABCDEF");

for (int j = 0; j < HASH_FUNC_COUNT; j++) {
uint8_t b = (15 - j) >> 1;
uint8_t algoDigit = (j & 1) ? data[b] & 0xF : data[b] >> 4;
if (algoDigit > 0) {
char pull = ptrHash[algoDigit];
for (int i = algoDigit; i > 0; i--) {
ptrHash[i] = ptrHash[i-1];
}
ptrHash[0] = pull;
}
}

}

static void getAlgoString(const uint32_t* prevblock, char *output, const char baseAlgo) {
if (baseAlgo == 'r')
getAlgoString16r(prevblock, output);
else
getAlgoString16s(prevblock, output);
}

// X16x CPU Hash (Validation)
extern "C" void x16x_hash(void *output, const void *input, const char variation) {
unsigned char _ALIGN(64) hash[128];

sph_blake512_context ctx_blake;
Expand All @@ -120,7 +148,7 @@ extern "C" void x16r_hash(void *output, const void *input) {
int size = 80;

uint32_t *in32 = (uint32_t*)input;
getAlgoString(&in32[1], hashOrder);
getAlgoString(&in32[1], hashOrder, variation);

for (int i = 0; i < 16; i++) {
const char elem = hashOrder[i];
Expand Down Expand Up @@ -247,7 +275,7 @@ static cudaEvent_t x16r_kernel_stop[MAX_GPUS];



extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done) {
extern "C" int scanhash_x16x(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, const char variation) {
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
const uint32_t first_nonce = pdata[19];
Expand Down Expand Up @@ -308,7 +336,7 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce,

uint32_t ntime = swab32(pdata[17]);
if (s_ntime != ntime) {
getAlgoString(&endiandata[1], hashOrder);
getAlgoString(&endiandata[1], hashOrder, variation);
s_ntime = ntime;
s_implemented = true;
if (opt_debug && !thr_id) {
Expand Down Expand Up @@ -592,15 +620,15 @@ extern "C" int scanhash_x16r(int thr_id, struct work* work, uint32_t max_nonce,
const uint32_t Htarg = ptarget[7];
uint32_t _ALIGN(64) vhash[8];
be32enc(&endiandata[19], work->nonces[0]);
x16r_hash(vhash, endiandata);
x16x_hash(vhash, endiandata, variation);

if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
work->valid_nonces = 1;
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
work_set_target_ratio(work, vhash);
if (work->nonces[1] != 0) {
be32enc(&endiandata[19], work->nonces[1]);
x16r_hash(vhash, endiandata);
x16x_hash(vhash, endiandata, variation);
bn_set_target_ratio(work, vhash, 1);
work->valid_nonces++;
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
Expand Down

0 comments on commit 0bac2bb

Please sign in to comment.