1
0
mirror of https://github.com/GOSTSec/gostoclminer synced 2025-01-30 16:34:29 +00:00

less clFinish(); hashmeter measures total loop time

This commit is contained in:
tcatm 2011-02-05 11:23:53 +01:00
parent cf84c8ce42
commit 53da7abb6c

16
miner.c
View File

@ -277,8 +277,10 @@ static void *miner_thread(void *thr_id_int)
int res_frame = 0; int res_frame = 0;
int my_block = block; int my_block = block;
bool need_work = true; bool need_work = true;
unsigned long hashes_done;
hashes_done = 0;
while (1) { while (1) {
unsigned long hashes_done;
struct timeval tv_start; struct timeval tv_start;
bool rc; bool rc;
@ -315,7 +317,9 @@ static void *miner_thread(void *thr_id_int)
need_work = false; need_work = false;
} }
hashes_done = 0; if (hashes_done != 0)
hashmeter(thr_id, &tv_start, hashes_done);
gettimeofday(&tv_start, NULL); gettimeofday(&tv_start, NULL);
int threads = 102400 * 4; int threads = 102400 * 4;
@ -326,6 +330,8 @@ static void *miner_thread(void *thr_id_int)
sizeof(dev_blk_ctx), (void *)&work[frame].blk, 0, NULL, NULL); sizeof(dev_blk_ctx), (void *)&work[frame].blk, 0, NULL, NULL);
if(status != CL_SUCCESS) { printf("Error: clEnqueueWriteBuffer failed.\n"); return 0; } if(status != CL_SUCCESS) { printf("Error: clEnqueueWriteBuffer failed.\n"); return 0; }
clFinish(clState->commandQueue);
status = clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 1, NULL, status = clEnqueueNDRangeKernel(clState->commandQueue, clState->kernel, 1, NULL,
globalThreads, localThreads, 0, NULL, NULL); globalThreads, localThreads, 0, NULL, NULL);
if(status != CL_SUCCESS) { printf("Error: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)\n"); return 0; } if(status != CL_SUCCESS) { printf("Error: Enqueueing kernel onto command queue. (clEnqueueNDRangeKernel)\n"); return 0; }
@ -377,14 +383,10 @@ static void *miner_thread(void *thr_id_int)
} }
} }
clFinish(clState->commandQueue);
status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0, status = clEnqueueReadBuffer(clState->commandQueue, clState->outputBuffer, CL_TRUE, 0,
sizeof(uint32_t) * threads, res, 0, NULL, NULL); sizeof(uint32_t) * threads, res, 0, NULL, NULL);
if(status != CL_SUCCESS) { printf("Error: clEnqueueReadBuffer failed. (clEnqueueReadBuffer)\n"); return 0; } if(status != CL_SUCCESS) { printf("Error: clEnqueueReadBuffer failed. (clEnqueueReadBuffer)\n"); return 0; }
clFinish(clState->commandQueue);
res_frame = frame; res_frame = frame;
work[res_frame].ready = threads; work[res_frame].ready = threads;
work[res_frame].res_nonce = work[res_frame].blk.nonce; work[res_frame].res_nonce = work[res_frame].blk.nonce;
@ -394,8 +396,6 @@ static void *miner_thread(void *thr_id_int)
if (work[frame].blk.nonce > 4000000 - threads) if (work[frame].blk.nonce > 4000000 - threads)
need_work = true; need_work = true;
hashmeter(thr_id, &tv_start, hashes_done);
failures = 0; failures = 0;
} }