Skip to content

Commit

Permalink
prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
monkins1010 committed Dec 17, 2019
1 parent 8c515b0 commit a2ae360
Show file tree
Hide file tree
Showing 13 changed files with 1,986 additions and 1,078 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ ccminer_SOURCES = elist.h miner.h compat.h \
ccminer.cpp pools.cpp util.cpp bench.cpp \
api.cpp hashlog.cpp stats.cpp sysinfos.cpp \
equi/equi-stratum.cpp verus/verusscan.cpp \
verus/haraka_portable.c verus/verus_clhash_portable.cpp
verus/haraka.c verus/verus_clhash.cpp



if HAVE_WINDOWS
Expand Down
9 changes: 7 additions & 2 deletions ccminer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright 2010 Jeff Garzik
* Copyright 2012-2014 pooler
* Copyright 2014-2017 tpruvot
Expand Down Expand Up @@ -1758,7 +1758,7 @@ static bool wanna_mine(int thr_id)
float temp = gpu_temp(cgpu);
if (temp > opt_max_temp) {
if (!conditional_state[thr_id] && !opt_quiet)
gpulog(LOG_INFO, thr_id, "temperature too high (%.0f°c), waiting...", temp);
gpulog(LOG_INFO, thr_id, "temperature too high (%.0f°c), waiting...", temp);
state = false;
} else if (opt_max_temp > 0. && opt_resume_temp > 0. && conditional_state[thr_id] && temp > opt_resume_temp) {
if (!thr_id && opt_debug)
Expand Down Expand Up @@ -2312,6 +2312,11 @@ static void *miner_thread(void *userdata)

work.valid_nonces = 0;

if (abort_flag)
break; // time to leave the mining loop...

if (work_restart[thr_id].restart)
continue;
/* scan nonces for a proof-of-work hash */
switch (opt_algo) {

Expand Down
2 changes: 1 addition & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

extracflags="-march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16"

./configure CXXFLAGS="-O3 $extracflags"
./configure CXXFLAGS="-O2 $extracflags"

9 changes: 4 additions & 5 deletions equi/equi-stratum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ bool equi_stratum_notify(struct stratum_ctx *sctx, json_t *params)
coinb2 = json_string_value(json_array_get(params, p++)); //blank (reserved)
stime = json_string_value(json_array_get(params, p++));
nbits = json_string_value(json_array_get(params, p++)); p++;
solution = json_string_value(json_array_get(params, p++));
clean = json_is_true(json_array_get(params, p)); p++;

solution = json_string_value(json_array_get(params, p));
if (!job_id || !prevhash || !coinb1 || !coinb2 || !version || !nbits || !stime ||
strlen(prevhash) != 64 || strlen(version) != 8 ||
strlen(coinb1) != 64 || strlen(coinb2) != 64 ||
Expand Down Expand Up @@ -178,9 +177,9 @@ bool equi_stratum_notify(struct stratum_ctx *sctx, json_t *params)

hex2bin(sctx->job.nbits, nbits, 4);
hex2bin(sctx->job.ntime, stime, 4);
if(solution)
sctx->job.nreward[0] = solution[0]; //just copy the version
else sctx->job.nreward[0] = 0;
// TODO, parse solution hex into nreward for future PBaaS merged mining support
if(solution) sctx->job.nreward[0] = 3; //verushash v2.1
else sctx->job.nreward[0] = 1; // verushash v2

sctx->job.clean = clean;

Expand Down
83 changes: 17 additions & 66 deletions verus/haraka.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,31 @@ void test_implementations() {
}

void haraka256(unsigned char *out, const unsigned char *in) {
__m128i s[2], tmp;
__m128i s[2], tmp;

s[0] = LOAD(in);
s[1] = LOAD(in + 16);
s[0] = LOAD(in);
s[1] = LOAD(in + 16);

AES2(s[0], s[1], 0);
MIX2(s[0], s[1]);
AES2(s[0], s[1], 0);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 4);
MIX2(s[0], s[1]);
AES2(s[0], s[1], 4);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 8);
MIX2(s[0], s[1]);
AES2(s[0], s[1], 8);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 12);
MIX2(s[0], s[1]);
AES2(s[0], s[1], 12);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 16);
MIX2(s[0], s[1]);
AES2(s[0], s[1], 16);
MIX2(s[0], s[1]);

s[0] = _mm_xor_si128(s[0], LOAD(in));
s[1] = _mm_xor_si128(s[1], LOAD(in + 16));
s[0] = _mm_xor_si128(s[0], LOAD(in));
s[1] = _mm_xor_si128(s[1], LOAD(in + 16));

STORE(out, s[0]);
STORE(out + 16, s[1]);
STORE(out, s[0]);
STORE(out + 16, s[1]);
}

void haraka256_keyed(unsigned char *out, const unsigned char *in, const u128 *rc) {
Expand All @@ -146,20 +146,6 @@ void haraka256_keyed(unsigned char *out, const unsigned char *in, const u128 *rc
s[0] = LOAD(in);
s[1] = LOAD(in + 16);

AES2(s[0], s[1], 0);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 4);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 8);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 12);
MIX2(s[0], s[1]);

AES2(s[0], s[1], 16);
MIX2(s[0], s[1]);

s[0] = _mm_xor_si128(s[0], LOAD(in));
s[1] = _mm_xor_si128(s[1], LOAD(in + 16));
Expand All @@ -178,42 +164,7 @@ void haraka256_4x(unsigned char *out, const unsigned char *in) {
s[2][0] = LOAD(in + 64);
s[2][1] = LOAD(in + 80);
s[3][0] = LOAD(in + 96);
s[3][1] = LOAD(in + 112);

// Round 1
AES2_4x(s[0], s[1], s[2], s[3], 0);

MIX2(s[0][0], s[0][1]);
MIX2(s[1][0], s[1][1]);
MIX2(s[2][0], s[2][1]);
MIX2(s[3][0], s[3][1]);

// Round 2
AES2_4x(s[0], s[1], s[2], s[3], 4);

MIX2(s[0][0], s[0][1]);
MIX2(s[1][0], s[1][1]);
MIX2(s[2][0], s[2][1]);
MIX2(s[3][0], s[3][1]);

// Round 3
AES2_4x(s[0], s[1], s[2], s[3], 8);

MIX2(s[0][0], s[0][1]);
MIX2(s[1][0], s[1][1]);
MIX2(s[2][0], s[2][1]);
MIX2(s[3][0], s[3][1]);

// Round 4
AES2_4x(s[0], s[1], s[2], s[3], 12);

MIX2(s[0][0], s[0][1]);
MIX2(s[1][0], s[1][1]);
MIX2(s[2][0], s[2][1]);
MIX2(s[3][0], s[3][1]);

// Round 5
AES2_4x(s[0], s[1], s[2], s[3], 16);

MIX2(s[0][0], s[0][1]);
MIX2(s[1][0], s[1][1]);
Expand Down
Loading

0 comments on commit a2ae360

Please sign in to comment.