Browse files

Simplify macros in output kernels avoiding apparent loops and local v…

…ariables.
  • Loading branch information...
1 parent 7992e5f commit 9bec1e158e0e913cc9166b1f01a75e029ef9a998 @ckolivas committed Aug 24, 2012
Showing with 42 additions and 107 deletions.
  1. +10 −24 diablo120823.cl
  2. +10 −24 diakgcn120823.cl
  3. +10 −24 phatk120823.cl
  4. +8 −21 poclbm120823.cl
  5. +4 −14 scrypt120823.cl
View
34 diablo120823.cl
@@ -1245,49 +1245,35 @@ void search(
#define FOUND (0x0F)
#if defined(OCL1)
- #define SETFOUND(Xfound, Xnonce) do { \
- (Xfound) = output[FOUND]; \
- output[FOUND] += 1; \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
#else
- #define SETFOUND(Xfound, Xnonce) do { \
- Xfound = atomic_add(&output[FOUND], 1); \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[atomic_add(&output[FOUND], 1)] = Xnonce
#endif
#if defined(VECTORS4)
bool result = any(ZA[924] == 0x136032EDU);
if (result) {
- uint found;
-
if (ZA[924].x == 0x136032EDU)
- SETFOUND(found, Znonce.x);
+ SETFOUND(Znonce.x);
if (ZA[924].y == 0x136032EDU)
- SETFOUND(found, Znonce.y);
+ SETFOUND(Znonce.y);
if (ZA[924].z == 0x136032EDU)
- SETFOUND(found, Znonce.z);
+ SETFOUND(Znonce.z);
if (ZA[924].w == 0x136032EDU)
- SETFOUND(found, Znonce.w);
+ SETFOUND(Znonce.w);
}
#elif defined(VECTORS2)
bool result = any(ZA[924] == 0x136032EDU);
if (result) {
- uint found;
-
if (ZA[924].x == 0x136032EDU)
- SETFOUND(found, Znonce.x);
+ SETFOUND(Znonce.x);
if (ZA[924].y == 0x136032EDU)
- SETFOUND(found, Znonce.y);
+ SETFOUND(Znonce.y);
}
#else
- if (ZA[924] == 0x136032EDU) {
- uint found;
-
- SETFOUND(found, Znonce);
- }
+ if (ZA[924] == 0x136032EDU)
+ SETFOUND(Znonce);
#endif
}
View
34 diakgcn120823.cl
@@ -574,45 +574,31 @@ __kernel
#define FOUND (0x0F)
#if defined(OCL1)
- #define SETFOUND(Xfound, Xnonce) do { \
- (Xfound) = output[FOUND]; \
- output[FOUND] += 1; \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
#else
- #define SETFOUND(Xfound, Xnonce) do { \
- Xfound = atomic_add(&output[FOUND], 1); \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[atomic_add(&output[FOUND], 1)] = Xnonce
#endif
#ifdef VECTORS4
if ((V[7].x == 0x136032edU) ^ (V[7].y == 0x136032edU) ^ (V[7].z == 0x136032edU) ^ (V[7].w == 0x136032edU)) {
- uint found;
-
if (V[7].x == 0x136032edU)
- SETFOUND(found, nonce.x);
+ SETFOUND(nonce.x);
if (V[7].y == 0x136032edU)
- SETFOUND(found, nonce.y);
+ SETFOUND(nonce.y);
if (V[7].z == 0x136032edU)
- SETFOUND(found, nonce.z);
+ SETFOUND(nonce.z);
if (V[7].w == 0x136032edU)
- SETFOUND(found, nonce.w);
+ SETFOUND(nonce.w);
}
#elif defined VECTORS2
if ((V[7].x == 0x136032edU) + (V[7].y == 0x136032edU)) {
- uint found;
-
if (V[7].x == 0x136032edU)
- SETFOUND(found, nonce.x);
+ SETFOUND(nonce.x);
if (V[7].y == 0x136032edU)
- SETFOUND(found, nonce.y);
+ SETFOUND(nonce.y);
}
#else
- if (V[7] == 0x136032edU) {
- uint found;
-
- SETFOUND(found, nonce);
- }
+ if (V[7] == 0x136032edU)
+ SETFOUND(nonce);
#endif
}
View
34 phatk120823.cl
@@ -390,47 +390,33 @@ void search( const uint state0, const uint state1, const uint state2, const uint
#define FOUND (0x0F)
#if defined(OCL1)
- #define SETFOUND(Xfound, Xnonce) do { \
- (Xfound) = output[FOUND]; \
- output[FOUND] += 1; \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
#else
- #define SETFOUND(Xfound, Xnonce) do { \
- Xfound = atomic_add(&output[FOUND], 1); \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[atomic_add(&output[FOUND], 1)] = Xnonce
#endif
#ifdef VECTORS4
bool result = W[117].x & W[117].y & W[117].z & W[117].w;
if (!result) {
- uint found;
-
if (!W[117].x)
- SETFOUND(found, W[3].x);
+ SETFOUND(W[3].x);
if (!W[117].y)
- SETFOUND(found, W[3].y);
+ SETFOUND(W[3].y);
if (!W[117].z)
- SETFOUND(found, W[3].z);
+ SETFOUND(W[3].z);
if (!W[117].w)
- SETFOUND(found, W[3].w);
+ SETFOUND(W[3].w);
}
#elif defined VECTORS2
bool result = W[117].x & W[117].y;
if (!result) {
- uint found;
-
if (!W[117].x)
- SETFOUND(found, W[3].x);
+ SETFOUND(W[3].x);
if (!W[117].y)
- SETFOUND(found, W[3].y);
+ SETFOUND(W[3].y);
}
#else
- if (!W[117]) {
- uint found;
-
- SETFOUND(found, W[3]);
- }
+ if (!W[117])
+ SETFOUND(W[3]);
#endif
}
View
29 poclbm120823.cl
@@ -1324,39 +1324,26 @@ Vals[2]+=ch(Vals[1],Vals[4],Vals[3]);
#define FOUND (0x0F)
#if defined(OCL1)
- #define SETFOUND(Xfound, Xnonce) do { \
- (Xfound) = output[FOUND]; \
- output[FOUND] += 1; \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
#else
- #define SETFOUND(Xfound, Xnonce) do { \
- Xfound = atomic_add(&output[FOUND], 1); \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[atomic_add(&output[FOUND], 1)] = Xnonce
#endif
#if defined(VECTORS2) || defined(VECTORS4)
-
if (any(Vals[2] == 0x136032edU)) {
- uint found;
-
if (Vals[2].x == 0x136032edU)
- SETFOUND(found, nonce.x);
+ SETFOUND(nonce.x);
if (Vals[2].y == 0x136032edU)
- SETFOUND(found, nonce.y);
+ SETFOUND(nonce.y);
#if defined(VECTORS4)
if (Vals[2].z == 0x136032edU)
- SETFOUND(found, nonce.z);
+ SETFOUND(nonce.z);
if (Vals[2].w == 0x136032edU)
- SETFOUND(found, nonce.w);
+ SETFOUND(nonce.w);
#endif
}
#else
- if (Vals[2] == 0x136032edU) {
- uint found;
-
- SETFOUND(found, nonce);
- }
+ if (Vals[2] == 0x136032edU)
+ SETFOUND(nonce);
#endif
}
View
18 scrypt120823.cl
@@ -685,16 +685,9 @@ void scrypt_core(uint4 X[8], __global uint4*restrict lookup)
#define FOUND (0x0F)
#if defined(OCL1)
- #define SETFOUND(Xfound, Xnonce) do { \
- (Xfound) = output[FOUND]; \
- output[FOUND] += 1; \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[output[FOUND]++] = Xnonce
#else
- #define SETFOUND(Xfound, Xnonce) do { \
- Xfound = atomic_add(&output[FOUND], 1); \
- output[Xfound] = Xnonce; \
- } while (0)
+ #define SETFOUND(Xnonce) output[atomic_add(&output[FOUND], 1)] = Xnonce
#endif
__attribute__((reqd_work_group_size(WORKSIZE, 1, 1)))
@@ -734,11 +727,8 @@ const uint4 midstate0, const uint4 midstate16, const uint target)
SHA256(&ostate0,&ostate1, tmp0, tmp1, (uint4)(0x80000000U, 0U, 0U, 0U), (uint4)(0U, 0U, 0U, 0x300U));
bool result = (EndianSwap(ostate1.w) <= target);
- if (result) {
- uint found;
-
- SETFOUND(found, gid);
- }
+ if (result)
+ SETFOUND(gid);
}
/*-

0 comments on commit 9bec1e1

Please sign in to comment.