1
0
mirror of https://github.com/GOSTSec/ccminer synced 2025-08-26 13:51:51 +00:00

Handle intensity param in all algos

and add a check related to start/max nounce params
This commit is contained in:
Tanguy Pruvot 2014-11-09 21:55:19 +01:00
parent 9f62014690
commit 11c5ec810d
18 changed files with 59 additions and 46 deletions

View File

@ -97,9 +97,8 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000ff; ((uint32_t*)ptarget)[7] = 0x0000ff;
const uint32_t Htarg = ptarget[7]; int throughput = opt_work_size ? opt_work_size : (1 << 22); // 256*4096*4
throughput = min(throughput, max_nonce - first_nonce);
const int throughput = 256*4096*4; // 100;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) if (!init[thr_id])
@ -212,6 +211,7 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
{ {
unsigned int rounds; unsigned int rounds;
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
// diese jackpothash Funktion gibt die Zahl der Runden zurück // diese jackpothash Funktion gibt die Zahl der Runden zurück

View File

@ -16,7 +16,6 @@ extern "C" {
/* threads per block and throughput (intensity) */ /* threads per block and throughput (intensity) */
#define TPB 128 #define TPB 128
#define INTENSITY (1 << 20) // = 1048576 nonces per call
/* added in sph_blake.c */ /* added in sph_blake.c */
extern "C" int blake256_rounds = 14; extern "C" int blake256_rounds = 14;
@ -393,15 +392,15 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
static bool init[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static bool init[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint64_t targetHigh = ((uint64_t*)ptarget)[3]; // 0x00000000.0fffffff uint64_t targetHigh = ((uint64_t*)ptarget)[3];
uint32_t _ALIGN(64) endiandata[20]; uint32_t _ALIGN(64) endiandata[20];
#if PRECALC64 #if PRECALC64
uint32_t _ALIGN(64) midstate[8]; uint32_t _ALIGN(64) midstate[8];
#else #else
uint32_t crcsum; uint32_t crcsum;
#endif #endif
/* todo: -i param */ uint32_t throughput = opt_work_size ? opt_work_size : (1 << 20); // 1048576 nonces per call
uint32_t throughput = min(INTENSITY, max_nonce - first_nonce); throughput = min(throughput, max_nonce - first_nonce);
int rc = 0; int rc = 0;

View File

@ -77,9 +77,8 @@ extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata,
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x00FF; ((uint32_t*)ptarget)[7] = 0x00FF;
const uint32_t Htarg = ptarget[7]; int throughput = opt_work_size ? opt_work_size : (1 << 20); // 256*4096
throughput = min(throughput, max_nonce - first_nonce);
const int throughput = 256*4096; // 100;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) if (!init[thr_id])
@ -119,6 +118,7 @@ extern "C" int scanhash_nist5(int thr_id, uint32_t *pdata,
if (foundNonce != 0xffffffff) if (foundNonce != 0xffffffff)
{ {
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
nist5hash(vhash64, endiandata); nist5hash(vhash64, endiandata);

View File

@ -281,8 +281,10 @@ int scanhash_heavy_cpp(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, const uint32_t *ptarget, uint32_t max_nonce,
unsigned long *hashes_done, uint32_t maxvote, int blocklen) unsigned long *hashes_done, uint32_t maxvote, int blocklen)
{ {
const uint32_t first_nonce = pdata[19]; /* to check */
// CUDA will process thousands of threads. // CUDA will process thousands of threads.
const int throughput = 4096 * 128; int throughput = opt_work_size ? opt_work_size : (1 << 19); // 128*4096
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x000000ff; ((uint32_t*)ptarget)[7] = 0x000000ff;
@ -296,8 +298,6 @@ int scanhash_heavy_cpp(int thr_id, uint32_t *pdata,
int nrmCalls[6]; int nrmCalls[6];
memset(nrmCalls, 0, sizeof(int) * 6); memset(nrmCalls, 0, sizeof(int) * 6);
uint32_t start_nonce = pdata[19];
// für jeden Hash ein individuelles Target erstellen basierend // für jeden Hash ein individuelles Target erstellen basierend
// auf dem höchsten Bit, das in ptarget gesetzt ist. // auf dem höchsten Bit, das in ptarget gesetzt ist.
int highbit = findhighbit(ptarget, 8); int highbit = findhighbit(ptarget, 8);
@ -418,7 +418,7 @@ int scanhash_heavy_cpp(int thr_id, uint32_t *pdata,
} }
else else
{ {
*hashes_done = pdata[19] - start_nonce; *hashes_done = pdata[19] - first_nonce;
rc = 1; rc = 1;
goto exit; goto exit;
} }
@ -432,7 +432,7 @@ emptyNonceVector:
pdata[19] += throughput; pdata[19] += throughput;
} 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] - first_nonce;
exit: exit:
cudaFreeHost(cpu_nonceVector); cudaFreeHost(cpu_nonceVector);

View File

@ -46,9 +46,8 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x000f; ((uint32_t*)ptarget)[7] = 0x000f;
const uint32_t Htarg = ptarget[7]; int throughput = opt_work_size ? opt_work_size : (1 << 22); // 256*256*8*8
throughput = min(throughput, max_nonce - first_nonce);
const int throughput = 256*256*8*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) { if (!init[thr_id]) {
@ -72,10 +71,9 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
uint32_t foundNonce = keccak256_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++); uint32_t foundNonce = keccak256_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
if (foundNonce != 0xffffffff) if (foundNonce != 0xffffffff)
{ {
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
keccak256_hash(vhash64, endiandata); keccak256_hash(vhash64, endiandata);
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) {

View File

@ -170,7 +170,8 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
((uint32_t*)ptarget)[7] = 0x00000f; ((uint32_t*)ptarget)[7] = 0x00000f;
const uint32_t Htarg = ptarget[7]; const uint32_t Htarg = ptarget[7];
const int throughput = 256*2048; // 100; int throughput = opt_work_size ? opt_work_size : (1 << 20); // 256*2048*2
throughput = min(throughput, max_nonce - first_nonce);
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) if (!init[thr_id])

View File

@ -135,9 +135,11 @@ extern "C" int scanhash_quark(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*4096; // 100;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
int throughput = opt_work_size ? opt_work_size : (1 << 20); // 256*4096
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x00FF; ((uint32_t*)ptarget)[7] = 0x00FF;

View File

@ -60,9 +60,10 @@ extern "C" int scanhash_deep(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
int throughput = opt_work_size ? opt_work_size : (1 << 22); // 256*256*8*8
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000ff; ((uint32_t*)ptarget)[7] = 0x0000ff;

View File

@ -40,9 +40,10 @@ extern "C" int scanhash_doom(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
int throughput = opt_work_size ? opt_work_size : (1 << 22); // 256*256*8*8
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000ff; ((uint32_t*)ptarget)[7] = 0x0000ff;

View File

@ -78,10 +78,11 @@ extern "C" int scanhash_qubit(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, const uint32_t *ptarget, uint32_t max_nonce,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
const uint32_t first_nonce = pdata[19];
int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000ff; ((uint32_t*)ptarget)[7] = 0x0000ff;

View File

@ -75,10 +75,12 @@ extern "C" int scanhash_fresh(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x00ff; ((uint32_t*)ptarget)[7] = 0x00ff;

View File

@ -57,14 +57,15 @@ extern "C" int scanhash_s3(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
static bool init[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
#ifdef WIN32 #ifdef WIN32
// reduce a bit the intensity on windows // reduce a bit the intensity on windows
const int throughput = 256 * 256 * 8; int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
#else #else
const int throughput = 256 * 256 * 8 * 2; int throughput = opt_work_size ? opt_work_size : (1 << 20); // 256*256*8*2;
#endif #endif
throughput = min(throughput, max_nonce - first_nonce);
static bool init[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0xF; ((uint32_t*)ptarget)[7] = 0xF;

View File

@ -138,8 +138,9 @@ extern "C" int scanhash_x11(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000f; ((uint32_t*)ptarget)[7] = 0x0000f;

View File

@ -162,7 +162,8 @@ extern "C" int scanhash_x13(int thr_id, uint32_t *pdata,
const uint32_t Htarg = ptarget[7]; const uint32_t Htarg = ptarget[7];
const int throughput = 256*256*8; int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) if (!init[thr_id])

View File

@ -56,13 +56,13 @@ extern "C" int scanhash_whc(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
uint32_t Htarg = ptarget[7]; int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = Htarg = 0x0000ff; ((uint32_t*)ptarget)[7] = 0x0000ff;
if (!init[thr_id]) { if (!init[thr_id]) {
cudaSetDevice(device_map[thr_id]); cudaSetDevice(device_map[thr_id]);
@ -91,8 +91,8 @@ extern "C" int scanhash_whc(int thr_id, uint32_t *pdata,
if (foundNonce != 0xffffffff) if (foundNonce != 0xffffffff)
{ {
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
wcoinhash(vhash64, endiandata); wcoinhash(vhash64, endiandata);
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget))

View File

@ -168,13 +168,14 @@ extern "C" int scanhash_x14(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
uint32_t Htarg = ptarget[7];
int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = Htarg = 0xff; ((uint32_t*)ptarget)[7] = 0xff;
if (!init[thr_id]) if (!init[thr_id])
{ {
@ -230,6 +231,7 @@ extern "C" int scanhash_x14(int thr_id, uint32_t *pdata,
uint32_t vhash64[8]; uint32_t vhash64[8];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
x14hash(vhash64, endiandata); x14hash(vhash64, endiandata);
uint32_t Htarg = ptarget[7];
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) {
pdata[19] = foundNonce; pdata[19] = foundNonce;
*hashes_done = foundNonce - first_nonce + 1; *hashes_done = foundNonce - first_nonce + 1;

View File

@ -177,13 +177,14 @@ extern "C" int scanhash_x15(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t endiandata[20]; uint32_t endiandata[20];
uint32_t Htarg = ptarget[7];
int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = Htarg = 0x00FF; ((uint32_t*)ptarget)[7] = 0x00FF;
if (!init[thr_id]) if (!init[thr_id])
{ {
@ -241,6 +242,7 @@ extern "C" int scanhash_x15(int thr_id, uint32_t *pdata,
{ {
/* check now with the CPU to confirm */ /* check now with the CPU to confirm */
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
x15hash(vhash64, endiandata); x15hash(vhash64, endiandata);
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) { if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) {

View File

@ -197,12 +197,12 @@ extern "C" int scanhash_x17(int thr_id, uint32_t *pdata,
unsigned long *hashes_done) unsigned long *hashes_done)
{ {
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const int throughput = 256*256*8;
static bool init[8] = {0,0,0,0,0,0,0,0}; static bool init[8] = {0,0,0,0,0,0,0,0};
uint32_t Htarg = ptarget[7]; int throughput = opt_work_size ? opt_work_size : (1 << 19); // 256*256*8;
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark) if (opt_benchmark)
((uint32_t*)ptarget)[7] = Htarg = 0x00FF; ((uint32_t*)ptarget)[7] = 0x00FF;
if (!init[thr_id]) if (!init[thr_id])
{ {
@ -265,6 +265,7 @@ extern "C" int scanhash_x17(int thr_id, uint32_t *pdata,
if (foundNonce != 0xffffffff) if (foundNonce != 0xffffffff)
{ {
uint32_t vhash64[8]; uint32_t vhash64[8];
uint32_t Htarg = ptarget[7];
be32enc(&endiandata[19], foundNonce); be32enc(&endiandata[19], foundNonce);
x17hash(vhash64, endiandata); x17hash(vhash64, endiandata);