Mark hash success as unlikely, using __builtin_expect() intrinsic
This commit is contained in:
parent
f0bdc0b6f9
commit
1083e15c47
5 changed files with 13 additions and 5 deletions
8
miner.h
8
miner.h
|
@ -21,6 +21,14 @@
|
|||
#include <byteswap.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
||||
#undef unlikely
|
||||
#define unlikely(expr) (__builtin_expect((expr), 0))
|
||||
#else
|
||||
#undef unlikely
|
||||
#define unlikely(expr) (expr)
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
#define WANT_CRYPTOPP_ASM32
|
||||
#endif
|
||||
|
|
|
@ -118,7 +118,7 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd
|
|||
|
||||
for (j = 0; j < NPAR; j++)
|
||||
{
|
||||
if (thash[7][j] == 0)
|
||||
if (unlikely(thash[7][j] == 0))
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data,
|
|||
|
||||
stat_ctr++;
|
||||
|
||||
if ((hash32[7] == 0) && fulltest(hash, target)) {
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
*hashes_done = stat_ctr;
|
||||
return true;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
|
|||
|
||||
stat_ctr++;
|
||||
|
||||
if ((hash32[7] == 0) && fulltest(hash, target)) {
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
fulltest(hash, target);
|
||||
|
||||
*hashes_done = stat_ctr;
|
||||
|
|
|
@ -256,7 +256,7 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
|||
|
||||
stat_ctr++;
|
||||
|
||||
if ((hash32[7] == 0) && fulltest(hash, target)) {
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
*hashes_done = stat_ctr;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ bool scanhash_via(unsigned char *data_inout,
|
|||
|
||||
stat_ctr++;
|
||||
|
||||
if ((hash32[7] == 0) && fulltest(tmp_hash, target)) {
|
||||
if (unlikely((hash32[7] == 0) && fulltest(tmp_hash, target))) {
|
||||
/* swap nonce'd data back into original storage area;
|
||||
* TODO: only swap back the nonce, rather than all data
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue