Browse Source

Merge commit 'ad1d998' into bfgminer

Luke Dashjr 12 years ago
parent
commit
2d74f585ca
3 changed files with 17 additions and 22 deletions
  1. 9 15
      deviceapi.c
  2. 6 5
      driver-hashfast.c
  3. 2 2
      miner.h

+ 9 - 15
deviceapi.c

@@ -781,13 +781,14 @@ bool _add_cgpu(struct cgpu_info *cgpu)
 		int ns;
 		int ns;
 		int tpp = cgpu->threads / lpcount;
 		int tpp = cgpu->threads / lpcount;
 		struct cgpu_info **nlp_p, *slave;
 		struct cgpu_info **nlp_p, *slave;
-		const bool manylp = (lpcount > 26);
-		const char *as = (manylp ? "aa" : "a");
+		int lpdigits = 1;
+		for (int i = lpcount; i > 26 && lpdigits < 3; i /= 26)
+			++lpdigits;
 		
 		
-		// Note, strcpy instead of assigning a byte to get the \0 too
-		strcpy(&cgpu->proc_repr[5], as);
+		memset(&cgpu->proc_repr[5], 'a', lpdigits);
+		cgpu->proc_repr[5 + lpdigits] = '\0';
 		ns = strlen(cgpu->proc_repr_ns);
 		ns = strlen(cgpu->proc_repr_ns);
-		strcpy(&cgpu->proc_repr_ns[ns], as);
+		strcpy(&cgpu->proc_repr_ns[ns], &cgpu->proc_repr[5]);
 		
 		
 		nlp_p = &cgpu->next_proc;
 		nlp_p = &cgpu->next_proc;
 		for (int i = 1; i < lpcount; ++i)
 		for (int i = 1; i < lpcount; ++i)
@@ -795,17 +796,10 @@ bool _add_cgpu(struct cgpu_info *cgpu)
 			slave = malloc(sizeof(*slave));
 			slave = malloc(sizeof(*slave));
 			*slave = *cgpu;
 			*slave = *cgpu;
 			slave->proc_id = i;
 			slave->proc_id = i;
-			if (manylp)
+			for (int x = i, y = lpdigits; --y, x; x /= 26)
 			{
 			{
-				slave->proc_repr[5] += i / 26;
-				slave->proc_repr[6] += i % 26;
-				slave->proc_repr_ns[ns    ] += i / 26;
-				slave->proc_repr_ns[ns + 1] += i % 26;
-			}
-			else
-			{
-				slave->proc_repr[5] += i;
-				slave->proc_repr_ns[ns] += i;
+				slave->proc_repr_ns[ns + y] =
+				slave->proc_repr[5 + y] += (x % 26);
 			}
 			}
 			slave->threads = tpp;
 			slave->threads = tpp;
 			devices_new[total_devices_new++] = slave;
 			devices_new[total_devices_new++] = slave;

+ 6 - 5
driver-hashfast.c

@@ -105,20 +105,21 @@ static
 ssize_t hashfast_write(const int fd, void * const buf, size_t bufsz)
 ssize_t hashfast_write(const int fd, void * const buf, size_t bufsz)
 {
 {
 	const ssize_t rv = write(fd, buf, bufsz);
 	const ssize_t rv = write(fd, buf, bufsz);
-	if (opt_debug && opt_dev_protocol)
+	if ((opt_debug && opt_dev_protocol) || unlikely(rv != bufsz))
 	{
 	{
+		const int e = errno;
 		char hex[(bufsz * 2) + 1];
 		char hex[(bufsz * 2) + 1];
 		bin2hex(hex, buf, bufsz);
 		bin2hex(hex, buf, bufsz);
 		if (rv < 0)
 		if (rv < 0)
-			applog(LOG_DEBUG, "%s fd=%d: SEND (%s) => %d",
-			       "hashfast", fd, hex, (int)rv);
+			applog(LOG_WARNING, "%s fd=%d: SEND (%s) => %d errno=%d(%s)",
+			       "hashfast", fd, hex, (int)rv, e, bfg_strerror(e, BST_ERRNO));
 		else
 		else
 		if (rv < bufsz)
 		if (rv < bufsz)
-			applog(LOG_DEBUG, "%s fd=%d: SEND %.*s(%s)",
+			applog(LOG_WARNING, "%s fd=%d: SEND %.*s(%s)",
 			       "hashfast", fd, rv * 2, hex, &hex[rv * 2]);
 			       "hashfast", fd, rv * 2, hex, &hex[rv * 2]);
 		else
 		else
 		if (rv > bufsz)
 		if (rv > bufsz)
-			applog(LOG_DEBUG, "%s fd=%d: SEND %s => +%d",
+			applog(LOG_WARNING, "%s fd=%d: SEND %s => +%d",
 			       "hashfast", fd, hex, (int)(rv - bufsz));
 			       "hashfast", fd, hex, (int)(rv - bufsz));
 		else
 		else
 			applog(LOG_DEBUG, "%s fd=%d: SEND %s",
 			applog(LOG_DEBUG, "%s fd=%d: SEND %s",

+ 2 - 2
miner.h

@@ -455,8 +455,8 @@ struct cgpu_info {
 	
 	
 	int procs;
 	int procs;
 	int proc_id;
 	int proc_id;
-	char proc_repr[8];
-	char proc_repr_ns[8];
+	char proc_repr[9];
+	char proc_repr_ns[9];
 	struct cgpu_info *device;
 	struct cgpu_info *device;
 	struct cgpu_info *next_proc;
 	struct cgpu_info *next_proc;