Browse Source

Merge branch '2014-benchmark' into bfgminer

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

+ 2 - 1
Makefile.am

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

+ 18 - 11
miner.c

@@ -77,7 +77,6 @@
 #include "adl.h"
 #include "adl.h"
 #include "driver-cpu.h"
 #include "driver-cpu.h"
 #include "driver-opencl.h"
 #include "driver-opencl.h"
-#include "bench_block.h"
 #include "scrypt.h"
 #include "scrypt.h"
 
 
 #ifdef USE_AVALON
 #ifdef USE_AVALON
@@ -4604,18 +4603,21 @@ static void calc_diff(struct work *work, int known)
 
 
 static void get_benchmark_work(struct work *work)
 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->mandatory = true;
 	work->pool = pools[0];
 	work->pool = pools[0];
 	cgtime(&work->tv_getwork);
 	cgtime(&work->tv_getwork);
 	copy_time(&work->tv_getwork_reply, &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;
 	work->getwork_mode = GETWORK_MODE_BENCHMARK;
 	calc_diff(work, 0);
 	calc_diff(work, 0);
 }
 }
@@ -8861,6 +8863,12 @@ static
 void _submit_work_async(struct work *work)
 void _submit_work_async(struct work *work)
 {
 {
 	applog(LOG_DEBUG, "Pushing submit work to work thread");
 	applog(LOG_DEBUG, "Pushing submit work to work thread");
+	
+	if (opt_benchmark)
+	{
+		free_work(work);
+		return;
+	}
 
 
 	mutex_lock(&submitting_lock);
 	mutex_lock(&submitting_lock);
 	++total_submitting;
 	++total_submitting;
@@ -11422,8 +11430,6 @@ int main(int argc, char *argv[])
 	if (opt_benchmark) {
 	if (opt_benchmark) {
 		struct pool *pool;
 		struct pool *pool;
 
 
-		if (opt_scrypt)
-			quit(1, "Cannot use benchmark mode with scrypt");
 		want_longpoll = false;
 		want_longpoll = false;
 		pool = add_pool();
 		pool = add_pool();
 		pool->rpc_url = malloc(255);
 		pool->rpc_url = malloc(255);
@@ -11767,6 +11773,7 @@ begin_bench:
 	cgtime(&total_tv_start);
 	cgtime(&total_tv_start);
 	cgtime(&total_tv_end);
 	cgtime(&total_tv_end);
 
 
+	if (!opt_benchmark)
 	{
 	{
 		pthread_t submit_thread;
 		pthread_t submit_thread;
 		if (unlikely(pthread_create(&submit_thread, NULL, submit_work_thread, NULL)))
 		if (unlikely(pthread_create(&submit_thread, NULL, submit_work_thread, NULL)))