Browse Source

Merge branch 'master' into myfork

Luke Dashjr 13 years ago
parent
commit
1694fbe632
9 changed files with 66 additions and 10 deletions
  1. 13 5
      adl.c
  2. 5 2
      cgminer.c
  3. 1 1
      driver-bitforce.c
  4. 1 1
      driver-icarus.c
  5. 30 0
      driver-opencl.c
  6. 1 0
      driver-opencl.h
  7. 1 1
      driver-ztex.c
  8. 2 0
      miner.h
  9. 12 0
      ocl.c

+ 13 - 5
adl.c

@@ -268,12 +268,11 @@ void init_adl(int nDevs)
 		 * one. Now since there's no way of correlating the
 		 * opencl enumerated devices and the ADL enumerated
 		 * ones, we have to assume they're in the same order.*/
-		if (++devices > nDevs) {
+		if (++devices > nDevs && devs_match) {
 			applog(LOG_ERR, "ADL found more devices than opencl!");
 			applog(LOG_ERR, "There is possibly at least one GPU that doesn't support OpenCL");
+			applog(LOG_ERR, "Use the gpu map feature to reliably map OpenCL to ADL");
 			devs_match = false;
-			devices = nDevs;
-			break;
 		}
 		last_adapter = lpAdapterID;
 
@@ -286,16 +285,25 @@ void init_adl(int nDevs)
 	if (devices < nDevs) {
 		applog(LOG_ERR, "ADL found less devices than opencl!");
 		applog(LOG_ERR, "There is possibly more than one display attached to a GPU");
+		applog(LOG_ERR, "Use the gpu map feature to reliably map OpenCL to ADL");
 		devs_match = false;
 	}
 
-	for (i = 0; i < nDevs; i++) {
+	for (i = 0; i < devices; i++) {
 		vadapters[i].virtual_gpu = i;
 		vadapters[i].id = adapters[i].id;
 	}
 
+	/* Apply manually provided OpenCL to ADL mapping, if any */
+	for (i = 0; i < nDevs; i++) {
+		if (gpus[i].mapped) {
+			vadapters[gpus[i].virtual_adl].virtual_gpu = i;
+			applog(LOG_INFO, "Mapping OpenCL device %d to ADL device %d", i, gpus[i].virtual_adl);
+		}
+	}
+			
 	if (!devs_match) {
-		applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices does not match!");
+		applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices did not match!");
 		applog(LOG_ERR, "Hardware monitoring may NOT match up with devices!");
 	} else if (opt_reorder) {
 		/* Windows has some kind of random ordering for bus number IDs and

+ 5 - 2
cgminer.c

@@ -714,6 +714,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--gpu-fan",
 		     set_gpu_fan, NULL, NULL,
 		     "GPU fan percentage range - one value, range and/or comma separated list (e.g. 0-85,85,65)"),
+	OPT_WITH_ARG("--gpu-map",
+		     set_gpu_map, NULL, NULL,
+		     "Map OpenCL to ADL device order manually, paired CSV (e.g. 1:0,2:1 maps OpenCL 1 to ADL 0, 2 to 1)"),
 	OPT_WITH_ARG("--gpu-memclock",
 		     set_gpu_memclock, NULL, NULL,
 		     "Set the GPU memory (over)clock in Mhz - one value for all or separate by commas for per card"),
@@ -783,8 +786,8 @@ static struct opt_table opt_config_table[] = {
 			opt_set_bool, &opt_protocol,
 			"Verbose dump of protocol-level activities"),
 	OPT_WITH_ARG("--queue|-Q",
-		     set_int_0_to_10, opt_show_intval, &opt_queue,
-		     "Minimum number of work items to have queued (0 - 10)"),
+		     set_int_0_to_9999, opt_show_intval, &opt_queue,
+		     "Minimum number of work items to have queued (0+)"),
 	OPT_WITHOUT_ARG("--quiet|-q",
 			opt_set_bool, &opt_quiet,
 			"Disable logging output, display status and errors"),

+ 1 - 1
driver-bitforce.c

@@ -365,7 +365,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 
 struct device_api bitforce_api = {
 	.dname = "bitforce",
-	.name = "PGA",
+	.name = "BFL",
 	.api_detect = bitforce_detect,
 	.get_statline_before = get_bitforce_statline_before,
 	.thread_prepare = bitforce_thread_prepare,

+ 1 - 1
driver-icarus.c

@@ -381,7 +381,7 @@ static void icarus_shutdown(struct thr_info *thr)
 
 struct device_api icarus_api = {
 	.dname = "icarus",
-	.name = "PGA",
+	.name = "ICA",
 	.api_detect = icarus_detect,
 	.thread_prepare = icarus_prepare,
 	.scanhash = icarus_scanhash,

+ 30 - 0
driver-opencl.c

@@ -171,6 +171,36 @@ char *set_kernel(char *arg)
 #endif
 
 #ifdef HAVE_ADL
+/* This function allows us to map an adl device to an opencl device for when
+ * simple enumeration has failed to match them. */
+char *set_gpu_map(char *arg)
+{
+	int val1 = 0, val2 = 0;
+	char *nextptr;
+
+	nextptr = strtok(arg, ",");
+	if (nextptr == NULL)
+		return "Invalid parameters for set gpu map";
+	if (sscanf(arg, "%d:%d", &val1, &val2) != 2)
+		return "Invalid description for map pair";
+	if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES)
+		return "Invalid value passed to set_gpu_map";
+
+	gpus[val1].virtual_adl = val2;
+	gpus[val1].mapped = true;
+
+	while ((nextptr = strtok(NULL, ",")) != NULL) {
+		if (sscanf(nextptr, "%d:%d", &val1, &val2) != 2)
+			return "Invalid description for map pair";
+		if (val1 < 0 || val1 > MAX_GPUDEVICES || val2 < 0 || val2 > MAX_GPUDEVICES)
+			return "Invalid value passed to set_gpu_map";
+		gpus[val1].virtual_adl = val2;
+		gpus[val1].mapped = true;
+	}
+
+	return NULL;
+}
+
 void get_intrange(char *arg, int *val1, int *val2)
 {
 	if (sscanf(arg, "%d-%d", val1, val2) == 1) {

+ 1 - 0
driver-opencl.h

@@ -6,6 +6,7 @@
 
 extern char *print_ndevs_and_exit(int *ndevs);
 extern void *reinit_gpu(void *userdata);
+extern char *set_gpu_map(char *arg);
 extern char *set_gpu_engine(char *arg);
 extern char *set_gpu_fan(char *arg);
 extern char *set_gpu_memclock(char *arg);

+ 1 - 1
driver-ztex.c

@@ -313,7 +313,7 @@ static void ztex_disable(struct thr_info *thr)
 
 struct device_api ztex_api = {
 	.dname = "ztex",
-	.name = "PGA",
+	.name = "ZTX",
 	.api_detect = ztex_detect,
 	.get_statline_before = ztex_statline_before,
 	.thread_prepare = ztex_prepare,

+ 2 - 0
miner.h

@@ -282,7 +282,9 @@ struct cgpu_info {
 
 	unsigned int max_hashes;
 
+	bool mapped;
 	int virtual_gpu;
+	int virtual_adl;
 	int intensity;
 	bool dynamic;
 	char *kname;

+ 12 - 0
ocl.c

@@ -123,6 +123,18 @@ int clDevicesNum(void) {
 		applog(LOG_INFO, "Platform %d devices: %d", i, numDevices);
 		if (numDevices > most_devices)
 			most_devices = numDevices;
+		if (numDevices) {
+			unsigned int j;
+			char pbuff[256];
+			cl_device_id *devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
+
+			clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
+			for (j = 0; j < numDevices; j++) {
+				clGetDeviceInfo(devices[j], CL_DEVICE_NAME, sizeof(pbuff), pbuff, NULL);
+				applog(LOG_INFO, "\t%i\t%s", j, pbuff);
+			}
+			free(devices);
+		}
 	}
 
 	return most_devices;