Browse Source

Merge commit 'b34f36b' into bfgminer

Luke Dashjr 13 years ago
parent
commit
e070c9af4a
4 changed files with 29 additions and 20 deletions
  1. 17 16
      driver-opencl.c
  2. 9 1
      miner.c
  3. 1 1
      miner.h
  4. 2 2
      ocl.c

+ 17 - 16
driver-opencl.c

@@ -1360,20 +1360,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 */
 
@@ -1786,15 +1789,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;
 

+ 9 - 1
miner.c

@@ -233,6 +233,7 @@ struct timeval block_timeval;
 struct block {
 	char hash[37];
 	UT_hash_handle hh;
+	int block_no;
 };
 
 static struct block *blocks = NULL;
@@ -3220,6 +3221,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;
@@ -3243,6 +3249,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
@@ -3251,6 +3258,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;
@@ -3262,7 +3270,7 @@ static void test_work_current(struct work *work)
 		wr_unlock(&blk_lock);
 		work->pool->block_id = block_id;
 		set_curblock(hexstr, work->data);
-		if (unlikely(++new_blocks == 1))
+		if (unlikely(new_blocks == 1))
 			goto out_free;
 
 		if (work->longpoll) {

+ 1 - 1
miner.h

@@ -390,7 +390,7 @@ struct cgpu_info {
 	int threads;
 	struct thr_info **thr;
 
-	unsigned int max_hashes;
+	int64_t max_hashes;
 
 	const char *kname;
 #ifdef HAVE_OPENCL

+ 2 - 2
ocl.c

@@ -570,7 +570,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 */
@@ -588,7 +588,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.");