Browse Source

opencl: Teach findnonce to behave based on kernel interface rather than mining algorithm

Luke Dashjr 11 years ago
parent
commit
60b127eaaf
3 changed files with 7 additions and 5 deletions
  1. 1 1
      driver-opencl.c
  2. 5 3
      findnonce.c
  3. 1 1
      findnonce.h

+ 1 - 1
driver-opencl.c

@@ -1807,7 +1807,7 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
 			return -1;
 		}
 		applog(LOG_DEBUG, "GPU %d found something?", gpu->device_id);
-		postcalc_hash_async(thr, work, thrdata->res);
+		postcalc_hash_async(thr, work, thrdata->res, kinfo->interface);
 		memset(thrdata->res, 0, buffersize);
 		/* This finish flushes the writebuffer set with CL_FALSE in clEnqueueWriteBuffer */
 		clFinish(clState->commandQueue);

+ 5 - 3
findnonce.c

@@ -140,6 +140,7 @@ struct pc_data {
 	uint32_t res[OPENCL_MAX_BUFFERSIZE];
 	pthread_t pth;
 	int found;
+	enum cl_kernels kinterface;
 };
 
 static void *postcalc_hash(void *userdata)
@@ -149,7 +150,7 @@ static void *postcalc_hash(void *userdata)
 	unsigned int entry = 0;
 	int found = FOUND;
 #ifdef USE_SCRYPT
-	if (work_mining_algorithm(&pcd->work)->algo == POW_SCRYPT)
+	if (pcd->kinterface == KL_SCRYPT)
 		found = SCRYPT_FOUND;
 #endif
 
@@ -178,7 +179,7 @@ static void *postcalc_hash(void *userdata)
 	return NULL;
 }
 
-void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
+void postcalc_hash_async(struct thr_info * const thr, struct work * const work, uint32_t * const res, const enum cl_kernels kinterface)
 {
 	struct pc_data *pcd = malloc(sizeof(struct pc_data));
 	int buffersize;
@@ -190,10 +191,11 @@ void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
 
 	*pcd = (struct pc_data){
 		.thr = thr,
+		.kinterface = kinterface,
 	};
 	__copy_work(&pcd->work, work);
 #ifdef USE_SCRYPT
-	if (work_mining_algorithm(work)->algo == POW_SCRYPT)
+	if (kinterface == KL_SCRYPT)
 		buffersize = SCRYPT_BUFFERSIZE;
 	else
 #endif

+ 1 - 1
findnonce.h

@@ -25,6 +25,6 @@
 #ifdef USE_SHA256D
 extern void precalc_hash(struct opencl_work_data *blk, uint32_t *state, uint32_t *data);
 #endif
-extern void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res);
+extern void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res, enum cl_kernels);
 
 #endif /*__FINDNONCE_H__*/