Browse Source

Merge commit '6761194' into bfgminer

Luke Dashjr 13 years ago
parent
commit
12255b50e5
3 changed files with 43 additions and 15 deletions
  1. 38 12
      driver-modminer.c
  2. 4 2
      miner.c
  3. 1 1
      miner.h

+ 38 - 12
driver-modminer.c

@@ -106,17 +106,6 @@ modminer_detect()
 	serial_detect_auto(modminer_api.dname, modminer_detect_one, modminer_detect_auto);
 }
 
-static void
-get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
-{
-	float gt = modminer->temp;
-	if (gt > 0)
-		tailsprintf(buf, "%5.1fC ", gt);
-	else
-		tailsprintf(buf, "       ", gt);
-	tailsprintf(buf, "        | ");
-}
-
 #define bailout(...)  return _bailout(-1, modminer, __VA_ARGS__);
 #define bailout2(...)  return _bailout(fd, modminer, __VA_ARGS__);
 
@@ -255,6 +244,8 @@ struct modminer_fpga_state {
 	int no_nonce_counter;
 	int good_share_counter;
 	time_t last_cutoff_reduced;
+
+	unsigned char temp;
 };
 
 static bool
@@ -346,6 +337,39 @@ modminer_fpga_init(struct thr_info *thr)
 	return true;
 }
 
+static void
+get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
+{
+	char info[18] = "               | ";
+	int tc = modminer->threads;
+	bool havetemp = false;
+	int i;
+
+	if (tc > 4)
+		tc = 4;
+
+	for (i = tc - 1; i >= 0; --i) {
+		struct thr_info*thr = modminer->thr[i];
+		struct modminer_fpga_state *state = thr->cgpu_data;
+		unsigned char temp = state->temp;
+
+		info[i*3+2] = '/';
+		if (temp) {
+			havetemp = true;
+			if (temp > 9)
+				info[i*3+0] = 0x30 + (temp / 10);
+			info[i*3+1] = 0x30 + (temp % 10);
+		}
+	}
+	if (havetemp) {
+		info[tc*3-1] = ' ';
+		info[tc*3] = 'C';
+		strcat(buf, info);
+	}
+	else
+		strcat(buf, "               | ");
+}
+
 static bool
 modminer_prepare_next_work(struct modminer_fpga_state*state, struct work*work)
 {
@@ -401,7 +425,9 @@ modminer_process_results(struct thr_info*thr)
 	mutex_lock(&modminer->device_mutex);
 	if (2 == write(fd, cmd, 2) && read(fd, &temperature, 1) == 1)
 	{
-		modminer->temp = (float)temperature;
+		state->temp = temperature;
+		if (!fpgaid)
+			modminer->temp = (float)temperature;
 		if (temperature > modminer->cutofftemp - 2) {
 			if (temperature > modminer->cutofftemp) {
 				applog(LOG_WARNING, "%s %u.%u: Hit thermal cutoff limit, disabling device!", modminer->api->name, modminer->device_id, fpgaid);

+ 4 - 2
miner.c

@@ -4390,7 +4390,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 #ifdef HAVE_OPENCL
 		for (i = 0; i < total_devices; ++i) {
 			struct cgpu_info *cgpu = devices[i];
-			struct thr_info *thr = cgpu->thread;
+			struct thr_info *thr = cgpu->thr[0];
 			enum dev_enable *denable;
 			int gpu;
 
@@ -5271,6 +5271,8 @@ begin_bench:
 	k = 0;
 	for (i = 0; i < total_devices; ++i) {
 		struct cgpu_info *cgpu = devices[i];
+		cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1));
+		cgpu->thr[cgpu->threads] = NULL;
 
 		for (j = 0; j < cgpu->threads; ++j, ++k) {
 			thr = &thr_info[k];
@@ -5313,7 +5315,7 @@ begin_bench:
 			if (unlikely(thr_info_create(thr, NULL, miner_thread, thr)))
 				quit(1, "thread %d create failed", thr->id);
 
-			cgpu->thread = thr;
+			cgpu->thr[j] = thr;
 		}
 	}
 

+ 1 - 1
miner.h

@@ -325,7 +325,7 @@ struct cgpu_info {
 	struct timeval last_message_tv;
 
 	int threads;
-	struct thr_info *thread;
+	struct thr_info **thr;
 
 	unsigned int max_hashes;