Browse Source

cpu & opencl: Refuse to detect more than once

Rationale: No hotpluggable CPU & GPU support, and no claim/conflict detection
Luke Dashjr 12 years ago
parent
commit
7d9176a549
3 changed files with 13 additions and 0 deletions
  1. 3 0
      driver-cpu.c
  2. 2 0
      driver-opencl.c
  3. 8 0
      util.h

+ 3 - 0
driver-cpu.c

@@ -33,6 +33,7 @@
 #include "fpgautils.h"
 #include "miner.h"
 #include "bench_block.h"
+#include "util.h"
 #include "driver-cpu.h"
 
 #if defined(unix)
@@ -770,6 +771,8 @@ static int cpu_autodetect()
 
 static void cpu_detect()
 {
+	RUNONCE();
+	
 	if ((opt_n_threads < 0 || !forced_n_threads)
 	 && ((total_devices || total_devices_new) && !opt_usecpu))
 		// If there are any other devices, only act if the user has explicitly enabled it

+ 2 - 0
driver-opencl.c

@@ -1485,6 +1485,8 @@ static int opencl_autodetect()
 
 static void opencl_detect()
 {
+	RUNONCE();
+	
 	// This wrapper ensures users can specify -S opencl:noauto to disable it
 	noserial_detect(&opencl_api, opencl_autodetect);
 }

+ 8 - 0
util.h

@@ -189,4 +189,12 @@ struct timeval *select_timeout(struct timeval *tvp_timeout, struct timeval *tvp_
 }
 
 
+#define RUNONCE(rv)  do {  \
+	static bool _runonce = false;  \
+	if (_runonce)  \
+		return rv;  \
+	_runonce = true;  \
+} while(0)
+
+
 #endif /* __UTIL_H__ */