]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
linux/mic: add a MICSerialNumber info attribute when running inside the MIC
authorBrice Goglin <Brice.Goglin@inria.fr>
Thu, 17 Oct 2013 17:04:50 +0000 (19:04 +0200)
committerBrice Goglin <Brice.Goglin@inria.fr>
Thu, 17 Oct 2013 17:04:50 +0000 (19:04 +0200)
OMPI people want an easy way to recognize MICs and nodes using hwloc.
We already have MICSerialNumber inside OS devices in the host topology,
add the same to the root object of MIC topologies.
Unfortunately, we couldn't find anything better than parsing /proc/elog
to find that number.

NEWS
doc/hwloc.doxy
src/topology-linux.c

diff --git a/NEWS b/NEWS
index 6086d7cff6f031366fd63874871997c7336b8e10..37b48c71ffbc3ae06d4f6610f4bb92f7b4b33ae3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,9 @@ Version 1.8.0
     crashes when hwloc is dynamically loaded by another plugin mechanisms.
   + Add --with-hwloc-plugins-path to specify the install/load directories
     of plugins.
+  + Add the MICSerialNumber info attribute to the root object when running
+    hwloc inside a Xeon Phi to match the same attribute in the MIC OS device
+    when running in the host.
 * API
   + hwloc.h and hwloc/helper.h have been reorganized to clarify the
     documentation sections. The actual inline code has moved out of hwloc.h
index 12bc835b870b65799c0fbefd3692e2c30dec3e4a..84f186657d5c67344456dc63fbd479eb919296e2 100644 (file)
@@ -1667,8 +1667,18 @@ object instead.
 <dt>NVIDIAUUID, NVIDIASerial (NVML GPU OS devices)</dt>
 <dd>The UUID and Serial of NVIDIA GPUs.
 </dd>
-<dt>MICFamily, MICSKU, MICSerialNumber, MICActiveCores, MICMemorySize</dt>
-<dd>The family, SKU (model), serial number,
+<dt>MICSerialNumber</dt>
+<dd>
+ The serial number of an Intel Xeon Phi (MIC) coprocessor.
+ When running hwloc on the host, each hwloc OS device object that
+ corresponds to a Xeon Phi gets such an attribute.
+ When running hwloc inside a Xeon Phi, the root object of the topology
+ gets this attribute.
+ It enables easy identification of devices and topologies when multiples
+ nodes and MICs are involved.
+</dd>
+<dt>MICFamily, MICSKU, MICActiveCores, MICMemorySize</dt>
+<dd>The family, SKU (model),
  number of active cores, and memory size (in kB)
  of an Intel Xeon Phi (MIC) coprocessor.
 </dd>
index dbab62d20ba0926aabc6d97edf8fed92a0c92555..c88b1cd60c14e81231475550d5750e9ee20d1265 100644 (file)
@@ -3397,6 +3397,29 @@ look_cpuinfo(struct hwloc_topology *topology,
  ****** Main Topology Discovery ******
  *************************************/
 
+static void
+hwloc__linux_get_mic_sn(struct hwloc_topology *topology, struct hwloc_linux_backend_data_s *data)
+{
+  FILE *file;
+  char line[64], *tmp, *end;
+  file = hwloc_fopen("/proc/elog", "r", data->root_fd);
+  if (!file)
+    return;
+  if (!fgets(line, sizeof(line), file))
+    goto out_with_file;
+  if (strncmp(line, "Card ", 5))
+    goto out_with_file;
+  tmp = line + 5;
+  end = strchr(tmp, ':');
+  if (!end)
+    goto out_with_file;
+  *end = '\0';
+  hwloc_obj_add_info(hwloc_get_root_obj(topology), "MICSerialNumber", tmp);
+
+ out_with_file:
+  fclose(file);
+}
+
 static void
 hwloc_linux_fallback_pu_level(struct hwloc_topology *topology)
 {
@@ -3531,6 +3554,8 @@ hwloc_look_linuxfs(struct hwloc_backend *backend)
     free(cpuset_name);
   }
 
+  hwloc__linux_get_mic_sn(topology, data);
+
   /* gather uname info if fsroot wasn't changed */
   if (topology->is_thissystem)
      hwloc_add_uname_info(topology);