Browse Source

Whitespace and indentation fix

Fixed whitespace and indentation of lasybear's pull request #272.
djm34
ystarnaud 11 years ago
parent
commit
56055754eb
  1. 19
      algorithm/talkcoin.c
  2. 3
      algorithm/talkcoin.h
  3. 30
      kernel/talkcoin-mod.cl

19
algorithm/talkcoin.c

@ -38,7 +38,8 @@
#include "sph/sph_skein.h" #include "sph/sph_skein.h"
/* Move init out of loop, so init once externally, and then use one single memcpy with that bigger memory block */ /* Move init out of loop, so init once externally, and then use one single memcpy with that bigger memory block */
typedef struct { typedef struct
{
sph_blake512_context blake1; sph_blake512_context blake1;
sph_groestl512_context groestl1; sph_groestl512_context groestl1;
sph_jh512_context jh1; sph_jh512_context jh1;
@ -48,7 +49,6 @@ typedef struct {
Xhash_context_holder base_contexts; Xhash_context_holder base_contexts;
void init_Nhash_contexts() void init_Nhash_contexts()
{ {
sph_blake512_init(&base_contexts.blake1); sph_blake512_init(&base_contexts.blake1);
@ -118,10 +118,13 @@ int talkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t n
(long unsigned int)Htarg, (long unsigned int)Htarg,
(long unsigned int)diff1targ, (long unsigned int)diff1targ,
(long unsigned int)tmp_hash7); (long unsigned int)tmp_hash7);
if (tmp_hash7 > diff1targ) if (tmp_hash7 > diff1targ)
return -1; return -1;
if (tmp_hash7 > Htarg) if (tmp_hash7 > Htarg)
return 0; return 0;
return 1; return 1;
} }
@ -149,7 +152,8 @@ bool scanhash_talkcoin(struct thr_info *thr, const unsigned char __maybe_unused
be32enc_vect(data, (const uint32_t *)pdata, 19); be32enc_vect(data, (const uint32_t *)pdata, 19);
while(1) { while(1)
{
uint32_t ostate[8]; uint32_t ostate[8];
*nonce = ++n; *nonce = ++n;
@ -157,17 +161,18 @@ bool scanhash_talkcoin(struct thr_info *thr, const unsigned char __maybe_unused
talkhash(ostate, data); talkhash(ostate, data);
tmp_hash7 = (ostate[7]); tmp_hash7 = (ostate[7]);
applog(LOG_INFO, "data7 %08lx", applog(LOG_INFO, "data7 %08lx", (long unsigned int)data[7]);
(long unsigned int)data[7]);
if (unlikely(tmp_hash7 <= Htarg)) { if (unlikely(tmp_hash7 <= Htarg))
{
((uint32_t *)pdata)[19] = htobe32(n); ((uint32_t *)pdata)[19] = htobe32(n);
*last_nonce = n; *last_nonce = n;
ret = true; ret = true;
break; break;
} }
if (unlikely((n >= max_nonce) || thr->work_restart)) { if (unlikely((n >= max_nonce) || thr->work_restart))
{
*last_nonce = n; *last_nonce = n;
break; break;
} }

3
algorithm/talkcoin.h

@ -3,8 +3,7 @@
#include "miner.h" #include "miner.h"
extern int talkcoin_test(unsigned char *pdata, const unsigned char *ptarget, extern int talkcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce);
uint32_t nonce);
extern void talkcoin_regenhash(struct work *work); extern void talkcoin_regenhash(struct work *work);
#endif /* TALKCOIN_H */ #endif /* TALKCOIN_H */

30
kernel/talkcoin-mod.cl

@ -173,6 +173,7 @@ __kernel void search1(__global hash_t* hashes)
T6_L[i] = T6[i]; T6_L[i] = T6[i];
T7_L[i] = T7[i]; T7_L[i] = T7[i];
} }
barrier(CLK_LOCAL_MEM_FENCE); barrier(CLK_LOCAL_MEM_FENCE);
#define T0 T0_L #define T0 T0_L
@ -185,8 +186,10 @@ __kernel void search1(__global hash_t* hashes)
#define T7 T7_L #define T7 T7_L
sph_u64 H[16]; sph_u64 H[16];
for (unsigned int u = 0; u < 15; u ++) for (unsigned int u = 0; u < 15; u ++)
H[u] = 0; H[u] = 0;
#if USE_LE #if USE_LE
H[15] = ((sph_u64)(512 & 0xFF) << 56) | ((sph_u64)(512 & 0xFF00) << 40); H[15] = ((sph_u64)(512 & 0xFF) << 56) | ((sph_u64)(512 & 0xFF00) << 40);
#else #else
@ -202,8 +205,10 @@ __kernel void search1(__global hash_t* hashes)
m[5] = DEC64E(hash->h8[5]); m[5] = DEC64E(hash->h8[5]);
m[6] = DEC64E(hash->h8[6]); m[6] = DEC64E(hash->h8[6]);
m[7] = DEC64E(hash->h8[7]); m[7] = DEC64E(hash->h8[7]);
for (unsigned int u = 0; u < 16; u ++) for (unsigned int u = 0; u < 16; u ++)
g[u] = m[u] ^ H[u]; g[u] = m[u] ^ H[u];
m[8] = 0x80; g[8] = m[8] ^ H[8]; m[8] = 0x80; g[8] = m[8] ^ H[8];
m[9] = 0; g[9] = m[9] ^ H[9]; m[9] = 0; g[9] = m[9] ^ H[9];
m[10] = 0; g[10] = m[10] ^ H[10]; m[10] = 0; g[10] = m[10] ^ H[10];
@ -212,16 +217,23 @@ __kernel void search1(__global hash_t* hashes)
m[13] = 0; g[13] = m[13] ^ H[13]; m[13] = 0; g[13] = m[13] ^ H[13];
m[14] = 0; g[14] = m[14] ^ H[14]; m[14] = 0; g[14] = m[14] ^ H[14];
m[15] = 0x100000000000000; g[15] = m[15] ^ H[15]; m[15] = 0x100000000000000; g[15] = m[15] ^ H[15];
PERM_BIG_P(g); PERM_BIG_P(g);
PERM_BIG_Q(m); PERM_BIG_Q(m);
for (unsigned int u = 0; u < 16; u ++) for (unsigned int u = 0; u < 16; u ++)
H[u] ^= g[u] ^ m[u]; H[u] ^= g[u] ^ m[u];
sph_u64 xH[16]; sph_u64 xH[16];
for (unsigned int u = 0; u < 16; u ++) for (unsigned int u = 0; u < 16; u ++)
xH[u] = H[u]; xH[u] = H[u];
PERM_BIG_P(xH); PERM_BIG_P(xH);
for (unsigned int u = 0; u < 16; u ++) for (unsigned int u = 0; u < 16; u ++)
H[u] ^= xH[u]; H[u] ^= xH[u];
for (unsigned int u = 0; u < 8; u ++) for (unsigned int u = 0; u < 8; u ++)
hash->h8[u] = DEC64E(H[u + 8]); hash->h8[u] = DEC64E(H[u + 8]);
@ -239,10 +251,10 @@ __kernel void search2(__global hash_t* hashes)
sph_u64 h4h = C64e(0x0169e60541e34a69), h4l = C64e(0x46b58a8e2e6fe65a), h5h = C64e(0x1047a7d0c1843c24), h5l = C64e(0x3b6e71b12d5ac199), h6h = C64e(0xcf57f6ec9db1f856), h6l = C64e(0xa706887c5716b156), h7h = C64e(0xe3c2fcdfe68517fb), h7l = C64e(0x545a4678cc8cdd4b); sph_u64 h4h = C64e(0x0169e60541e34a69), h4l = C64e(0x46b58a8e2e6fe65a), h5h = C64e(0x1047a7d0c1843c24), h5l = C64e(0x3b6e71b12d5ac199), h6h = C64e(0xcf57f6ec9db1f856), h6l = C64e(0xa706887c5716b156), h7h = C64e(0xe3c2fcdfe68517fb), h7l = C64e(0x545a4678cc8cdd4b);
sph_u64 tmp; sph_u64 tmp;
for(int i = 0; i < 2; i++) for(int i = 0; i < 2; i++)
{ {
if (i == 0) { if (i == 0)
{
h0h ^= DEC64E(hash->h8[0]); h0h ^= DEC64E(hash->h8[0]);
h0l ^= DEC64E(hash->h8[1]); h0l ^= DEC64E(hash->h8[1]);
h1h ^= DEC64E(hash->h8[2]); h1h ^= DEC64E(hash->h8[2]);
@ -251,7 +263,9 @@ __kernel void search2(__global hash_t* hashes)
h2l ^= DEC64E(hash->h8[5]); h2l ^= DEC64E(hash->h8[5]);
h3h ^= DEC64E(hash->h8[6]); h3h ^= DEC64E(hash->h8[6]);
h3l ^= DEC64E(hash->h8[7]); h3l ^= DEC64E(hash->h8[7]);
} else if(i == 1) { }
else if(i == 1)
{
h4h ^= DEC64E(hash->h8[0]); h4h ^= DEC64E(hash->h8[0]);
h4l ^= DEC64E(hash->h8[1]); h4l ^= DEC64E(hash->h8[1]);
h5h ^= DEC64E(hash->h8[2]); h5h ^= DEC64E(hash->h8[2]);
@ -266,6 +280,7 @@ __kernel void search2(__global hash_t* hashes)
} }
E8; E8;
} }
h4h ^= 0x80; h4h ^= 0x80;
h7l ^= 0x2000000000000; h7l ^= 0x2000000000000;
@ -314,6 +329,7 @@ __kernel void search3(__global hash_t* hashes)
a21 ^= SWAP8(hash->h8[7]); a21 ^= SWAP8(hash->h8[7]);
a31 ^= 0x8000000000000001; a31 ^= 0x8000000000000001;
KECCAK_F_1600; KECCAK_F_1600;
// Finalize the "lane complement" // Finalize the "lane complement"
a10 = ~a10; a10 = ~a10;
a20 = ~a20; a20 = ~a20;
@ -340,9 +356,8 @@ __kernel void search4(__global hash_t* hashes, __global uint* output, const ulon
hash_t hash; hash_t hash;
__global hash_t *hashp = &(hashes[gid-offset]); __global hash_t *hashp = &(hashes[gid-offset]);
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++)
hash.h8[i] = hashes[gid-offset].h8[i]; hash.h8[i] = hashes[gid-offset].h8[i];
}
sph_u64 h0 = SPH_C64(0x4903ADFF749C51CE), h1 = SPH_C64(0x0D95DE399746DF03), h2 = SPH_C64(0x8FD1934127C79BCE), h3 = SPH_C64(0x9A255629FF352CB1), h4 = SPH_C64(0x5DB62599DF6CA7B0), h5 = SPH_C64(0xEABE394CA9D5C3F4), h6 = SPH_C64(0x991112C71A75B523), h7 = SPH_C64(0xAE18A40B660FCC33); sph_u64 h0 = SPH_C64(0x4903ADFF749C51CE), h1 = SPH_C64(0x0D95DE399746DF03), h2 = SPH_C64(0x8FD1934127C79BCE), h3 = SPH_C64(0x9A255629FF352CB1), h4 = SPH_C64(0x5DB62599DF6CA7B0), h5 = SPH_C64(0xEABE394CA9D5C3F4), h6 = SPH_C64(0x991112C71A75B523), h7 = SPH_C64(0xAE18A40B660FCC33);
sph_u64 m0, m1, m2, m3, m4, m5, m6, m7; sph_u64 m0, m1, m2, m3, m4, m5, m6, m7;
@ -356,10 +371,14 @@ __kernel void search4(__global hash_t* hashes, __global uint* output, const ulon
m5 = SWAP8(hash.h8[5]); m5 = SWAP8(hash.h8[5]);
m6 = SWAP8(hash.h8[6]); m6 = SWAP8(hash.h8[6]);
m7 = SWAP8(hash.h8[7]); m7 = SWAP8(hash.h8[7]);
UBI_BIG(480, 64); UBI_BIG(480, 64);
bcount = 0; bcount = 0;
m0 = m1 = m2 = m3 = m4 = m5 = m6 = m7 = 0; m0 = m1 = m2 = m3 = m4 = m5 = m6 = m7 = 0;
UBI_BIG(510, 8); UBI_BIG(510, 8);
hash.h8[0] = SWAP8(h0); hash.h8[0] = SWAP8(h0);
hash.h8[1] = SWAP8(h1); hash.h8[1] = SWAP8(h1);
hash.h8[2] = SWAP8(h2); hash.h8[2] = SWAP8(h2);
@ -372,7 +391,6 @@ __kernel void search4(__global hash_t* hashes, __global uint* output, const ulon
bool result = (SWAP8(hash.h8[3]) <= target); bool result = (SWAP8(hash.h8[3]) <= target);
if (result) if (result)
output[atomic_inc(output+0xFF)] = SWAP4(gid); output[atomic_inc(output+0xFF)] = SWAP4(gid);
} }
#endif // TALKCOIN_MOD_CL #endif // TALKCOIN_MOD_CL

Loading…
Cancel
Save