|
|
@ -1,18 +1,25 @@ |
|
|
|
#include "uint256.h" |
|
|
|
#include "uint256.h" |
|
|
|
#include "sph/sph_groestl.h" |
|
|
|
#include "sph/sph_groestl.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "cpuminer-config.h" |
|
|
|
|
|
|
|
#include "miner.h" |
|
|
|
#include "miner.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
#include <stdint.h> |
|
|
|
#include <stdint.h> |
|
|
|
#include "cuda_groestlcoin.h" |
|
|
|
#include <algorithm> |
|
|
|
#include <openssl/sha.h> |
|
|
|
#include <openssl/sha.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "cuda_groestlcoin.h" |
|
|
|
|
|
|
|
|
|
|
|
#define SWAP32(x) \ |
|
|
|
#define SWAP32(x) \ |
|
|
|
((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \ |
|
|
|
((((x) << 24) & 0xff000000u) | (((x) << 8) & 0x00ff0000u) | \ |
|
|
|
(((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) |
|
|
|
(((x) >> 8) & 0x0000ff00u) | (((x) >> 24) & 0x000000ffu)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
|
|
|
|
|
|
#define MIN min |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#define MIN std::min |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
void sha256func(unsigned char *hash, const unsigned char *data, int len) |
|
|
|
void sha256func(unsigned char *hash, const unsigned char *data, int len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t S[16], T[16]; |
|
|
|
uint32_t S[16], T[16]; |
|
|
@ -48,7 +55,6 @@ extern "C" void groestlhash(void *state, const void *input) |
|
|
|
//these uint512 in the c++ source of the client are backed by an array of uint32
|
|
|
|
//these uint512 in the c++ source of the client are backed by an array of uint32
|
|
|
|
uint32_t hashA[16], hashB[16]; |
|
|
|
uint32_t hashA[16], hashB[16]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sph_groestl512_init(&ctx_groestl[0]); |
|
|
|
sph_groestl512_init(&ctx_groestl[0]); |
|
|
|
sph_groestl512 (&ctx_groestl[0], input, 80); //6
|
|
|
|
sph_groestl512 (&ctx_groestl[0], input, 80); //6
|
|
|
|
sph_groestl512_close(&ctx_groestl[0], hashA); //7
|
|
|
|
sph_groestl512_close(&ctx_groestl[0], hashA); //7
|
|
|
@ -65,15 +71,15 @@ extern bool opt_benchmark; |
|
|
|
extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t *ptarget, |
|
|
|
extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t *ptarget, |
|
|
|
uint32_t max_nonce, unsigned long *hashes_done) |
|
|
|
uint32_t max_nonce, unsigned long *hashes_done) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (opt_benchmark) |
|
|
|
|
|
|
|
((uint32_t*)ptarget)[7] = 0x000000ff; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t start_nonce = pdata[19]++; |
|
|
|
uint32_t start_nonce = pdata[19]++; |
|
|
|
const uint32_t Htarg = ptarget[7]; |
|
|
|
uint32_t throughPut = opt_work_size ? opt_work_size : (1 << 19); // 256*2048
|
|
|
|
const uint32_t throughPut = 4096 * 128; |
|
|
|
throughPut = MIN(throughPut, max_nonce - start_nonce); |
|
|
|
//const uint32_t throughPut = 1;
|
|
|
|
|
|
|
|
uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t)); |
|
|
|
uint32_t *outputHash = (uint32_t*)malloc(throughPut * 16 * sizeof(uint32_t)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opt_benchmark) |
|
|
|
|
|
|
|
((uint32_t*)ptarget)[7] = 0x000000ff; |
|
|
|
|
|
|
|
|
|
|
|
// init
|
|
|
|
// init
|
|
|
|
static bool init[8] = { false, false, false, false, false, false, false, false }; |
|
|
|
static bool init[8] = { false, false, false, false, false, false, false, false }; |
|
|
|
if(!init[thr_id]) |
|
|
|
if(!init[thr_id]) |
|
|
@ -93,6 +99,7 @@ extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t |
|
|
|
do { |
|
|
|
do { |
|
|
|
// GPU
|
|
|
|
// GPU
|
|
|
|
uint32_t foundNounce = 0xFFFFFFFF; |
|
|
|
uint32_t foundNounce = 0xFFFFFFFF; |
|
|
|
|
|
|
|
const uint32_t Htarg = ptarget[7]; |
|
|
|
|
|
|
|
|
|
|
|
groestlcoin_cpu_hash(thr_id, throughPut, pdata[19], outputHash, &foundNounce); |
|
|
|
groestlcoin_cpu_hash(thr_id, throughPut, pdata[19], outputHash, &foundNounce); |
|
|
|
|
|
|
|
|
|
|
@ -101,10 +108,10 @@ extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t |
|
|
|
uint32_t tmpHash[8]; |
|
|
|
uint32_t tmpHash[8]; |
|
|
|
endiandata[19] = SWAP32(foundNounce); |
|
|
|
endiandata[19] = SWAP32(foundNounce); |
|
|
|
groestlhash(tmpHash, endiandata); |
|
|
|
groestlhash(tmpHash, endiandata); |
|
|
|
if (tmpHash[7] <= Htarg && |
|
|
|
|
|
|
|
fulltest(tmpHash, ptarget)) { |
|
|
|
if (tmpHash[7] <= Htarg && fulltest(tmpHash, ptarget)) { |
|
|
|
pdata[19] = foundNounce; |
|
|
|
pdata[19] = foundNounce; |
|
|
|
*hashes_done = foundNounce - start_nonce; |
|
|
|
*hashes_done = foundNounce - start_nonce + 1; |
|
|
|
free(outputHash); |
|
|
|
free(outputHash); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -120,7 +127,7 @@ extern "C" int scanhash_groestlcoin(int thr_id, uint32_t *pdata, const uint32_t |
|
|
|
|
|
|
|
|
|
|
|
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart); |
|
|
|
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart); |
|
|
|
|
|
|
|
|
|
|
|
*hashes_done = pdata[19] - start_nonce; |
|
|
|
*hashes_done = pdata[19] - start_nonce + 1; |
|
|
|
free(outputHash); |
|
|
|
free(outputHash); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|