Browse Source

cpu: Drivers should not be doing fulltest on their own, so remove it

Luke Dashjr 11 years ago
parent
commit
2016458e46
10 changed files with 20 additions and 31 deletions
  1. 0 2
      miner.h
  2. 3 3
      sha256_4way.c
  3. 3 3
      sha256_altivec_4way.c
  4. 4 4
      sha256_cryptopp.c
  5. 2 2
      sha256_generic.c
  6. 2 2
      sha256_sse2_amd64.c
  7. 2 2
      sha256_sse2_i386.c
  8. 2 2
      sha256_sse4_amd64.c
  9. 2 2
      sha256_via.c
  10. 0 9
      util.c

+ 0 - 2
miner.h

@@ -1004,8 +1004,6 @@ extern bool our_curl_supports_proxy_uris();
 extern void bin2hex(char *out, const void *in, size_t len);
 extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
 
-extern bool fulltest(const unsigned char *hash, const unsigned char *target);
-
 extern int opt_queue;
 extern int opt_scantime;
 extern int opt_expiry;

+ 3 - 3
sha256_4way.c

@@ -87,7 +87,6 @@ bool ScanHash_4WaySSE2(struct thr_info * const thr, struct work * const work,
 	uint8_t *pdata = work->data;
 	const uint32_t * const phash1 = hash1_init;
 	uint8_t * const phash = work->hash;
-	const uint8_t * const ptarget = work->target;
 	
 	uint32_t *hash32 = (uint32_t *)phash;
     unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
@@ -112,12 +111,13 @@ bool ScanHash_4WaySSE2(struct thr_info * const thr, struct work * const work,
                 for (i = 0; i < 32/4; i++)
                     ((unsigned int*)phash)[i] = thash[i][j];
 
-		if (unlikely(hash32[7] == 0 && fulltest(phash, ptarget))) {
+				if (unlikely(hash32[7] == 0))
+				{
 					nonce += j;
 					*last_nonce = nonce;
 					*nNonce_p = nonce;
 					return true;
-		}
+				}
             }
         }
 

+ 3 - 3
sha256_altivec_4way.c

@@ -86,7 +86,6 @@ bool ScanHash_altivec_4way(struct thr_info * const thr, struct work * const work
 	uint8_t hash1[0x40];
 	memcpy(hash1, hash1_init, sizeof(hash1));
 	uint8_t * const phash = work->hash;
-	const uint8_t * const ptarget = work->target;
 	
 	uint32_t *hash32 = (uint32_t *)phash;
     unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
@@ -111,12 +110,13 @@ bool ScanHash_altivec_4way(struct thr_info * const thr, struct work * const work
                 for (i = 0; i < 32/4; i++)
                     ((unsigned int*)phash)[i] = thash[i][j];
 
-		if (unlikely(hash32[7] == 0 && fulltest(phash, ptarget))) {
+				if (unlikely(hash32[7] == 0))
+				{
 					nonce += j;
 					*last_nonce = nonce;
 					*nNonce_p = nonce;
 					return true;
-		}
+				}
             }
         }
 

+ 4 - 4
sha256_cryptopp.c

@@ -115,7 +115,6 @@ bool scanhash_cryptopp(struct thr_info * const thr, struct work * const work,
 	uint8_t hash1[0x40];
 	memcpy(hash1, hash1_init, sizeof(hash1));
 	uint8_t * const hash = work->hash;
-	const uint8_t * const target = work->target;
 	
 	uint32_t *hash32 = (uint32_t *) hash;
 	uint32_t *nonce = (uint32_t *)(data + 76);
@@ -133,7 +132,8 @@ bool scanhash_cryptopp(struct thr_info * const thr, struct work * const work,
 		runhash(hash1, data, midstate);
 		runhash(hash, hash1, sha256_init_state);
 
-		if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
+		if (unlikely((hash32[7] == 0)))
+		{
 			*nonce = htole32(n);
 			*last_nonce = n;
 			return true;
@@ -605,7 +605,6 @@ bool scanhash_asm32(struct thr_info * const thr, struct work * const work,
 	uint8_t hash1[0x40];
 	memcpy(hash1, hash1_init, sizeof(hash1));
 	uint8_t * const hash = work->hash;
-	const uint8_t * const target = work->target;
 	
 	uint32_t *hash32 = (uint32_t *) hash;
 	uint32_t *nonce = (uint32_t *)(data + 76);
@@ -618,7 +617,8 @@ bool scanhash_asm32(struct thr_info * const thr, struct work * const work,
 		runhash32(hash1, data, midstate);
 		runhash32(hash, hash1, sha256_init_state);
 
-		if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
+		if (unlikely(hash32[7] == 0))
+		{
 			*last_nonce = n;
 			return true;
 		}

+ 2 - 2
sha256_generic.c

@@ -243,7 +243,6 @@ bool scanhash_c(struct thr_info * const thr, struct work * const work,
 	uint8_t hash1[0x40];
 	memcpy(hash1, hash1_init, sizeof(hash1));
 	uint8_t * const hash = work->hash;
-	const uint8_t * const target = work->target;
 	
 	uint32_t *hash32 = (uint32_t *) hash;
 	uint32_t *nonce = (uint32_t *)(data + 76);
@@ -265,7 +264,8 @@ bool scanhash_c(struct thr_info * const thr, struct work * const work,
 
 		stat_ctr++;
 
-		if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
+		if (unlikely(hash32[7] == 0))
+		{
 			*nonce = htole32(n);
 			*last_nonce = n;
 			return true;

+ 2 - 2
sha256_sse2_amd64.c

@@ -59,7 +59,6 @@ bool scanhash_sse2_64(struct thr_info * const thr, struct work * const work,
 	uint8_t *pdata = work->data;
 	const uint32_t * const phash1 = hash1_init;
 	uint8_t * const phash = work->hash;
-	const uint8_t * const ptarget = work->target;
 	
 	uint32_t *hash32 = (uint32_t *)phash;
     uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
@@ -118,7 +117,8 @@ bool scanhash_sse2_64(struct thr_info * const thr, struct work * const work,
 		    *(uint32_t *)&(phash)[i*4] = mi.i[j];
 		}
 
-		if (unlikely(hash32[7] == 0 && fulltest(phash, ptarget))) {
+		if (unlikely(hash32[7] == 0))
+		{
 		     nonce += j;
 		     *last_nonce = nonce + 1;
 		     *nNonce_p = nonce;

+ 2 - 2
sha256_sse2_i386.c

@@ -59,7 +59,6 @@ bool scanhash_sse2_32(struct thr_info * const thr, struct work * const work,
 	uint8_t *pdata = work->data;
 	const uint32_t * const phash1 = hash1_init;
 	uint8_t * const phash = work->hash;
-	const uint8_t * const ptarget = work->target;
 	
 	uint32_t *hash32 = (uint32_t *)phash;
     uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
@@ -109,7 +108,8 @@ bool scanhash_sse2_32(struct thr_info * const thr, struct work * const work,
 		    *(uint32_t *)&(phash)[i<<2] = ((uint32_t *)&(m_4hash[i]))[j];
 		}
 
-		if (unlikely(hash32[7] == 0 && fulltest(phash, ptarget))) {
+		if (unlikely(hash32[7] == 0))
+		{
 		     nonce += j;
 		     *last_nonce = nonce;
 		     *nNonce_p = nonce;

+ 2 - 2
sha256_sse4_amd64.c

@@ -58,7 +58,6 @@ bool scanhash_sse4_64(struct thr_info * const thr, struct work * const work,
 	uint8_t *pdata = work->data;
 	const uint32_t * const phash1 = hash1_init;
 	uint8_t * const phash = work->hash;
-	const uint8_t * const ptarget = work->target;
 	
 	uint32_t *hash32 = (uint32_t *)phash;
     uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
@@ -117,7 +116,8 @@ bool scanhash_sse4_64(struct thr_info * const thr, struct work * const work,
 		    *(uint32_t *)&(phash)[i*4] = mi.i[j];
 		}
 
-		if (unlikely(hash32[7] == 0 && fulltest(phash, ptarget))) {
+		if (unlikely(hash32[7] == 0))
+		{
 			nonce += j;
 			*last_nonce = nonce;
 			*nNonce_p = nonce;

+ 2 - 2
sha256_via.c

@@ -37,7 +37,6 @@ bool scanhash_via(struct thr_info * const thr, struct work * const work,
 		  uint32_t n)
 {
 	uint8_t * const data_inout = work->data;
-	const uint8_t * const target = work->target;
 	
 	unsigned char data[128] __attribute__((aligned(128)));
 	unsigned char tmp_hash[32] __attribute__((aligned(128)));
@@ -70,7 +69,8 @@ bool scanhash_via(struct thr_info * const thr, struct work * const work,
 
 		stat_ctr++;
 
-		if (unlikely((hash32[7] == 0) && fulltest(tmp_hash, target))) {
+		if (unlikely((hash32[7] == 0)))
+		{
 			/* swap nonce'd data back into original storage area;
 			 */
 			*nonce_inout = bswap_32(n);

+ 0 - 9
util.c

@@ -865,15 +865,6 @@ bool hash_target_check_v(const unsigned char *hash, const unsigned char *target)
 	return rc;
 }
 
-// This operates on a native-endian SHA256 state
-// In other words, on little endian platforms, every 4 bytes are in reverse order
-bool fulltest(const unsigned char *hash, const unsigned char *target)
-{
-	unsigned char hash2[32];
-	swap32tobe(hash2, hash, 32 / 4);
-	return hash_target_check_v(hash2, target);
-}
-
 struct thread_q *tq_new(void)
 {
 	struct thread_q *tq;