]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
synthetic: add support for L2cache, L1i, group3, etc for for input and export
authorBrice Goglin <Brice.Goglin@inria.fr>
Mon, 3 Feb 2014 21:13:09 +0000 (22:13 +0100)
committerBrice Goglin <Brice.Goglin@inria.fr>
Fri, 7 Feb 2014 12:59:33 +0000 (13:59 +0100)
NEWS
doc/hwloc.doxy
src/topology-synthetic.c
utils/lstopo-text.c

diff --git a/NEWS b/NEWS
index 93ceb9af186eca3e56bf17f9a9a20f23123baae5..54992d19c9f6e5be7c033229fccdd07bfe5b27c5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ Version 1.9.0
   + Add CPUVendor, CPUModelNumber and CPUFamilyNumber info attributes for
     x86, ia64 and Xeon Phi sockets on Linux, to extend the x86-specific
     support added in v1.8.1. Requested by Ralph Castain.
+  + The synthetic backend now accepts extended types such as L2Cache, L1i or
+    Group3. lstopo also exports synthetic strings using these extended types.
 * Tools
   + Add -e or --get-last-cpu-location to hwloc-ps to report where
     processes/threads run instead of where they are bound.
index 8f1445ce2e3e42ff9747216c562451cbc6ecd3f5..dbaefacd83bce3fb08673c66a2ccb59380935427 100644 (file)
@@ -1828,8 +1828,11 @@ That is why the above topology contains 4 cores (2 cores times 2 nodes).
 These type names must be written as
 <tt>machine</tt>, <tt>node</tt>, <tt>socket</tt>, <tt>core</tt>,
 <tt>cache</tt>, <tt>pu</tt>, <tt>misc</tt>, <tt>group</tt>.
-They do not need to be written case-sensitively, nor entirely (2
-characters such as <tt>ma</tt> select a Machine level).
+They do not need to be written case-sensitively, nor entirely
+(as long as there is no ambiguity, 2 characters such as <tt>ma</tt>
+ select a Machine level).
+Type-specific attributes may also be given such as <tt>L2iCache</tt>
+(hwloc_obj_type_sscanf() is used for parsing the type names).
 Note that I/O objects are not available.
 
 The root object does not appear in the string.
index 11c8c333e134338fecad62aca6a51ea7788e790f..c118bfa8ca9a356c500e3e322fb586306ed2d3aa 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria.  All rights reserved.
+ * Copyright © 2009-2014 Inria.  All rights reserved.
  * Copyright © 2009-2010 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -25,7 +25,8 @@ struct hwloc_synthetic_backend_data_s {
   unsigned arity[HWLOC_SYNTHETIC_MAX_DEPTH];
   hwloc_obj_type_t type[HWLOC_SYNTHETIC_MAX_DEPTH];
   unsigned id[HWLOC_SYNTHETIC_MAX_DEPTH];
-  unsigned depth[HWLOC_SYNTHETIC_MAX_DEPTH]; /* For cache/misc */
+  unsigned depth[HWLOC_SYNTHETIC_MAX_DEPTH]; /* For caches/groups */
+  hwloc_obj_cache_type_t cachetype[HWLOC_SYNTHETIC_MAX_DEPTH]; /* For caches */
 };
 
 /* Read from description a series of integers describing a symmetrical
@@ -50,6 +51,8 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
   for (pos = description, count = 1; *pos; pos = next_pos) {
 #define HWLOC_OBJ_TYPE_UNKNOWN ((hwloc_obj_type_t) -1)
     hwloc_obj_type_t type = HWLOC_OBJ_TYPE_UNKNOWN;
+    int typedepth = -1;
+    hwloc_obj_cache_type_t cachetype = (hwloc_obj_cache_type_t) -1;
 
     while (*pos == ' ')
       pos++;
@@ -58,24 +61,12 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
       break;
 
     if (*pos < '0' || *pos > '9') {
-      if (!hwloc_namecoloncmp(pos, "machines", 2)) {
-       type = HWLOC_OBJ_MACHINE;
-      } else if (!hwloc_namecoloncmp(pos, "nodes", 1))
-       type = HWLOC_OBJ_NODE;
-      else if (!hwloc_namecoloncmp(pos, "sockets", 1))
-       type = HWLOC_OBJ_SOCKET;
-      else if (!hwloc_namecoloncmp(pos, "cores", 2))
-       type = HWLOC_OBJ_CORE;
-      else if (!hwloc_namecoloncmp(pos, "caches", 2))
-       type = HWLOC_OBJ_CACHE;
-      else if (!hwloc_namecoloncmp(pos, "pus", 1))
-       type = HWLOC_OBJ_PU;
-      else if (!hwloc_namecoloncmp(pos, "misc", 2))
-       type = HWLOC_OBJ_MISC;
-      else if (!hwloc_namecoloncmp(pos, "group", 2))
-       type = HWLOC_OBJ_GROUP;
-      else if (verbose)
-        fprintf(stderr, "Synthetic string with unknown object type `%s'\n", pos);
+      if (hwloc_obj_type_sscanf(pos, &type, &typedepth, &cachetype, sizeof(cachetype)) < 0) {
+       if (verbose)
+         fprintf(stderr, "Synthetic string with unknown object type at '%s'\n", pos);
+       errno = EINVAL;
+       return -1;
+      }
 
       next_pos = strchr(pos, ':');
       if (!next_pos) {
@@ -109,6 +100,8 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
 
     data->arity[count-1] = (unsigned)item;
     data->type[count] = type;
+    data->depth[count] = (unsigned) typedepth;
+    data->cachetype[count] = cachetype;
     count++;
   }
 
@@ -210,10 +203,15 @@ hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
   for (i=0; i<count; i++) {
     hwloc_obj_type_t type = data->type[i];
 
-    if (type == HWLOC_OBJ_GROUP)
-      data->depth[i] = group_depth--;
-    else if (type == HWLOC_OBJ_CACHE)
-      data->depth[i] = cache_depth--;
+    if (type == HWLOC_OBJ_GROUP) {
+      if (data->depth[i] == (unsigned)-1)
+       data->depth[i] = group_depth--;
+    } else if (type == HWLOC_OBJ_CACHE) {
+      if (data->depth[i] == (unsigned)-1)
+       data->depth[i] = cache_depth--;
+      if (data->cachetype[i] == (hwloc_obj_cache_type_t) -1)
+       data->cachetype[i] = data->depth[i] == 1 ? HWLOC_OBJ_CACHE_DATA : HWLOC_OBJ_CACHE_UNIFIED;
+    }
   }
 
   data->string = strdup(description);
@@ -317,14 +315,13 @@ hwloc__look_synthetic(struct hwloc_topology *topology,
     case HWLOC_OBJ_CACHE:
       obj->attr->cache.depth = data->depth[level];
       obj->attr->cache.linesize = 64;
+      obj->attr->cache.type = data->cachetype[level];
       if (obj->attr->cache.depth == 1) {
        /* 32Kb in L1d */
        obj->attr->cache.size = 32*1024;
-       obj->attr->cache.type = HWLOC_OBJ_CACHE_DATA;
       } else {
        /* *4 at each level, starting from 1MB for L2, unified */
        obj->attr->cache.size = 256*1024 << (2*obj->attr->cache.depth);
-       obj->attr->cache.type = HWLOC_OBJ_CACHE_UNIFIED;
       }
       break;
     case HWLOC_OBJ_CORE:
index 64369f77c5b0887775bf5843b9e68621e99d1894..67267eb5ade12eb0aa597aab45f26198c3f8b024 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2013 Inria.  All rights reserved.
+ * Copyright © 2009-2014 Inria.  All rights reserved.
  * Copyright © 2009-2012 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -275,8 +275,10 @@ void output_synthetic(hwloc_topology_t topology, const char *filename, int logic
 
   arity = obj->arity;
   while (arity) {
+    char types[64];
     obj = obj->first_child;
-    fprintf(output, "%s:%u ", hwloc_obj_type_string(obj->type), arity);
+    hwloc_obj_type_snprintf(types, sizeof(types), obj, 1);
+    fprintf(output, "%s:%u ", types, arity);
     arity = obj->arity;
   }
   fprintf(output, "\n");