Browse Source

blake: change dynamic round system

blakecoin was conflicting with lyra2, set the rounds more properly
2upstream
Tanguy Pruvot 9 years ago
parent
commit
8db5a0bc9e
  1. 16
      Algo256/blake256.cu
  2. 2
      Algo256/keccak256.cu
  3. 14
      algos.h
  4. 4
      ccminer.cpp
  5. 4
      lyra2/lyra2RE.cu
  6. 2
      lyra2/lyra2REv2.cu
  7. 9
      sph/blake.c
  8. 5
      sph/sph_blake.h

16
Algo256/blake256.cu

@ -17,16 +17,13 @@ extern "C" { @@ -17,16 +17,13 @@ extern "C" {
/* threads per block and throughput (intensity) */
#define TPB 128
/* added in sph_blake.c */
extern "C" int blake256_rounds = 14;
/* hash by cpu with blake 256 */
extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14)
{
uchar hash[64];
sph_blake256_context ctx;
blake256_rounds = rounds;
sph_blake256_set_rounds(rounds);
sph_blake256_init(&ctx);
sph_blake256(&ctx, input, 80);
@ -356,8 +353,7 @@ static void blake256mid(uint32_t *output, const uint32_t *input, int8_t rounds = @@ -356,8 +353,7 @@ static void blake256mid(uint32_t *output, const uint32_t *input, int8_t rounds =
{
sph_blake256_context ctx;
/* in sph_blake.c */
blake256_rounds = rounds;
sph_blake256_set_rounds(rounds);
sph_blake256_init(&ctx);
sph_blake256(&ctx, input, 64);
@ -392,14 +388,14 @@ extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_non @@ -392,14 +388,14 @@ extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_non
const uint32_t first_nonce = pdata[19];
uint64_t targetHigh = ((uint64_t*)ptarget)[3];
int intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 20;
uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity);
throughput = min(throughput, max_nonce - first_nonce);
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity, max_nonce - first_nonce);
int rc = 0;
if (opt_benchmark) {
targetHigh = 0x1ULL << 32;
((uint32_t*)ptarget)[6] = swab32(0xff);
ptarget[7] = 0;
ptarget[6] = swab32(0xff);
targetHigh = 0xffULL << 32;
}
if (opt_tracegpu) {

2
Algo256/keccak256.cu

@ -46,7 +46,7 @@ extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_no @@ -46,7 +46,7 @@ extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_no
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0005;
ptarget[7] = 0x00ff;
if (!init[thr_id]) {
cudaSetDevice(device_map[thr_id]);

14
algos.h

@ -2,10 +2,8 @@ @@ -2,10 +2,8 @@
#define ALGOS_H
enum sha_algos {
ALGO_BLAKE = 0,
ALGO_LYRA2, /* moved first for benchs */
ALGO_LYRA2v2,
ALGO_BLAKECOIN,
ALGO_BLAKECOIN = 0,
ALGO_BLAKE,
ALGO_BMW,
ALGO_C11,
ALGO_DEEP,
@ -17,6 +15,8 @@ enum sha_algos { @@ -17,6 +15,8 @@ enum sha_algos {
ALGO_KECCAK,
ALGO_JACKPOT,
ALGO_LUFFA,
ALGO_LYRA2,
ALGO_LYRA2v2,
ALGO_MJOLLNIR, /* Hefty hash */
ALGO_MYR_GR,
ALGO_NEOSCRYPT,
@ -43,10 +43,8 @@ enum sha_algos { @@ -43,10 +43,8 @@ enum sha_algos {
};
static const char *algo_names[] = {
"blake",
"lyra2",
"lyra2v2",
"blakecoin",
"blake",
"bmw",
"c11",
"deep",
@ -58,6 +56,8 @@ static const char *algo_names[] = { @@ -58,6 +56,8 @@ static const char *algo_names[] = {
"keccak",
"jackpot",
"luffa",
"lyra2",
"lyra2v2",
"mjollnir",
"myr-gr",
"neoscrypt",

4
ccminer.cpp

@ -1738,10 +1738,8 @@ static void *miner_thread(void *userdata) @@ -1738,10 +1738,8 @@ static void *miner_thread(void *userdata)
minmax = 0x80000000U;
break;
case ALGO_BMW:
case ALGO_KECCAK:
minmax = 0x40000000U;
break;
case ALGO_JACKPOT:
case ALGO_LUFFA:
minmax = 0x2000000;
break;
@ -1755,6 +1753,8 @@ static void *miner_thread(void *userdata) @@ -1755,6 +1753,8 @@ static void *miner_thread(void *userdata)
case ALGO_WHIRLPOOL:
minmax = 0x400000;
break;
case ALGO_KECCAK:
case ALGO_JACKPOT:
case ALGO_NEOSCRYPT:
case ALGO_X15:
minmax = 0x300000;

4
lyra2/lyra2RE.cu

@ -47,12 +47,14 @@ extern uint32_t groestl256_getSecNonce(int thr_id, int num); @@ -47,12 +47,14 @@ extern uint32_t groestl256_getSecNonce(int thr_id, int num);
extern "C" void lyra2re_hash(void *state, const void *input)
{
uint32_t hashA[8], hashB[8];
sph_blake256_context ctx_blake;
sph_keccak256_context ctx_keccak;
sph_skein256_context ctx_skein;
sph_groestl256_context ctx_groestl;
uint32_t hashA[8], hashB[8];
sph_blake256_set_rounds(14);
sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, 80);

2
lyra2/lyra2REv2.cu

@ -42,6 +42,8 @@ void lyra2v2_hash(void *state, const void *input) @@ -42,6 +42,8 @@ void lyra2v2_hash(void *state, const void *input)
sph_bmw256_context ctx_bmw;
sph_cubehash256_context ctx_cube;
sph_blake256_set_rounds(14);
sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, 80);
sph_blake256_close(&ctx_blake, hashA);

9
sph/blake.c

@ -36,6 +36,8 @@ @@ -36,6 +36,8 @@
#include "sph_blake.h"
int blake256_rounds = 14;
#ifdef __cplusplus
extern "C"{
#endif
@ -1055,6 +1057,13 @@ sph_blake256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) @@ -1055,6 +1057,13 @@ sph_blake256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst)
sph_blake256_init(cc);
}
/* see sph_blake.h */
void
sph_blake256_set_rounds(int rounds)
{
blake256_rounds = rounds;
}
#if SPH_64
/* see sph_blake.h */

5
sph/sph_blake.h

@ -231,6 +231,11 @@ void sph_blake256_close(void *cc, void *dst); @@ -231,6 +231,11 @@ void sph_blake256_close(void *cc, void *dst);
void sph_blake256_addbits_and_close(
void *cc, unsigned ub, unsigned n, void *dst);
/**
* Allow blakecoin and blake variants
*/
void sph_blake256_set_rounds(int rounds);
#if SPH_64
/**

Loading…
Cancel
Save