Browse Source

Bugfix: cpu: Adapt benchmarking code to new benchmark work generator

Luke Dashjr 12 years ago
parent
commit
1d7cac1208
3 changed files with 4 additions and 9 deletions
  1. 2 8
      driver-cpu.c
  2. 1 1
      miner.c
  3. 1 0
      miner.h

+ 2 - 8
driver-cpu.c

@@ -228,16 +228,10 @@ double bench_algo_stage3(
 	enum sha256_algos algo
 )
 {
-	// Use a random work block pulled from a pool
-	static uint8_t bench_block[] = { CGMINER_BENCHMARK_BLOCK };
 	struct work work __attribute__((aligned(128)));
 	unsigned char hash1[64];
 
-	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);
+	get_benchmark_work(&work);
 
 	static struct thr_info dummy;
 
@@ -260,7 +254,7 @@ double bench_algo_stage3(
 					work.target,
 					max_nonce,
 					&last_nonce,
-					work.blk.nonce
+					0
 				);
 			}
 	timer_set_now(&end);

+ 1 - 1
miner.c

@@ -4608,7 +4608,7 @@ static void calc_diff(struct work *work, int known)
 	}
 }
 
-static void get_benchmark_work(struct work *work)
+void get_benchmark_work(struct work *work)
 {
 	static uint32_t blkhdr[20];
 	for (int i = 18; i >= 0; --i)

+ 1 - 0
miner.h

@@ -1343,6 +1343,7 @@ struct work {
 
 extern void get_datestamp(char *, size_t, time_t);
 #define get_now_datestamp(buf, bufsz)  get_datestamp(buf, bufsz, INVALID_TIMESTAMP)
+extern void get_benchmark_work(struct work *);
 extern void stratum_work_cpy(struct stratum_work *dst, const struct stratum_work *src);
 extern void stratum_work_clean(struct stratum_work *);
 extern void gen_stratum_work2(struct work *, struct stratum_work *, const char *nonce1);