Browse Source

Fix GPU memory allocation size for scrypt

Fix logic to find smallest power of 2 value bigger than required memory amount needed by scrypt kernel.
Jake 13 years ago
parent
commit
9e627b685b
1 changed files with 2 additions and 5 deletions
  1. 2 5
      ocl.c

+ 2 - 5
ocl.c

@@ -652,7 +652,6 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 #ifdef USE_SCRYPT
 #ifdef USE_SCRYPT
 	if (opt_scrypt) {
 	if (opt_scrypt) {
 		cl_ulong ma = cgpu->max_alloc, mt;
 		cl_ulong ma = cgpu->max_alloc, mt;
-		int pow2 = 0;
 
 
 		if (!cgpu->opt_lg) {
 		if (!cgpu->opt_lg) {
 			applog(LOG_DEBUG, "GPU %d: selecting lookup gap of 2", gpu);
 			applog(LOG_DEBUG, "GPU %d: selecting lookup gap of 2", gpu);
@@ -676,12 +675,10 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
 		 * >= required amount to map nicely to an intensity */
 		 * >= required amount to map nicely to an intensity */
 		mt = cgpu->thread_concurrency * 32768 * cgpu->lookup_gap;
 		mt = cgpu->thread_concurrency * 32768 * cgpu->lookup_gap;
 		if (ma > mt) {
 		if (ma > mt) {
-			while (ma >>= 1)
-				pow2++;
 			ma = 1;
 			ma = 1;
-			while (--pow2 && ma < mt)
+			while (ma < mt)
 				ma <<= 1;
 				ma <<= 1;
-			if (ma >= mt) {
+			if (ma < cgpu->max_alloc) {
 				cgpu->max_alloc = ma;
 				cgpu->max_alloc = ma;
 				applog(LOG_DEBUG, "Max alloc decreased to %lu", cgpu->max_alloc);
 				applog(LOG_DEBUG, "Max alloc decreased to %lu", cgpu->max_alloc);
 			}
 			}