From 69983b778b71a11b2bc3a9d07219727be1338171 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 28 Aug 2012 17:19:38 +1000 Subject: [PATCH 1/8] Revert "Pick worksize 256 with Cypress if none is specified." This reverts commit 482322a4b7add8458bee946ffb247a9a587fc25f. Worksize 256 was only helpful on cypress with ultra-low memory speeds with old SDKs and the new kernels require higher memory clocks, having the opposite net effect. --- ocl.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ocl.c b/ocl.c index fe457822..042fea2c 100644 --- a/ocl.c +++ b/ocl.c @@ -468,12 +468,8 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) clState->wsize = cgpu->work_size; else if (strstr(name, "Tahiti")) clState->wsize = 64; - else { - if (strstr(name, "Cypress")) - clState->wsize = 256; - else - clState->wsize = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth; - } + else + clState->wsize = (clState->max_work_size <= 256 ? clState->max_work_size : 256) / clState->vwidth; cgpu->work_size = clState->wsize; #ifdef USE_SCRYPT From d91af893c8ac473609c7565c791cc2fab5456de4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 28 Aug 2012 18:08:39 +1000 Subject: [PATCH 2/8] Use correct sdk version detection for SDK 2.7 --- ocl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ocl.c b/ocl.c index 042fea2c..450a2d61 100644 --- a/ocl.c +++ b/ocl.c @@ -393,7 +393,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) strstr(vbuff, "831.4") || strstr(vbuff, "898.1") || // 12.2 driver SDK strstr(vbuff, "923.1") || // 12.4 - strstr(vbuff, "938.1"))) { // SDK 2.7 + strstr(vbuff, "938.2"))) { // SDK 2.7 applog(LOG_INFO, "Selecting diablo kernel"); clState->chosen_kernel = KL_DIABLO; /* Detect all 7970s, older ATI and NVIDIA and use poclbm */ @@ -411,7 +411,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) if (clState->chosen_kernel == KL_PHATK && (strstr(vbuff, "844.4") || strstr(vbuff, "851.4") || strstr(vbuff, "831.4") || strstr(vbuff, "898.1") || - strstr(vbuff, "923.1") || strstr(vbuff, "938.1"))) { + strstr(vbuff, "923.1") || strstr(vbuff, "938.2"))) { applog(LOG_WARNING, "WARNING: You have selected the phatk kernel."); applog(LOG_WARNING, "You are running SDK 2.6+ which performs poorly with this kernel."); applog(LOG_WARNING, "Downgrade your SDK and delete any .bin files before starting again."); From f97bf2e2acb9e1bdb84a511836dfb1d45731996e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 28 Aug 2012 20:16:50 +1000 Subject: [PATCH 3/8] Keep the local block number in the blocks structs stored and sort them by number to guarantee we delete the oldest when ageing the block struct entries. --- cgminer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cgminer.c b/cgminer.c index f677a60b..89d75ae8 100644 --- a/cgminer.c +++ b/cgminer.c @@ -218,6 +218,7 @@ struct timeval block_timeval; struct block { char hash[37]; UT_hash_handle hh; + int block_no; }; static struct block *blocks = NULL; @@ -2811,6 +2812,11 @@ static inline bool from_existing_block(struct work *work) return ret; } +static int block_sort(struct block *blocka, struct block *blockb) +{ + return blockb->block_no - blocka->block_no; +} + static void test_work_current(struct work *work) { char *hexstr; @@ -2832,6 +2838,7 @@ static void test_work_current(struct work *work) if (unlikely(!s)) quit (1, "test_work_current OOM"); strcpy(s->hash, hexstr); + s->block_no = new_blocks++; wr_lock(&blk_lock); /* Only keep the last 6 blocks in memory since work from blocks * before this is virtually impossible and we want to prevent @@ -2840,6 +2847,7 @@ static void test_work_current(struct work *work) struct block *blocka, *blockb; int count = 0; + HASH_SORT(blocks, block_sort); HASH_ITER(hh, blocks, blocka, blockb) { if (count++ < 6) continue; @@ -2850,7 +2858,7 @@ static void test_work_current(struct work *work) HASH_ADD_STR(blocks, hash, s); wr_unlock(&blk_lock); set_curblock(hexstr, work->data); - if (unlikely(++new_blocks == 1)) + if (unlikely(new_blocks == 1)) goto out_free; work_block++; From a178039a655be960c13188cd68b0401f5a702011 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 30 Aug 2012 23:22:37 +1000 Subject: [PATCH 4/8] miner.h max_hashes -> int64_t --- miner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner.h b/miner.h index 13f4960c..a234ecd3 100644 --- a/miner.h +++ b/miner.h @@ -352,7 +352,7 @@ struct cgpu_info { int threads; struct thr_info **thr; - unsigned int max_hashes; + int64_t max_hashes; const char *kname; #ifdef HAVE_OPENCL From f1c6ae22f79863ee01ed164c7355b56e9915cfcb Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 31 Aug 2012 09:13:19 +1000 Subject: [PATCH 5/8] Adjust opencl intensity when adjusting thread count to prevent it getting pegged at a value below the minimum threads possible. --- driver-opencl.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/driver-opencl.c b/driver-opencl.c index 6883ada3..ded20c31 100644 --- a/driver-opencl.c +++ b/driver-opencl.c @@ -1106,20 +1106,23 @@ static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_u } #endif -static void set_threads_hashes(unsigned int vectors, unsigned int *threads, - int64_t *hashes, size_t *globalThreads, - unsigned int minthreads, int intensity) +static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *globalThreads, + unsigned int minthreads, __maybe_unused int *intensity) { - if (opt_scrypt) { - if (intensity < 0) - intensity = 0; - *threads = 1 << intensity; - } else - *threads = 1 << (15 + intensity); - if (*threads < minthreads) - *threads = minthreads; - *globalThreads = *threads; - *hashes = *threads * vectors; + unsigned int threads = 0; + + while (threads < minthreads) { + threads = 1 << ((opt_scrypt ? 0 : 15) + *intensity); + if (threads < minthreads) { + if (likely(*intensity < MAX_INTENSITY)) + (*intensity)++; + else + threads = minthreads; + } + } + + *globalThreads = threads; + *hashes = threads * vectors; } #endif /* HAVE_OPENCL */ @@ -1499,15 +1502,13 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, cl_int status; size_t globalThreads[1]; size_t localThreads[1] = { clState->wsize }; - unsigned int threads; int64_t hashes; /* This finish flushes the readbuffer set with CL_FALSE later */ if (!gpu->dynamic) clFinish(clState->commandQueue); - set_threads_hashes(clState->vwidth, &threads, &hashes, globalThreads, - localThreads[0], gpu->intensity); + set_threads_hashes(clState->vwidth, &hashes, globalThreads, localThreads[0], &gpu->intensity); if (hashes > gpu->max_hashes) gpu->max_hashes = hashes; From 57c3b12f64706fb39dadc664ffd14ae7c7e7dc8e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 31 Aug 2012 12:01:44 +1000 Subject: [PATCH 6/8] Sort the blocks database in reverse order, allowing us to remove the first block without iterating over them. Output the block number to debug. --- cgminer.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cgminer.c b/cgminer.c index 89d75ae8..c9114b28 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2814,7 +2814,7 @@ static inline bool from_existing_block(struct work *work) static int block_sort(struct block *blocka, struct block *blockb) { - return blockb->block_no - blocka->block_no; + return blocka->block_no - blockb->block_no; } static void test_work_current(struct work *work) @@ -2834,29 +2834,29 @@ static void test_work_current(struct work *work) * new block and set the current block details to this one */ if (!block_exists(hexstr)) { struct block *s = calloc(sizeof(struct block), 1); + int deleted_block = 0; if (unlikely(!s)) quit (1, "test_work_current OOM"); strcpy(s->hash, hexstr); s->block_no = new_blocks++; wr_lock(&blk_lock); - /* Only keep the last 6 blocks in memory since work from blocks - * before this is virtually impossible and we want to prevent - * memory usage from continually rising */ - if (HASH_COUNT(blocks) > 5) { - struct block *blocka, *blockb; - int count = 0; + /* Only keep the last hour's worth of blocks in memory since + * work from blocks before this is virtually impossible and we + * want to prevent memory usage from continually rising */ + if (HASH_COUNT(blocks) > 6) { + struct block *oldblock; HASH_SORT(blocks, block_sort); - HASH_ITER(hh, blocks, blocka, blockb) { - if (count++ < 6) - continue; - HASH_DEL(blocks, blocka); - free(blocka); - } + oldblock = blocks; + deleted_block = oldblock->block_no; + HASH_DEL(blocks, oldblock); + free(oldblock); } HASH_ADD_STR(blocks, hash, s); wr_unlock(&blk_lock); + if (deleted_block) + applog(LOG_DEBUG, "Deleted block %d from database", deleted_block); set_curblock(hexstr, work->data); if (unlikely(new_blocks == 1)) goto out_free; From ae8bacc54f5a4d299453fa1c3d7265ccbda5e802 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 31 Aug 2012 12:24:14 +1000 Subject: [PATCH 7/8] Update NEWS. --- NEWS | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/NEWS b/NEWS index 06f328dd..6b104c30 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,22 @@ +Version 2.7.5 - August 31, 2012 + +- Adjust opencl intensity when adjusting thread count to prevent it getting +pegged at a value below the minimum threads possible. +- miner.h max_hashes -> int64_t +- Keep the local block number in the blocks structs stored and sort them by +number to guarantee we delete the oldest when ageing the block struct entries. +- Use correct sdk version detection for SDK 2.7 +- Revert "Pick worksize 256 with Cypress if none is specified." +- Test for lagging once more in queue_request to enable work to leak to backup +pools. +- There is no need to try to switch pools in select_pool since the current pool +is actually not affected by the choice of pool to get work from. +- Only clear the pool lagging flag if we're staging work faster than we're using +it. +- needed flag is currently always false in queue_request. Remove it for now. +- thr is always NULL going into queue_request now. + + Version 2.7.4 - August 23, 2012 - Perform select_pool even when not lagging to allow it to switch back if needed From ba0122535a7045f75adcab2953f51c241683b0de Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 31 Aug 2012 12:24:39 +1000 Subject: [PATCH 8/8] Bump version number to 2.7.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4197da9c..68ea6ca7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## m4_define([v_maj], [2]) m4_define([v_min], [7]) -m4_define([v_mic], [4]) +m4_define([v_mic], [5]) ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## m4_define([v_ver], [v_maj.v_min.v_mic]) m4_define([lt_rev], m4_eval(v_maj + v_min))