Browse Source

cpu: Add --algo fastauto (new default) to detect a usable algorithm without taking over a minute

Luke Dashjr 12 years ago
parent
commit
69ab302ae6
4 changed files with 14 additions and 4 deletions
  1. 1 0
      README
  2. 11 4
      driver-cpu.c
  3. 1 0
      driver-cpu.h
  4. 1 0
      miner.c

+ 1 - 0
README

@@ -298,6 +298,7 @@ For other FPGA details see the README.FPGA
 CPU only options (not included in binaries):
 CPU only options (not included in binaries):
 
 
 --algo|-a <arg>     Specify sha256 implementation for CPU mining:
 --algo|-a <arg>     Specify sha256 implementation for CPU mining:
+        fastauto*       Quick benchmark at startup to pick a working algorithm
         auto            Benchmark at startup and pick fastest algorithm
         auto            Benchmark at startup and pick fastest algorithm
         c               Linux kernel sha256, implemented in C
         c               Linux kernel sha256, implemented in C
         4way            tcatm's 4-way SSE2 implementation
         4way            tcatm's 4-way SSE2 implementation

+ 11 - 4
driver-cpu.c

@@ -166,6 +166,7 @@ const char *algo_names[] = {
 #ifdef WANT_SCRYPT
 #ifdef WANT_SCRYPT
     [ALGO_SCRYPT] = "scrypt",
     [ALGO_SCRYPT] = "scrypt",
 #endif
 #endif
+	[ALGO_FASTAUTO] = "fastauto",
 	[ALGO_AUTO] = "auto",
 	[ALGO_AUTO] = "auto",
 };
 };
 
 
@@ -202,7 +203,7 @@ static const sha256_func sha256_funcs[] = {
 
 
 
 
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
-enum sha256_algos opt_algo = ALGO_AUTO;
+enum sha256_algos opt_algo = ALGO_FASTAUTO;
 bool opt_usecpu = false;
 bool opt_usecpu = false;
 static bool forced_n_threads;
 static bool forced_n_threads;
 #endif
 #endif
@@ -238,7 +239,7 @@ double bench_algo_stage3(
 
 
 	struct timeval end;
 	struct timeval end;
 	struct timeval start;
 	struct timeval start;
-	uint32_t max_nonce = (1<<22);
+	uint32_t max_nonce = opt_algo == ALGO_FASTAUTO ? (1<<8) : (1<<22);
 	uint32_t last_nonce = 0;
 	uint32_t last_nonce = 0;
 
 
 	memcpy(&hash1[0], &hash1_init[0], sizeof(hash1));
 	memcpy(&hash1[0], &hash1_init[0], sizeof(hash1));
@@ -792,8 +793,14 @@ static bool cpu_thread_init(struct thr_info *thr)
 	const int thr_id = thr->id;
 	const int thr_id = thr->id;
 
 
 	mutex_lock(&cpualgo_lock);
 	mutex_lock(&cpualgo_lock);
-	if (opt_algo == ALGO_AUTO)
-		opt_algo = pick_fastest_algo();
+	switch (opt_algo)
+	{
+		case ALGO_AUTO:
+		case ALGO_FASTAUTO:
+			opt_algo = pick_fastest_algo();
+		default:
+			break;
+	}
 	mutex_unlock(&cpualgo_lock);
 	mutex_unlock(&cpualgo_lock);
 
 
 	/* Set worker threads to nice 19 and then preferentially to SCHED_IDLE
 	/* Set worker threads to nice 19 and then preferentially to SCHED_IDLE

+ 1 - 0
driver-cpu.h

@@ -50,6 +50,7 @@ enum sha256_algos {
 	ALGO_ALTIVEC_4WAY,	/* parallel Altivec */
 	ALGO_ALTIVEC_4WAY,	/* parallel Altivec */
 	ALGO_SCRYPT,		/* scrypt */
 	ALGO_SCRYPT,		/* scrypt */
 	
 	
+	ALGO_FASTAUTO,		/* fast autodetect */
 	ALGO_AUTO		/* autodetect */
 	ALGO_AUTO		/* autodetect */
 };
 };
 
 

+ 1 - 0
miner.c

@@ -1124,6 +1124,7 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--algo|-a",
 	OPT_WITH_ARG("--algo|-a",
 		     set_algo, show_algo, &opt_algo,
 		     set_algo, show_algo, &opt_algo,
 		     "Specify sha256 implementation for CPU mining:\n"
 		     "Specify sha256 implementation for CPU mining:\n"
+		     "\tfastauto*\tQuick benchmark at startup to pick a working algorithm\n"
 		     "\tauto\t\tBenchmark at startup and pick fastest algorithm"
 		     "\tauto\t\tBenchmark at startup and pick fastest algorithm"
 		     "\n\tc\t\tLinux kernel sha256, implemented in C"
 		     "\n\tc\t\tLinux kernel sha256, implemented in C"
 #ifdef WANT_SSE2_4WAY
 #ifdef WANT_SSE2_4WAY