]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
tools: Add --whole-system and --restrict for uniformity
authorBrice Goglin <Brice.Goglin@inria.fr>
Tue, 15 Oct 2013 09:13:40 +0000 (11:13 +0200)
committerBrice Goglin <Brice.Goglin@inria.fr>
Tue, 15 Oct 2013 09:13:40 +0000 (11:13 +0200)
Add --whole-system to hwloc-bind, hwloc-calc, hwloc-distances and
hwloc-distrib, and add --restrict to hwloc-bind for uniformity among
tools.

Based on http://www.open-mpi.org/community/lists/hwloc-users/2013/10/0908.php

NEWS
utils/hwloc-bind.1in
utils/hwloc-bind.c
utils/hwloc-calc.1in
utils/hwloc-calc.c
utils/hwloc-distances.1in
utils/hwloc-distances.c
utils/hwloc-distrib.1in
utils/hwloc-distrib.c

diff --git a/NEWS b/NEWS
index 4b919d8a85e4a6506bc945ce8a0c87ecffd021be..6086d7cff6f031366fd63874871997c7336b8e10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,9 @@ Version 1.8.0
     discussing the idea.
   + hwloc-calc and friends have a more robust parsing of locations given
     on the command-line and they report useful error messages about it.
+  + Add --whole-system to hwloc-bind, hwloc-calc, hwloc-distances and
+    hwloc-distrib, and add --restrict to hwloc-bind for uniformity among
+    tools.
 * Misc
   + Calling hwloc_topology_load() or hwloc_topology_set_*() on an already
     loaded topology now returns an error.
index 101574f62aa34bda93466d3c14a88c472c618543..1d85f6f01d42d0d85bc92e9b9d83917be480ee4b 100644 (file)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2009-2012 Inria.  All rights reserved.
+.\" Copyright © 2009-2013 Inria.  All rights reserved.
 .\" Copyright © 2010 Université of Bordeaux
 .\" Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 .\" See COPYING in top-level directory.
@@ -76,6 +76,12 @@ program instead of hwloc-specific CPU set string format.
 This option has no impact on the format of input CPU set strings,
 both formats are always accepted.
 .TP
+\fB\-\-restrict\fR <cpuset>
+Restrict the topology to the given cpuset.
+.TP
+\fB\-\-whole\-system\fR
+Do not consider administration limitations.
+.TP
 \fB\-f\fR \fB\-\-force\fR
 Launch the executable even if binding failed.
 .TP
index a03a0aca9ea69442988baecd1b8da74a9fc0cc1c..ed773b170385c8cb5c6b073bbca926c6907e98db 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria.  All rights reserved.
+ * Copyright © 2009-2013 Inria.  All rights reserved.
  * Copyright © 2009-2010, 2012 Université Bordeaux 1
  * Copyright © 2009 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -37,6 +37,10 @@ void usage(const char *name, FILE *where)
                 "                 Retrieve the last processors where the current process ran\n");
   fprintf(where, "  --pid <pid>    Operate on process <pid>\n");
   fprintf(where, "  --taskset      Use taskset-specific format when displaying cpuset strings\n");
+  fprintf(where, "Input topology options:\n");
+  fprintf(where, "  --restrict <set> Restrict the topology to processors listed in <set>\n");
+  fprintf(where, "  --whole-system   Do not consider administration limitations\n");
+  fprintf(where, "Miscellaneous options:\n");
   fprintf(where, "  -f --force     Launch the command even if binding failed\n");
   fprintf(where, "  -q --quiet     Hide non-fatal error messages\n");
   fprintf(where, "  -v --verbose   Show verbose messages\n");
@@ -52,6 +56,7 @@ int main(int argc, char *argv[])
   int working_on_cpubind = 1; /* membind if 0 */
   int get_binding = 0;
   int get_last_cpu_location = 0;
+  unsigned long flags = HWLOC_TOPOLOGY_FLAG_WHOLE_IO|HWLOC_TOPOLOGY_FLAG_ICACHES;
   int force = 0;
   int single = 0;
   int verbose = 0;
@@ -70,7 +75,7 @@ int main(int argc, char *argv[])
   membind_set = hwloc_bitmap_alloc();
 
   hwloc_topology_init(&topology);
-  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_IO|HWLOC_TOPOLOGY_FLAG_ICACHES);
+  hwloc_topology_set_flags(topology, flags);
   hwloc_topology_load(topology);
   depth = hwloc_topology_get_depth(topology);
 
@@ -176,6 +181,34 @@ int main(int argc, char *argv[])
        opt = 1;
        goto next;
       }
+      else if (!strcmp (argv[0], "--whole-system")) {
+       flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
+       hwloc_topology_destroy(topology);
+       hwloc_topology_init(&topology);
+       hwloc_topology_set_flags(topology, flags);
+       hwloc_topology_load(topology);
+       depth = hwloc_topology_get_depth(topology);
+       goto next;
+      }
+      else if (!strcmp (argv[0], "--restrict")) {
+       hwloc_bitmap_t restrictset;
+       int err;
+       if (argc < 2) {
+         usage (callname, stdout);
+         exit(EXIT_FAILURE);
+       }
+       restrictset = hwloc_bitmap_alloc();
+       hwloc_bitmap_sscanf(restrictset, argv[1]);
+       err = hwloc_topology_restrict (topology, restrictset, 0);
+       if (err) {
+         perror("Restricting the topology");
+         /* fallthrough */
+       }
+       hwloc_bitmap_free(restrictset);
+       argc--;
+       argv++;
+       goto next;
+      }
 
       fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
       usage("hwloc-bind", stderr);
index f137cbb3111718d8540c8ff9f57c12d2609407c5..8a6302d1c4017148718125879c455f427203e7c8 100644 (file)
@@ -93,6 +93,9 @@ both formats are always accepted.
 \fB\-\-restrict\fR <cpuset>
 Restrict the topology to the given cpuset.
 .TP
+\fB\-\-whole\-system\fR
+Do not consider administration limitations.
+.TP
 \fB\-i\fR <file>, \fB\-\-input\fR <file>
 Read topology from XML file <file> (instead of discovering the
 topology on the local machine).  If <file> is "\-", the standard input
index c13695ef914c3a276057b8630ef6bf90bd8c4ce2..0d91a27a0c2fb489304d6f1afc8e1712af44f550 100644 (file)
@@ -45,6 +45,7 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where)
   fprintf(where, "  --single                  Singlify the output to a single CPU\n");
   fprintf(where, "Input topology options:\n");
   fprintf(where, "  --restrict <cpuset>       Restrict the topology to processors listed in <cpuset>\n");
+  fprintf(where, "  --whole-system            Do not consider administration limitations\n");
   hwloc_utils_input_format_usage(where, 10);
   fprintf(where, "Miscellaneous options:\n");
   fprintf(where, "  -q --quiet                Hide non-fatal error messages\n");
@@ -235,6 +236,11 @@ int main(int argc, char *argv[])
         verbose--;
         goto next;
       }
+      if (!strcmp (argv[0], "--whole-system")) {
+       flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
+       input_changed = 1;
+       goto next;
+      }
       if (!strcmp(argv[0], "--help")) {
        usage(callname, stdout);
        return EXIT_SUCCESS;
@@ -394,14 +400,17 @@ int main(int argc, char *argv[])
       return EXIT_FAILURE;
     }
 
-    if (input_changed && input) {
-      /* only update the input when actually using it */
+    if (input_changed) {
+      /* flags or input was changed */
       hwloc_topology_destroy(topology);
       hwloc_topology_init(&topology);
       hwloc_topology_set_flags(topology, flags);
-      err = hwloc_utils_enable_input_format(topology, input, input_format, verbose, callname);
-      if (err)
-       return err;
+      if (input) {
+       /* only update the input when actually using it */
+       err = hwloc_utils_enable_input_format(topology, input, input_format, verbose, callname);
+       if (err)
+         return err;
+      }
       hwloc_topology_load(topology);
       depth = hwloc_topology_get_depth(topology);
       input_changed = 0;
@@ -436,14 +445,17 @@ int main(int argc, char *argv[])
     size_t len = HWLOC_CALC_LINE_LEN;
     char * line = malloc(len);
 
-    if (input_changed && input) {
-      /* only update the input when actually using it */
+    if (input_changed) {
+      /* flags or input was changed */
       hwloc_topology_destroy(topology);
       hwloc_topology_init(&topology);
       hwloc_topology_set_flags(topology, flags);
-      err = hwloc_utils_enable_input_format(topology, input, input_format, verbose, callname);
-      if (err)
-        return err;
+      if (input) {
+       /* only update the input when actually using it */
+       err = hwloc_utils_enable_input_format(topology, input, input_format, verbose, callname);
+       if (err)
+         return err;
+      }
       hwloc_topology_load(topology);
       depth = hwloc_topology_get_depth(topology);
       input_changed = 0;
index 7e3535ae17aa6c959ab8e2ef7b4fb975fabc5985..70f0eda4ea16e1738fad0fdcbf132069f27e5cda 100644 (file)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2012 Inria.  All rights reserved.
+.\" Copyright © 2012-2013 Inria.  All rights reserved.
 .\" Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 .\" See COPYING in top-level directory.
 .TH HWLOC-DISTANCES "1" "#HWLOC_DATE#" "#PACKAGE_VERSION#" "#PACKAGE_NAME#"
@@ -49,6 +49,9 @@ and \fBsynthetic\fR.
 \fB\-\-restrict\fR <cpuset>
 Restrict the topology to the given cpuset.
 .TP
+\fB\-\-whole\-system\fR
+Do not consider administration limitations.
+.TP
 \fB\-v\fR \fB\-\-verbose\fR
 Verbose messages.
 .TP
index b38e0ba44129f53bfd671b8de9481e4191c2489e..9330e9e32ffcfcca492d50012689da84c720095b 100644 (file)
@@ -22,6 +22,7 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where)
   fprintf(where, "  -p --physical    Display physical object indexes\n");
   fprintf(where, "Input topology options:\n");
   fprintf(where, "  --restrict <set> Restrict the topology to processors listed in <set>\n");
+  fprintf(where, "  --whole-system   Do not consider administration limitations\n");
   hwloc_utils_input_format_usage(where, 0);
   fprintf(where, "Miscellaneous options:\n");
   fprintf(where, "  -v --verbose     Show verbose messages\n");
@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
   enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT;
   char *restrictstring = NULL;
   hwloc_topology_t topology;
+  unsigned long flags = 0;
   unsigned i, depth;
   int logical = 1;
   int verbose = 0;
@@ -76,6 +78,10 @@ int main(int argc, char *argv[])
        logical = 0;
        goto next;
       }
+      if (!strcmp (argv[0], "--whole-system")) {
+       flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
+       goto next;
+      }
       if (hwloc_utils_lookup_input_option(argv, argc, &opt,
                                          &input, &input_format,
                                          callname)) {
@@ -113,6 +119,7 @@ int main(int argc, char *argv[])
     if (err)
       return err;
   }
+  hwloc_topology_set_flags(topology, flags);
   hwloc_topology_load(topology);
 
   if (restrictstring) {
index 8e4a8203903d0da3e11d097d02613910851c42c8..be79db253def46d05b582073da4670cdd1e1356f 100644 (file)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2010-2012 Inria.  All rights reserved.
+.\" Copyright © 2010-2013 Inria.  All rights reserved.
 .\" Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 .\" See COPYING in top-level directory.
 .TH HWLOC-DISTRIB "1" "#HWLOC_DATE#" "#PACKAGE_VERSION#" "#PACKAGE_NAME#"
@@ -71,6 +71,9 @@ both \fB\-\-from\fR and \fB\-\-to\fR at the same time.
 \fB\-\-restrict\fR <cpuset>
 Restrict the topology to the given cpuset.
 .TP
+\fB\-\-whole\-system\fR
+Do not consider administration limitations.
+.TP
 \fB\-\-version\fR
 Report version and exit.
 .
index bda82c7cccad013ed71db15484ce480f5a585bec..b04c15beb5d26b64f9995c3c2b56089d3fd40468 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria.  All rights reserved.
+ * Copyright © 2009-2013 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,6 +25,7 @@ void usage(const char *callname __hwloc_attribute_unused, FILE *where)
   fprintf(where, "  --at <type>      Distribute among objects of the given type\n");
   fprintf(where, "Input topology options:\n");
   fprintf(where, "  --restrict <set> Restrict the topology to processors listed in <set>\n");
+  fprintf(where, "  --whole-system   Do not consider administration limitations\n");
   hwloc_utils_input_format_usage(where, 0);
   fprintf(where, "Formatting options:\n");
   fprintf(where, "  --single         Singlify each output to a single CPU\n");
@@ -46,6 +47,7 @@ int main(int argc, char *argv[])
   char *restrictstring = NULL;
   hwloc_obj_type_t from_type = (hwloc_obj_type_t) -1, to_type = (hwloc_obj_type_t) -1;
   hwloc_topology_t topology;
+  unsigned long flags = 0;
   int opt;
   int err;
 
@@ -80,6 +82,10 @@ int main(int argc, char *argv[])
        verbose = 1;
        goto next;
       }
+      if (!strcmp (argv[0], "--whole-system")) {
+       flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
+       goto next;
+      }
       if (!strcmp(argv[0], "--help")) {
        usage(callname, stdout);
        return EXIT_SUCCESS;
@@ -194,6 +200,7 @@ int main(int argc, char *argv[])
       if (err)
        return err;
     }
+    hwloc_topology_set_flags(topology, flags);
     hwloc_topology_load(topology);
 
     if (restrictstring) {