Browse Source

Rework benchmark mode

Luke Dashjr 12 years ago
parent
commit
fddc67ec53
2 changed files with 13 additions and 12 deletions
  1. 2 1
      Makefile.am
  2. 11 11
      miner.c

+ 2 - 1
Makefile.am

@@ -64,7 +64,7 @@ bfgminer_CPPFLAGS += $(libblkmaker_CFLAGS)
 # common sources
 bfgminer_SOURCES := miner.c
 
-bfgminer_SOURCES	+= miner.h compat.h bench_block.h	\
+bfgminer_SOURCES += miner.h compat.h  \
 	deviceapi.c deviceapi.h \
 		   util.c util.h logging.h		\
 		   sha2.c sha2.h api.c
@@ -143,6 +143,7 @@ bfgminer_SOURCES	+= \
 
 # the CPU portion extracted from original main.c
 bfgminer_SOURCES += driver-cpu.h driver-cpu.c
+bfgminer_SOURCES += bench_block.h
 
 if HAVE_SSE2
 bfgminer_LDADD  += libsse2cpuminer.a

+ 11 - 11
miner.c

@@ -77,7 +77,6 @@
 #include "adl.h"
 #include "driver-cpu.h"
 #include "driver-opencl.h"
-#include "bench_block.h"
 #include "scrypt.h"
 
 #ifdef USE_AVALON
@@ -4604,18 +4603,21 @@ static void calc_diff(struct work *work, int known)
 
 static void get_benchmark_work(struct work *work)
 {
-	// Use a random work block pulled from a pool
-	static uint8_t bench_block[] = { CGMINER_BENCHMARK_BLOCK };
-
-	size_t bench_size = sizeof(*work);
-	size_t work_size = sizeof(bench_block);
-	size_t min_size = (work_size < bench_size ? work_size : bench_size);
-	memset(work, 0, sizeof(*work));
-	memcpy(work, &bench_block, min_size);
+	static uint32_t blkhdr[20];
+	for (int i = 19; i >= 0; --i)
+		if (++blkhdr[i])
+			break;
+	
+	memcpy(&work->data[ 0], blkhdr, 80);
+	memcpy(&work->data[80], workpadding_bin, 48);
+	calc_midstate(work);
+	set_target(work->target, 1.0);
+	
 	work->mandatory = true;
 	work->pool = pools[0];
 	cgtime(&work->tv_getwork);
 	copy_time(&work->tv_getwork_reply, &work->tv_getwork);
+	copy_time(&work->tv_staged, &work->tv_getwork);
 	work->getwork_mode = GETWORK_MODE_BENCHMARK;
 	calc_diff(work, 0);
 }
@@ -11422,8 +11424,6 @@ int main(int argc, char *argv[])
 	if (opt_benchmark) {
 		struct pool *pool;
 
-		if (opt_scrypt)
-			quit(1, "Cannot use benchmark mode with scrypt");
 		want_longpoll = false;
 		pool = add_pool();
 		pool->rpc_url = malloc(255);