Browse Source

RPC: Update to include ProcID so multiprocessor devices can be understood correctly

Luke Dashjr 13 years ago
parent
commit
5b1f70410e
3 changed files with 57 additions and 35 deletions
  1. 25 8
      API-README
  2. 10 8
      api.c
  3. 22 19
      miner.php

+ 25 - 8
API-README

@@ -244,7 +244,7 @@ The list of requests - a (*) means it requires privileged access - and replies a
                               reply before BFGMiner quits
                               reply before BFGMiner quits
 
 
  notify        NOTIFY         The last status and history count of each devices problem
  notify        NOTIFY         The last status and history count of each devices problem
-                              e.g. NOTIFY=0,Name=GPU,ID=0,Last Well=1332432290,...|
+                              e.g. NOTIFY=0,Name=PGA,ID=0,ProcID=0,Last Well=1332432290,...|
 
 
  privileged (*)
  privileged (*)
                none           There is no reply section just the STATUS section
                none           There is no reply section just the STATUS section
@@ -282,7 +282,7 @@ The list of requests - a (*) means it requires privileged access - and replies a
  devdetails    DEVDETAILS     Each device with a list of their static details
  devdetails    DEVDETAILS     Each device with a list of their static details
                               This lists all devices including those not supported
                               This lists all devices including those not supported
                               by the 'devs' command
                               by the 'devs' command
-                              e.g. DEVDETAILS=0,Name=GPU,ID=0,Driver=opencl,...|
+                              e.g. DEVDETAILS=0,Name=PGA,ID=0,ProcID=0,Driver=bitforce,...|
 
 
  restart (*)   none           There is no status section but just a single "RESTART"
  restart (*)   none           There is no status section but just a single "RESTART"
                               reply before BFGMiner restarts
                               reply before BFGMiner restarts
@@ -408,6 +408,22 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 Feature Changelog for external applications using the API:
 
 
 
 
+API V1.24b
+
+Modified API commands:
+ 'cpustatus' - Added 'ProcID'
+ 'gpustatus' - Added 'ProcID'
+ 'pgastatus' - Added 'ProcID'
+ 'devstatus' - Added 'ProcID'
+ 'notify' - Added 'ProcID'
+ 'devdetails' - Added 'ProcID'
+ 'devdetail' - Added 'Name', 'ID', and 'ProcID'
+
+Pretty much updated every method returning 'Name' and 'ID' to also return
+'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.
+
+----------
+
 API V1.24 (BFGMiner v2.10.3)
 API V1.24 (BFGMiner v2.10.3)
 
 
 Added API commands:
 Added API commands:
@@ -1239,7 +1255,8 @@ Looking at the Mobile example:
   'RIGS' => null,
   'RIGS' => null,
   'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks', 
   'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks', 
 			Accepted', 'Rejected=Rej', 'Utility'),
 			Accepted', 'Rejected=Rej', 'Utility'),
-  'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.Status=Status',
+  'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.ProcID=Proc',
+			'DEVS.Status=Status',
 			'DEVS.Temperature=Temp', 'DEVS.MHS av=MHS av',
 			'DEVS.Temperature=Temp', 'DEVS.MHS av=MHS av',
 			'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
 			'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
 			'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
 			'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
@@ -1280,11 +1297,11 @@ Each table will have the chosen details for all the rigs specified in $rigs
 	since each field name in the join between DEVS and NOTIFY is actually
 	since each field name in the join between DEVS and NOTIFY is actually
 	section.fieldname, not just fieldname
 	section.fieldname, not just fieldname
 
 
-	The join code automatically adds 2 fields to each GPU device: 'Name' and 'ID'
-	They don't exist in the API 'devs' output but I can correctly calculate
-	them from the GPU device data
-	These two fields are used to join DEVS to NOTIFY i.e. find the NOTIFY
-	record that has the same Name and ID as the DEVS record and join them
+	The join code automatically adds 2 fields to each GPU device: 'Name', 'ID',
+	and 'ProcID'. They don't exist in the API 'devs' output but we can correctly
+	calculate them from the GPU device data. These two fields are used to join
+	DEVS to NOTIFY: i.e. find the NOTIFY record that has the same Name/ID/ProcID
+	as the DEVS record and join them.
 
 
  POOL
  POOL
 
 

+ 10 - 8
api.c

@@ -1460,6 +1460,15 @@ static const char *status2str(enum alive status)
 	}
 	}
 }
 }
 
 
+static
+struct api_data *api_add_device_identifier(struct api_data *root, struct cgpu_info *cgpu)
+{
+	root = api_add_string(root, "Name", cgpu->api->name, false);
+	root = api_add_int(root, "ID", &(cgpu->device_id), false);
+	root = api_add_int(root, "ProcID", &(cgpu->proc_id), false);
+	return root;
+}
+
 static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson, bool precom)
 static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson, bool precom)
 {
 {
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;
@@ -1476,6 +1485,7 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	}
 	}
 
 
 	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
 	root = api_add_int(root, (char*)cgpu->devtype, &n, true);
+	root = api_add_device_identifier(root, cgpu);
 	root = api_add_string(root, "Driver", cgpu->api->dname, false);
 	root = api_add_string(root, "Driver", cgpu->api->dname, false);
 	if (cgpu->kname)
 	if (cgpu->kname)
 		root = api_add_string(root, "Kernel", cgpu->kname, false);
 		root = api_add_string(root, "Kernel", cgpu->kname, false);
@@ -1491,14 +1501,6 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
 	io_add(io_data, buf);
 	io_add(io_data, buf);
 }
 }
 
 
-static
-struct api_data *api_add_device_identifier(struct api_data *root, struct cgpu_info *cgpu)
-{
-	root = api_add_string(root, "Name", cgpu->api->name, false);
-	root = api_add_int(root, "ID", &(cgpu->device_id), false);
-	return root;
-}
-
 static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson, bool precom)
 static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool isjson, bool precom)
 {
 {
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;

+ 22 - 19
miner.php

@@ -82,7 +82,8 @@ $mobilepage = array(
  'DATE' => null,
  'DATE' => null,
  'RIGS' => null,
  'RIGS' => null,
  'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks', 'Accepted', 'Rejected=Rej', 'Utility'),
  'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks', 'Accepted', 'Rejected=Rej', 'Utility'),
- 'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.Status=Status', 'DEVS.Temperature=Temp',
+ 'DEVS+NOTIFY' => array('DEVS.Name=Name', 'DEVS.ID=ID', 'DEVS.ProcID=Proc',
+			'DEVS.Status=Status', 'DEVS.Temperature=Temp',
 			'DEVS.MHS av=MHS av', 'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
 			'DEVS.MHS av=MHS av', 'DEVS.Accepted=Accept', 'DEVS.Rejected=Rej',
 			'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
 			'DEVS.Utility=Utility', 'NOTIFY.Last Not Well=Not Well'),
  'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected=Rej', 'Last Share Time'));
  'POOL' => array('POOL', 'Status', 'Accepted', 'Rejected=Rej', 'Last Share Time'));
@@ -1739,6 +1740,19 @@ function joinfields($section1, $section2, $join, $results)
  return $newres;
  return $newres;
 }
 }
 #
 #
+function join_get_field($field, $fields)
+{
+	// : means a string constant otherwise it's a field name
+	// ProcID field name is converted to a lowercase letter
+	if (substr($field, 0, 1) == ':')
+		return substr($field, 1);
+	else
+	if ($field == 'ProcID')
+		return chr(97 + $fields[$field]);
+	else
+		return $fields[$field];
+}
+#
 function joinlr($section1, $section2, $join, $results)
 function joinlr($section1, $section2, $join, $results)
 {
 {
  global $sectionmap;
  global $sectionmap;
@@ -1763,15 +1777,9 @@ function joinlr($section1, $section2, $join, $results)
 		}
 		}
 
 
 		// Build L string to be matched
 		// Build L string to be matched
-		// : means a string constant otherwise it's a field name
 		$Lval = '';
 		$Lval = '';
 		foreach ($join['L'] as $field)
 		foreach ($join['L'] as $field)
-		{
-			if (substr($field, 0, 1) == ':')
-				$Lval .= substr($field, 1);
-			else
-				$Lval .= $fields1b[$field];
-		}
+			$Lval .= join_get_field($field, $fields1b);
 
 
 		// foreach answer section in the rig api call (for the other api command)
 		// foreach answer section in the rig api call (for the other api command)
 		foreach ($results[$name2][$rig] as $name2b => $fields2b)
 		foreach ($results[$name2][$rig] as $name2b => $fields2b)
@@ -1780,15 +1788,9 @@ function joinlr($section1, $section2, $join, $results)
 				continue;
 				continue;
 
 
 			// Build R string and compare
 			// Build R string and compare
-			// : means a string constant otherwise it's a field name
 			$Rval = '';
 			$Rval = '';
 			foreach ($join['R'] as $field)
 			foreach ($join['R'] as $field)
-			{
-				if (substr($field, 0, 1) == ':')
-					$Rval .= substr($field, 1);
-				else
-					$Rval .= $fields2b[$field];
-			}
+				$Rval .= join_get_field($field, $fields2b);
 
 
 			if ($Lval === $Rval)
 			if ($Lval === $Rval)
 			{
 			{
@@ -1856,7 +1858,7 @@ function joinsections($sections, $results, $errors)
 {
 {
  global $sectionmap;
  global $sectionmap;
 
 
- // GPU's don't have Name,ID fields - so create them
+ // GPU's don't have Name,ID,ProcID fields - so create them
  foreach ($results as $section => $res)
  foreach ($results as $section => $res)
 	foreach ($res as $rig => $result)
 	foreach ($res as $rig => $result)
 		foreach ($result as $name => $fields)
 		foreach ($result as $name => $fields)
@@ -1866,6 +1868,7 @@ function joinsections($sections, $results, $errors)
 			{
 			{
 				$results[$section][$rig][$name]['Name'] = 'GPU';
 				$results[$section][$rig][$name]['Name'] = 'GPU';
 				$results[$section][$rig][$name]['ID'] = $result[$name]['GPU'];
 				$results[$section][$rig][$name]['ID'] = $result[$name]['GPU'];
+				$results[$section][$rig][$name]['ProcID'] = 0;
 			}
 			}
 		}
 		}
 
 
@@ -1898,12 +1901,12 @@ function joinsections($sections, $results, $errors)
 				case 'NOTIFY':
 				case 'NOTIFY':
 				case 'DEVDETAILS':
 				case 'DEVDETAILS':
 				case 'USBSTATS':
 				case 'USBSTATS':
-					$join = array('Name', 'ID');
+					$join = array('Name', 'ID', 'ProcID');
 					$sectionmap[$section] = $section;
 					$sectionmap[$section] = $section;
 					$results[$section] = joinfields($both[0], $both[1], $join, $results);
 					$results[$section] = joinfields($both[0], $both[1], $join, $results);
 					break;
 					break;
 				case 'STATS':
 				case 'STATS':
-					$join = array('L' => array('Name','ID'), 'R' => array('ID'));
+					$join = array('L' => array('Name','ID','ProcID'), 'R' => array('ID'));
 					$sectionmap[$section] = $section;
 					$sectionmap[$section] = $section;
 					$results[$section] = joinlr($both[0], $both[1], $join, $results);
 					$results[$section] = joinlr($both[0], $both[1], $join, $results);
 					break;
 					break;
@@ -2690,7 +2693,7 @@ function display()
  endtable();
  endtable();
  otherrow('<td><br><br></td>');
  otherrow('<td><br><br></td>');
  newtable();
  newtable();
- doforeach('devs', 'device list', $sum, array(''=>'','ID'=>'','Name'=>''), false);
+ doforeach('devs', 'device list', $sum, array(''=>'','ProcID'=>'','ID'=>'','Name'=>''), false);
  endtable();
  endtable();
  otherrow('<td><br><br></td>');
  otherrow('<td><br><br></td>');
  newtable();
  newtable();