Browse Source

Minimal support for defining devices with multiple logical processors

Currently each processor still needs its own thread
Luke Dashjr 13 years ago
parent
commit
0509084841
2 changed files with 31 additions and 1 deletions
  1. 27 1
      miner.c
  2. 4 0
      miner.h

+ 27 - 1
miner.c

@@ -7641,9 +7641,35 @@ void renumber_cgpu(struct cgpu_info *cgpu)
 
 bool add_cgpu(struct cgpu_info*cgpu)
 {
+	int lpcount;
+	
 	renumber_cgpu(cgpu);
-	devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + 2));
+	if (!cgpu->procs)
+		cgpu->procs = 1;
+	lpcount = cgpu->procs;
+	cgpu->device = cgpu;
+	devices = realloc(devices, sizeof(struct cgpu_info *) * (total_devices + lpcount + 1));
 	devices[total_devices++] = cgpu;
+	
+	if (lpcount > 1)
+	{
+		int tpp = cgpu->threads / lpcount;
+		struct cgpu_info **nlp_p, *slave;
+		
+		nlp_p = &cgpu->next_proc;
+		for (int i = 1; i < lpcount; ++i)
+		{
+			slave = malloc(sizeof(*slave));
+			*slave = *cgpu;
+			slave->proc_id = i;
+			slave->threads = tpp;
+			devices[total_devices++] = slave;
+			*nlp_p = slave;
+			nlp_p = &cgpu->next_proc;
+		}
+		cgpu->proc_id = 0;
+		cgpu->threads -= (tpp * (lpcount - 1));
+	}
 	return true;
 }
 

+ 4 - 0
miner.h

@@ -382,6 +382,10 @@ struct cgpu_info {
 	const char *devtype;
 	int device_id;
 	const char *name;
+	int procs;
+	int proc_id;
+	struct cgpu_info *device;
+	struct cgpu_info *next_proc;
 	const char *device_path;
 	FILE *device_file;
 	union {