Optimise loop and make debug debug only.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
diff --git a/cpu-miner.c b/cpu-miner.c
index 16c6a9e..cf611f9 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -814,25 +814,24 @@ static void *gpuminer_thread(void *userdata)
BUFFERSIZE, res, 0, NULL, NULL);
if (unlikely(status != CL_SUCCESS))
{ applog(LOG_ERR, "Error: clEnqueueReadBuffer failed. (clEnqueueReadBuffer)"); goto out;}
- for (i = 0; i < 128; i++) {
- int found = false;
-
- if (res[i]) {
- uint32_t start = res[i];
- uint32_t my_g, my_nonce;
-
- applog(LOG_INFO, "GPU Found something?");
- my_g = postcalc_hash(mythr, &work->blk, work, start, start + 1026, &my_nonce, &h0count);
- found = true;
- res[i] = 0;
- }
- if (found) {
- /* Clear the buffer again */
- status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
- BUFFERSIZE, res, 0, NULL, NULL);
- if (unlikely(status != CL_SUCCESS))
- { applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed."); goto out; }
+ if (unlikely(res[127])) {
+ /* 127 is used as a flag to say nonces exist */
+ for (i = 0; i < 127; i++) {
+ if (res[i]) {
+ uint32_t start = res[i];
+ uint32_t my_g, my_nonce;
+
+ applog(LOG_INFO, "GPU Found something?");
+ my_g = postcalc_hash(mythr, &work->blk, work, start, start + 1026, &my_nonce, &h0count);
+ res[i] = 0;
+ } else
+ break;
}
+ /* Clear the buffer again */
+ status = clEnqueueWriteBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
+ BUFFERSIZE, res, 0, NULL, NULL);
+ if (unlikely(status != CL_SUCCESS))
+ { applog(LOG_ERR, "Error: clEnqueueWriteBuffer failed."); goto out; }
}
gettimeofday(&tv_end, NULL);
diff --git a/ocl.c b/ocl.c
index 02e0d60..326f303 100644
--- a/ocl.c
+++ b/ocl.c
@@ -308,7 +308,8 @@ _clState *initCl(int gpu, char *name, size_t nameSize) {
/* copy over all of the generated binaries. */
binaries = (char **)malloc( sizeof(char *)*nDevices );
for( i = 0; i < nDevices; i++ ) {
- printf("binary size %d : %d\n", i, binary_sizes[i]);
+ if (opt_debug)
+ applog(LOG_DEBUG, "binary size %d : %d\n", i, binary_sizes[i]);
if( binary_sizes[i] != 0 )
binaries[i] = (char *)malloc( sizeof(char)*binary_sizes[i] );
else
diff --git a/oclminer.cl b/oclminer.cl
index 968d01c..54fd1a0 100644
--- a/oclminer.cl
+++ b/oclminer.cl
@@ -629,9 +629,10 @@ A = A + E;
H = H + D;
if (H==0xa41f32e7) {
- for (it = 0; it != 128; it++) {
+ for (it = 0; it != 127; it++) {
if (!output[it]) {
output[it] = tnonce;
+ output[127] = 1;
break;
}
}