Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#0001 5455945 1 增加cpuminer-xzc中的 lyra2z 算法,支持vs2013/树莓派3 #32

Open
wants to merge 1 commit into
base: linux
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cpuminer_SOURCES = \
crypto/hash.c \
crypto/aesb.c \
lyra2/Lyra2.c lyra2/Sponge.c \
lyra2/Lyra2-xzc.c \
yescrypt/yescrypt-common.c yescrypt/yescrypt-best.c \
yescrypt/sha256_Y.c \
algo/allium.c \
Expand All @@ -75,6 +76,7 @@ cpuminer_SOURCES = \
algo/luffa.c \
algo/lyra2re.c \
algo/lyra2rev2.c \
algo/lyra2z.c \
algo/myr-groestl.c \
algo/keccak.c \
algo/pentablake.c \
Expand Down
85 changes: 85 additions & 0 deletions algo/lyra2z.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <memory.h>
//#include <mm_malloc.h>

#include "sha3/sph_blake.h"

#include "lyra2/Lyra2-xzc.h"

#include "miner.h"

void lyra2z_hash(uint64_t* wholeMatrix, void *state, const void *input)
{
#ifdef VERBOSE_HASH_TIMING
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
double start = spec.tv_sec + spec.tv_nsec / 1.0e9;
#endif

sph_blake256_context ctx_blake;

uint32_t hashA[8], hashB[8];

sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, 80);
sph_blake256_close(&ctx_blake, hashA);

// LYRA2(0, hashB, 32, hashA, 32, hashA, 32, 2, 8, 8);

//LYRA2(wholeMatrix, hashB, 32, hashA, 32, hashA, 32, 8, 8, 8);
LYRA2_XZC(wholeMatrix, hashB, 32, hashA, 32, hashA, 32, 8, 8, 8);

#ifdef VERBOSE_HASH_TIMING
if (hash[0] % 32 == 0) {
clock_gettime(CLOCK_REALTIME, &spec);
double end = spec.tv_sec + spec.tv_nsec / 1.0e9;
printf("Hash time: %f ms\n", (end - start) * 1000);
}
#endif

memcpy(state, hashB, 32);
}

int scanhash_lyra2z(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{

size_t size = (int64_t) ((int64_t) 16 * 16 * 96);
//uint64_t *wholeMatrix = _mm_malloc(size, 64);
uint64_t _ALIGN(64) wholeMatrix[24580] = {0};

uint32_t _ALIGN(128) hash[8];
uint32_t _ALIGN(128) endiandata[20];
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;

const uint32_t Htarg = ptarget[7];
const uint32_t first_nonce = pdata[19];
uint32_t nonce = first_nonce;

if (opt_benchmark)
ptarget[7] = 0x0000ff;

for (int i=0; i < 19; i++) {
be32enc(&endiandata[i], pdata[i]);
}

do {
be32enc(&endiandata[19], nonce);
lyra2z_hash(wholeMatrix, hash, endiandata);
// lyra2z_hash(0, hash, endiandata);

if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
work_set_target_ratio(work, hash);
pdata[19] = nonce;
*hashes_done = pdata[19] - first_nonce;
//_mm_free(wholeMatrix);
return 1;
}
nonce++;

} while (nonce < max_nonce && !work_restart[thr_id].restart);

pdata[19] = nonce;
*hashes_done = pdata[19] - first_nonce + 1;
//_mm_free(wholeMatrix);
return 0;
}
10 changes: 10 additions & 0 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ enum algos {
ALGO_LUFFA, /* Luffa (Joincoin, Doom) */
ALGO_LYRA2, /* Lyra2RE */
ALGO_LYRA2REV2, /* Lyra2REv2 (Vertcoin) */
ALGO_LYRA2Z, /* Lyra2Z */
ALGO_MYR_GR, /* Myriad Groestl */
ALGO_NIST5, /* Nist5 */
ALGO_PENTABLAKE, /* Pentablake */
Expand Down Expand Up @@ -162,6 +163,7 @@ static const char *algo_names[] = {
"luffa",
"lyra2re",
"lyra2rev2",
"lyra2z",
"myr-gr",
"nist5",
"pentablake",
Expand Down Expand Up @@ -320,6 +322,7 @@ Options:\n\
luffa Luffa\n\
lyra2re Lyra2RE\n\
lyra2rev2 Lyra2REv2 (Vertcoin)\n\
lyra2z Lyra2z\n\
myr-gr Myriad-Groestl\n\
neoscrypt NeoScrypt(128, 2, 1)\n\
nist5 Nist5\n\
Expand Down Expand Up @@ -1828,6 +1831,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
break;
case ALGO_KECCAK:
case ALGO_LYRA2:
case ALGO_LYRA2Z:
work_set_target(work, sctx->job.diff / (128.0 * opt_diff_factor));
break;
default:
Expand Down Expand Up @@ -2148,6 +2152,7 @@ static void *miner_thread(void *userdata)
case ALGO_ALLIUM:
case ALGO_LYRA2:
case ALGO_LYRA2REV2:
case ALGO_LYRA2Z:
case ALGO_TIMETRAVEL:
case ALGO_BITCORE:
case ALGO_XEVAN:
Expand Down Expand Up @@ -2275,6 +2280,9 @@ static void *miner_thread(void *userdata)
case ALGO_LYRA2REV2:
rc = scanhash_lyra2rev2(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_LYRA2Z:
rc = scanhash_lyra2z(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_MYR_GR:
rc = scanhash_myriad(thr_id, &work, max_nonce, &hashes_done);
break;
Expand Down Expand Up @@ -2892,6 +2900,8 @@ void parse_arg(int key, char *arg)
i = opt_algo = ALGO_LYRA2;
else if (!strcasecmp("lyra2v2", arg))
i = opt_algo = ALGO_LYRA2REV2;
else if (!strcasecmp("lyra2z", arg))
i = opt_algo = ALGO_LYRA2Z;
else if (!strcasecmp("scryptjane", arg))
i = opt_algo = ALGO_SCRYPTJANE;
else if (!strcasecmp("sibcoin", arg))
Expand Down
4 changes: 3 additions & 1 deletion cpuminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="algo\lyra2z.c" />
<ClCompile Include="compat\getopt\getopt_long.c" />
<ClCompile Include="compat\gettimeofday.c" />
<ClCompile Include="compat\jansson\dump.c" />
Expand All @@ -184,6 +185,7 @@
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
</ClCompile>
<ClCompile Include="api.c" />
<ClCompile Include="lyra2\Lyra2-xzc.c" />
<ClCompile Include="sysinfos.c" />
<ClCompile Include="crypto\aesb.c" />
<ClCompile Include="crypto\c_blake256.c" />
Expand Down Expand Up @@ -399,4 +401,4 @@
<Target Name="AfterClean">
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>
</Project>
8 changes: 7 additions & 1 deletion cpuminer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@
<ClCompile Include="yescrypt\sha256_Y.c">
<Filter>yescrypt</Filter>
</ClCompile>
<ClCompile Include="algo\lyra2z.c">
<Filter>algo</Filter>
</ClCompile>
<ClCompile Include="lyra2\Lyra2-xzc.c">
<Filter>algo</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="sha3\sph_blake.h">
Expand Down Expand Up @@ -611,4 +617,4 @@
<Filter>res</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>
Loading