[mpich-commits] r10739 - in mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc: . config contrib contrib/dist doc include include/hwloc include/private src tests tests/linux tests/linux/gather tests/ports tests/ports/include tests/ports/include/sys tests/rename tests/xml utils

balaji at mcs.anl.gov balaji at mcs.anl.gov
Sun Dec 9 21:23:47 CST 2012


Author: balaji
Date: 2012-12-09 21:23:44 -0600 (Sun, 09 Dec 2012)
New Revision: 10739

Added:
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_components.m4
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/components.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/base64.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/components.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-custom.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-fake.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-noos.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_list_components.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_pci_backend.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/wrapper.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-fake-plugin.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.input
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.output
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.sh.in
Modified:
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/HACKING
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/NEWS
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/README
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/VERSION
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/autogen.sh
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc.m4
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_internal.m4
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/configure.ac
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/dist/make_dist_tarball
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/hwloc-valgrind.supp
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/hwloc.doxy
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc/rename.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/cpuid.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/private.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/xml.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/bind.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/distances.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/hwloc.dtd
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/misc.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-aix.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-darwin.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-freebsd.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-hpux.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-libpci.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-linux.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-osf.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris-chiptype.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-synthetic.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-windows.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-x86.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-libxml.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-nolibxml.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_backends.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_custom.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_object_userdata.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-4n4c-cgroup-distance-merge.output
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-8n2c-cpusets_noadmin.output
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16em64t-4s2c2t_merge.output
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/gather/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/test-topology.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/sys/cpuset.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/windows.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/main.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/test-topology.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xmlbuffer.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/Makefile.am
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-assembler.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc.7in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-draw.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-text.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.1in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.c
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/misc.h
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-assembler.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-calc.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distances.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distrib.sh.in
   mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-ls.sh.in
Log:
Update to hwloc-1.6.

No reviewer.

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/HACKING
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/HACKING	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/HACKING	2012-12-10 03:23:44 UTC (rev 10739)
@@ -87,6 +87,8 @@
      http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/
   - MSYS-<date>.zip
      http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/
+  - findutils-<version>-bin.zip
+     http://sourceforge.net/projects/ezwinports/files/
   Unpack all these ZIPs in a path that does not contain spaces,
   to avoid problems later.
 
@@ -100,6 +102,8 @@
   - Visual C++ Express bin and IDE directories
   - The bin directory of the non-cross-compiling MinGW ZIP
     when building a 64bits zipball on a 32bits Windows
+  - The bin directory of the findutils ZIP to find the "find" command
+    (the Windows find command cannot be used)
 - Examples of PATH (depends on where ZIPs were extracted and were Visual Studio was installed):
   - For a 32bits zipball:
     $ PATH=/c/hwloc/mingw32/bin:/c/hwloc/mingw32/i686-w64-mingw32/lib:”/c/Program Files/Microsoft Visual Studio 10.0/VC/bin”:”/c/Program Files/Microsoft Visual Studio 10.0/Common7/IDE”:$PATH

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -9,7 +9,10 @@
 
 SUBDIRS = src include
 if HWLOC_BUILD_STANDALONE
-# SUBDIRS += utils tests doc
+SUBDIRS += utils tests
+# We need doc/ if HWLOC_BUILD_DOXYGEN, or during make install if HWLOC_INSTALL_DOXYGEN.
+# There's no INSTALL_SUBDIRS, so always enter doc/ and check HWLOC_BUILD/INSTALL_DOXYGEN there
+SUBDIRS += doc
 endif
 
 # Do not let automake automatically add the non-standalone dirs to the

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/NEWS
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/NEWS	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/NEWS	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 Copyright © 2009 CNRS
-Copyright © 2009-2012 inria.  All rights reserved.
+Copyright © 2009-2012 Inria.  All rights reserved.
 Copyright © 2009-2012 Université Bordeaux 1
 Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
 
@@ -16,7 +16,77 @@
 0.9 (as initially released as "libtopology", then re-branded to "hwloc"
 in v0.9.1).
 
+Version 1.6.0
+-------------
+* Major changes
+  + Reorganize the backend infrastructure to support dynamic selection
+    of components and dynamic loading of plugins. For details, see the
+    new documentation section Components and plugins.
+    - The HWLOC_COMPONENTS variable lets one replace the default discovery
+      components.
+    - Dynamic loading of plugins may be enabled with --enable-plugins
+      (except on AIX and Windows). It will build libxml2 and libpci
+      support as separated modules. This helps reducing the dependencies
+      of the core hwloc library when distributed as a binary package.
+* Backends
+  + Add CPUModel detection on Darwin and x86/FreeBSD.
+    Thanks to Robin Scher for providing ways to implement this.
+  + The x86 backend now adds CPUModel info attributes to socket objects
+    created by other backends that do not natively support this attribute.
+  + Fix detection on FreeBSD in case of cpuset restriction. Thanks to
+    Sebastian Kuzminsky for reporting the problem.
+* XML
+  + Add hwloc_topology_set_userdata_import/export_callback(),
+    hwloc_export_obj_userdata() and _userdata_base64() to let
+    applications specify how to save/restore the custom data they placed
+    in the userdata private pointer field of hwloc objects.
+* Tools
+  + Add hwloc-annotate program to add string info attributes to XML
+    topologies.
+  + Add --pid-cmd to hwloc-ps to append the output of a command to each
+    PID line. May be used for showing Open MPI process ranks, see the
+    hwloc-ps(1) manpage for details.
+  + hwloc-bind now exits with an error if binding fails; the executable
+    is not launched unless binding suceeeded or --force was given.
+  + Add --quiet to hwloc-calc and hwloc-bind to hide non-fatal error
+    messages.
+  + Fix command-line pid support in windows tools.
+  + All programs accept --verbose as a synonym to -v.
+* Misc
+  + Fix some DIR descriptor leaks on Linux.
+  + Fix I/O device lists when some were filtered out after a XML import.
+  + Fix the removal of I/O objects when importing a I/O-enabled XML topology
+    without any I/O topology flag.
+  + When merging objects with HWLOC_IGNORE_TYPE_KEEP_STRUCTURE or
+    lstopo --merge, compare object types before deciding which one of two
+    identical object to remove (e.g. keep sockets in favor of caches).
+  + Add some GUID- and LID-related info attributes to OpenFabrics
+    OS devices.
+  + Only add CPUType socket attributes on Solaris/Sparc. Other cases
+    don't report reliable information (Solaris/x86), and a replacement
+    is available as the Architecture string info in the Machine object.
+  + Add missing Backend string info on Solaris in most cases.
+  + Document object attributes and string infos in a new Attributes
+    section in the documentation.
+  + Add a section about Synthetic topologies in the documentation.
 
+
+Version 1.5.1
+-------------
+* Fix block OS device detection on Linux kernel 3.3 and later.
+  Thanks to Guy Streeter for reporting the problem and testing the fix.
+* Fix the cpuid code in the x86 backend (for FreeBSD). Thanks to
+  Sebastian Kuzminsky for reporting problems and testing patches.
+* Fix 64bit detection on FreeBSD.
+* Fix some corner cases in the management of the thissystem flag with
+  respect to topology flags and environment variables.
+* Fix some corner cases in command-line parsing checks in hwloc-distrib
+  and hwloc-distances.
+* Make sure we do not miss some block OS devices on old Linux kernels
+  when a single PCI device has multiple IDE hosts/devices behind it.
+* Do not disable I/O devices or instruction caches in hwloc-assembler output.
+
+
 Version 1.5.0
 -------------
 * Backends

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/README
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/README	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/README	2012-12-10 03:23:44 UTC (rev 10739)
@@ -38,7 +38,8 @@
 independant from the processor type (x86, powerpc, ...) and just relies on the
 Operating System support. The only exception to this is kFreeBSD, which does
 not support topology information, and hwloc thus uses an x86-only CPUID-based
-backend (which could be used for other OSes too).
+backend (which can be used for other OSes too, see the Components and plugins
+section).
 
 To check whether hwloc works on a particular machine, just try to build it and
 run lstopo or lstopo-no-graphics. If some things do not look right (e.g. bogus
@@ -66,7 +67,7 @@
 nodes. Several utility programs are also provided to ease command-line
 manipulation of topology objects, binding of processes, and so on.
 
-Perl bindings are available from Bernd Kallies on CPAN:
+Perl bindings are available from Bernd Kallies on CPAN.
 
 Python bindings are available from Guy Streeter:
 
@@ -111,6 +112,10 @@
  exported by the same hwloc release). See Importing and exporting topologies
  from/to XML files for details.
 
+libpci and libxml2 support may be statically built inside the main hwloc
+library, or as separate dynamically-loaded plugins (see the Components and
+plugins section).
+
 CLI Examples
 
 On a 4-socket 2-core machine with hyperthreading, the lstopo tool may show the
@@ -157,55 +162,39 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE topology SYSTEM "hwloc.dtd">
 <topology>
-  <object type="Machine" os_level="-1" os_index="0" cpuset="0x0000ffff"
+  <object type="Machine" os_index="0" cpuset="0x0000ffff"
    complete_cpuset="0x0000ffff" online_cpuset="0x0000ffff"
    allowed_cpuset="0x0000ffff"
    dmi_board_vendor="Dell Computer Corporation" dmi_board_name="0RD318"
    local_memory="16648183808">
  <page_type size="4096" count="4064498"/>
  <page_type size="2097152" count="0"/>
- <object type="Socket" os_level="-1" os_index="0" cpuset="0x00001111"
-     complete_cpuset="0x00001111" online_cpuset="0x00001111"
-     allowed_cpuset="0x00001111">
-   <object type="Cache" os_level="-1" cpuset="0x00001111"
-       complete_cpuset="0x00001111" online_cpuset="0x00001111"
-       allowed_cpuset="0x00001111" cache_size="4194304" depth="3"
-       cache_linesize="64">
-     <object type="Cache" os_level="-1" cpuset="0x00000101"
-         complete_cpuset="0x00000101" online_cpuset="0x00000101"
-         allowed_cpuset="0x00000101" cache_size="1048576" depth="2"
-         cache_linesize="64">
-       <object type="Cache" os_level="-1" cpuset="0x00000101"
-           complete_cpuset="0x00000101" online_cpuset="0x00000101"
-           allowed_cpuset="0x00000101" cache_size="16384" depth="1"
-           cache_linesize="64">
-         <object type="Core" os_level="-1" os_index="0" cpuset="0x00000101"
-             complete_cpuset="0x00000101" online_cpuset="0x00000101"
-             allowed_cpuset="0x00000101">
-           <object type="PU" os_level="-1" os_index="0" cpuset="0x00000001"
+ <object type="Socket" os_index="0" cpuset="0x00001111" ... >
+   <object type="Cache" cpuset="0x00001111" ...
+       cache_size="4194304" depth="3" cache_linesize="64">
+     <object type="Cache" cpuset="0x00000101" ...
+         cache_size="1048576" depth="2" cache_linesize="64">
+       <object type="Cache" cpuset="0x00000101" ...
+           cache_size="16384" depth="1" cache_linesize="64">
+         <object type="Core" os_index="0" ... >
+           <object type="PU" os_index="0" cpuset="0x00000001"
                complete_cpuset="0x00000001" online_cpuset="0x00000001"
                allowed_cpuset="0x00000001"/>
-           <object type="PU" os_level="-1" os_index="8" cpuset="0x00000100"
+           <object type="PU" os_index="8" cpuset="0x00000100"
                complete_cpuset="0x00000100" online_cpuset="0x00000100"
                allowed_cpuset="0x00000100"/>
          </object>
        </object>
      </object>
-     <object type="Cache" os_level="-1" cpuset="0x00001010"
-         complete_cpuset="0x00001010" online_cpuset="0x00001010"
-         allowed_cpuset="0x00001010" cache_size="1048576" depth="2"
-         cache_linesize="64">
-       <object type="Cache" os_level="-1" cpuset="0x00001010"
-           complete_cpuset="0x00001010" online_cpuset="0x00001010"
-           allowed_cpuset="0x00001010" cache_size="16384" depth="1"
-           cache_linesize="64">
-         <object type="Core" os_level="-1" os_index="1" cpuset="0x00001010"
-             complete_cpuset="0x00001010" online_cpuset="0x00001010"
-             allowed_cpuset="0x00001010">
-           <object type="PU" os_level="-1" os_index="4" cpuset="0x00000010"
+     <object type="Cache" cpuset="0x00001010" ...
+         cache_size="1048576" depth="2" cache_linesize="64">
+       <object type="Cache" cpuset="0x00001010"
+           cache_size="16384" depth="1" cache_linesize="64">
+         <object type="Core" os_index="1" cpuset="0x00001010" ... >
+           <object type="PU" os_index="4" cpuset="0x00000010"
                complete_cpuset="0x00000010" online_cpuset="0x00000010"
                allowed_cpuset="0x00000010"/>
-           <object type="PU" os_level="-1" os_index="12" cpuset="0x00001000"
+           <object type="PU" os_index="12" cpuset="0x00001000"
                complete_cpuset="0x00001000" online_cpuset="0x00001000"
                allowed_cpuset="0x00001000"/>
          </object>
@@ -244,40 +233,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE topology SYSTEM "hwloc.dtd">
 <topology>
-  <object type="Machine" os_level="-1" os_index="0" cpuset="0x000000ff"
+  <object type="Machine" os_index="0" cpuset="0x000000ff"
    complete_cpuset="0x000000ff" online_cpuset="0x000000ff"
    allowed_cpuset="0x000000ff" nodeset="0x000000ff"
    complete_nodeset="0x000000ff" allowed_nodeset="0x000000ff"
    dmi_board_vendor="TYAN Computer Corp" dmi_board_name="S4881 ">
  <page_type size="4096" count="0"/>
  <page_type size="2097152" count="0"/>
- <object type="NUMANode" os_level="-1" os_index="0" cpuset="0x00000003"
-     complete_cpuset="0x00000003" online_cpuset="0x00000003"
-     allowed_cpuset="0x00000003" nodeset="0x00000001"
-     complete_nodeset="0x00000001" allowed_nodeset="0x00000001"
-     local_memory="7514177536">
+ <object type="NUMANode" os_index="0" cpuset="0x00000003" ...
+     nodeset="0x00000001" ... local_memory="7514177536">
    <page_type size="4096" count="1834516"/>
    <page_type size="2097152" count="0"/>
-   <object type="Socket" os_level="-1" os_index="0" cpuset="0x00000003"
-       complete_cpuset="0x00000003" online_cpuset="0x00000003"
-       allowed_cpuset="0x00000003" nodeset="0x00000001"
-       complete_nodeset="0x00000001" allowed_nodeset="0x00000001">
-     <object type="Cache" os_level="-1" cpuset="0x00000001"
-         complete_cpuset="0x00000001" online_cpuset="0x00000001"
-         allowed_cpuset="0x00000001" nodeset="0x00000001"
-         complete_nodeset="0x00000001" allowed_nodeset="0x00000001"
+   <object type="Socket" os_index="0" cpuset="0x00000003" ... >
+     <object type="Cache" cpuset="0x00000001" ...
          cache_size="1048576" depth="2" cache_linesize="64">
-       <object type="Cache" os_level="-1" cpuset="0x00000001"
-           complete_cpuset="0x00000001" online_cpuset="0x00000001"
-           allowed_cpuset="0x00000001" nodeset="0x00000001"
-           complete_nodeset="0x00000001" allowed_nodeset="0x00000001"
+       <object type="Cache" cpuset="0x00000001" ...
            cache_size="65536" depth="1" cache_linesize="64">
-         <object type="Core" os_level="-1" os_index="0"
-             cpuset="0x00000001" complete_cpuset="0x00000001"
-             online_cpuset="0x00000001" allowed_cpuset="0x00000001"
-             nodeset="0x00000001" complete_nodeset="0x00000001"
-             allowed_nodeset="0x00000001">
-           <object type="PU" os_level="-1" os_index="0" cpuset="0x00000001"
+         <object type="Core" os_index="0" ... >
+           <object type="PU" os_index="0" cpuset="0x00000001"
                complete_cpuset="0x00000001" online_cpuset="0x00000001"
                allowed_cpuset="0x00000001" nodeset="0x00000001"
                complete_nodeset="0x00000001" allowed_nodeset="0x00000001"/>
@@ -315,39 +288,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE topology SYSTEM "hwloc.dtd">
 <topology>
-  <object type="Machine" os_level="-1" os_index="0" cpuset="0x000000ff"
+  <object type="Machine" os_index="0" cpuset="0x000000ff"
    complete_cpuset="0x000000ff" online_cpuset="0x000000ff"
    allowed_cpuset="0x000000ff" dmi_board_vendor="Dell Inc."
    dmi_board_name="0NR282" local_memory="16865292288">
  <page_type size="4096" count="4117503"/>
  <page_type size="2097152" count="0"/>
- <object type="Socket" os_level="-1" os_index="0" cpuset="0x00000055"
-     complete_cpuset="0x00000055" online_cpuset="0x00000055"
-     allowed_cpuset="0x00000055">
-   <object type="Cache" os_level="-1" cpuset="0x00000011"
-       complete_cpuset="0x00000011" online_cpuset="0x00000011"
-       allowed_cpuset="0x00000011" cache_size="4194304" depth="2"
-       cache_linesize="64">
-     <object type="Cache" os_level="-1" cpuset="0x00000001"
-         complete_cpuset="0x00000001" online_cpuset="0x00000001"
-         allowed_cpuset="0x00000001" cache_size="32768" depth="1"
-         cache_linesize="64">
-       <object type="Core" os_level="-1" os_index="0" cpuset="0x00000001"
-           complete_cpuset="0x00000001" online_cpuset="0x00000001"
-           allowed_cpuset="0x00000001">
-         <object type="PU" os_level="-1" os_index="0" cpuset="0x00000001"
+ <object type="Socket" os_index="0" cpuset="0x00000055" ... >
+   <object type="Cache" cpuset="0x00000011" ...
+       cache_size="4194304" depth="2" cache_linesize="64">
+     <object type="Cache" cpuset="0x00000001" ...
+         cache_size="32768" depth="1" cache_linesize="64">
+       <object type="Core" os_index="0" ... >
+         <object type="PU" os_index="0" cpuset="0x00000001"
              complete_cpuset="0x00000001" online_cpuset="0x00000001"
              allowed_cpuset="0x00000001"/>
        </object>
      </object>
-     <object type="Cache" os_level="-1" cpuset="0x00000010"
-         complete_cpuset="0x00000010" online_cpuset="0x00000010"
-         allowed_cpuset="0x00000010" cache_size="32768" depth="1"
-         cache_linesize="64">
-       <object type="Core" os_level="-1" os_index="1" cpuset="0x00000010"
-           complete_cpuset="0x00000010" online_cpuset="0x00000010"
-           allowed_cpuset="0x00000010">
-         <object type="PU" os_level="-1" os_index="4" cpuset="0x00000010"
+     <object type="Cache" cpuset="0x00000010" ...
+         cache_size="32768" depth="1" cache_linesize="64">
+       <object type="Core" os_index="1" ... >
+         <object type="PU" os_index="4" cpuset="0x00000010" ...
              complete_cpuset="0x00000010" online_cpuset="0x00000010"
              allowed_cpuset="0x00000010"/>
        </object>
@@ -708,9 +669,11 @@
   * CPU and Memory Binding Overview
   * I/O Devices
   * Multi-node Topologies
+  * Object attributes
   * Importing and exporting topologies from/to XML files
   * Interoperability With Other Software
   * Thread Safety
+  * Components and plugins
   * Embedding hwloc in Other Software
   * Frequently Asked Questions
 
@@ -718,5 +681,5 @@
 
 -------------------------------------------------------------------------------
 
-Generated on Wed Jul 18 2012 10:50:44 for Hardware Locality (hwloc) by   
+Generated on Mon Nov 12 2012 03:13:56 for Hardware Locality (hwloc) by   
 doxygen 1.8.1.2

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/VERSION
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/VERSION	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/VERSION	2012-12-10 03:23:44 UTC (rev 10739)
@@ -6,7 +6,7 @@
 # <major>.<minor>.<release>.  If release is zero, then it is omitted.
 
 major=1
-minor=5
+minor=6
 release=0
 
 # greek is used for alpha or beta release tags.  If it is non-empty,
@@ -58,4 +58,4 @@
 # 2. Version numbers are described in the Libtool current:revision:age
 # format.
 
-libhwloc_so_version=6:0:1
+libhwloc_so_version=7:0:2

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/autogen.sh
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/autogen.sh	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/autogen.sh	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,2 +1,2 @@
 :
-autoreconf ${autoreconf_args:-"-vif"}
+autoreconf -ivf

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc.m4
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc.m4	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc.m4	2012-12-10 03:23:44 UTC (rev 10739)
@@ -162,6 +162,12 @@
     AC_CHECK_SIZEOF([void *])
 
     #
+    # List of components to be built, either statically or dynamically.
+    # To be enlarged below.
+    #
+    hwloc_components="noos xml synthetic custom xml_nolibxml"
+
+    #
     # Check OS support
     #
     AC_MSG_CHECKING([which OS support to include])
@@ -170,46 +176,55 @@
         AC_DEFINE(HWLOC_LINUX_SYS, 1, [Define to 1 on Linux])
         hwloc_linux=yes
         AC_MSG_RESULT([Linux])
+        hwloc_components="$hwloc_components linux"
         ;;
       *-*-irix*)
         AC_DEFINE(HWLOC_IRIX_SYS, 1, [Define to 1 on Irix])
         hwloc_irix=yes
         AC_MSG_RESULT([IRIX])
+        # no irix component yet
         ;;
       *-*-darwin*)
         AC_DEFINE(HWLOC_DARWIN_SYS, 1, [Define to 1 on Darwin])
         hwloc_darwin=yes
         AC_MSG_RESULT([Darwin])
+        hwloc_components="$hwloc_components darwin"
         ;;
       *-*-solaris*)
         AC_DEFINE(HWLOC_SOLARIS_SYS, 1, [Define to 1 on Solaris])
         hwloc_solaris=yes
         AC_MSG_RESULT([Solaris])
+        hwloc_components="$hwloc_components solaris"
         ;;
       *-*-aix*)
         AC_DEFINE(HWLOC_AIX_SYS, 1, [Define to 1 on AIX])
         hwloc_aix=yes
         AC_MSG_RESULT([AIX])
+        hwloc_components="$hwloc_components aix"
         ;;
       *-*-osf*)
         AC_DEFINE(HWLOC_OSF_SYS, 1, [Define to 1 on OSF])
         hwloc_osf=yes
         AC_MSG_RESULT([OSF])
+        hwloc_components="$hwloc_components osf"
         ;;
       *-*-hpux*)
         AC_DEFINE(HWLOC_HPUX_SYS, 1, [Define to 1 on HP-UX])
         hwloc_hpux=yes
         AC_MSG_RESULT([HP-UX])
+        hwloc_components="$hwloc_components hpux"
         ;;
       *-*-mingw*|*-*-cygwin*)
         AC_DEFINE(HWLOC_WIN_SYS, 1, [Define to 1 on WINDOWS])
         hwloc_windows=yes
         AC_MSG_RESULT([Windows])
+        hwloc_components="$hwloc_components windows"
         ;;
       *-*-*freebsd*)
         AC_DEFINE(HWLOC_FREEBSD_SYS, 1, [Define to 1 on *FREEBSD])
         hwloc_freebsd=yes
         AC_MSG_RESULT([FreeBSD])
+        hwloc_components="$hwloc_components freebsd"
         ;;
       *)
         AC_MSG_RESULT([Unsupported! ($target)])
@@ -230,7 +245,7 @@
     #
     AC_MSG_CHECKING([which CPU support to include])
     case ${target} in
-      i*86-*-*|x86_64-*-*)
+      i*86-*-*|x86_64-*-*|amd64-*-*)
         case ${ac_cv_sizeof_void_p} in
           4)
             AC_DEFINE(HWLOC_X86_32_ARCH, 1, [Define to 1 on x86_32])
@@ -388,6 +403,8 @@
     		_SC_NPROCESSORS_CONF,
     		_SC_NPROC_ONLN,
     		_SC_NPROC_CONF,
+    		_SC_PAGESIZE,
+    		_SC_PAGE_SIZE,
     		_SC_LARGE_PAGESIZE],,[:],[[#include <unistd.h>]])
     
     AC_HAVE_HEADERS([mach/mach_host.h])
@@ -556,16 +573,6 @@
     AC_CHECK_HEADERS([malloc.h])
     AC_CHECK_FUNCS([getpagesize memalign posix_memalign])
 
-    # when autoheader is run, it doesn't know about
-    # PAC_FUNC_NEEDS_DECL, so it doesn't generate an appropriate line
-    # in config.h.in.  We need to fool it with a dummy AC_DEFINE().
-    if false ; then
-        AC_DEFINE([NEEDS_GETPAGESIZE_DECL], 1, [Define to 1 if getpagesize needs a declaration])
-    fi
-    if test $ac_cv_func_getpagesize = "yes" ; then
-       PAC_FUNC_NEEDS_DECL([#include <unistd.h>],getpagesize)
-    fi
-
     AC_CHECK_HEADERS([sys/utsname.h])
     AC_CHECK_FUNCS([uname])
 
@@ -588,6 +595,7 @@
     AC_SEARCH_LIBS([pthread_getthrds_np], [pthread],
       AC_DEFINE([HWLOC_HAVE_PTHREAD_GETTHRDS_NP], 1, `Define to 1 if you have pthread_getthrds_np')
     )
+    AC_CHECK_FUNCS([cpuset_setid])
 
     # Linux libnuma support
     hwloc_linux_libnuma_happy=no
@@ -668,7 +676,6 @@
         ])
     fi
     AC_SUBST(HWLOC_PCI_LIBS)
-    HWLOC_LIBS="$HWLOC_LIBS $HWLOC_PCI_LIBS"
     # If we asked for pci support but couldn't deliver, fail
     AS_IF([test "$enable_pci" = "yes" -a "$hwloc_pci_happy" = "no"],
           [AC_MSG_WARN([Specified --enable-pci switch, but could not])
@@ -704,15 +711,18 @@
         AC_DEFINE([HWLOC_HAVE_PCIDEV_DOMAIN], [1], [Define to 1 if struct pci_dev has a `domain' field.])
       fi
 
-      HWLOC_REQUIRES="libpci $HWLOC_REQUIRES"
+      HWLOC_PCI_REQUIRES=libpci
       AC_DEFINE([HWLOC_HAVE_LIBPCI], [1], [Define to 1 if you have the `libpci' library.])
       AC_SUBST([HWLOC_HAVE_LIBPCI], [1])
       CFLAGS="$tmp_save_CFLAGS"
       LIBS="$tmp_save_LIBS"
+
+      hwloc_components="$hwloc_components libpci"
+      hwloc_libpci_component_maybeplugin=1
     else
       AC_SUBST([HWLOC_HAVE_LIBPCI], [0])
     fi
-    HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_PCI_CFLAGS"
+    # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
 
     # libxml2 support
     hwloc_libxml2_happy=
@@ -722,19 +732,125 @@
                                 [hwloc_libxml2_happy=no])
     fi
     if test "x$hwloc_libxml2_happy" = "xyes"; then
-        HWLOC_REQUIRES="libxml-2.0 $HWLOC_REQUIRES"
+        HWLOC_LIBXML2_REQUIRES="libxml-2.0"
         AC_DEFINE([HWLOC_HAVE_LIBXML2], [1], [Define to 1 if you have the `libxml2' library.])
         AC_SUBST([HWLOC_HAVE_LIBXML2], [1])
+
+        hwloc_components="$hwloc_components xml_libxml"
+        hwloc_xml_libxml_component_maybeplugin=1
     else
         AC_SUBST([HWLOC_HAVE_LIBXML2], [0])
 	AS_IF([test "$enable_libxml2" = "yes"],
               [AC_MSG_WARN([--enable-libxml2 requested, but libxml2 was not found])
                AC_MSG_ERROR([Cannot continue])])
     fi
-    HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_LIBXML2_CFLAGS"    
-    HWLOC_LIBS="$HWLOC_LIBS $HWLOC_LIBXML2_LIBS"
+    # don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
 
+    # Try to compile the cpuid inlines
+    AC_MSG_CHECKING([for cpuid])
+    old_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -I$HWLOC_top_srcdir/include"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+        #include <stdio.h>
+        #define __hwloc_inline
+        #include <private/cpuid.h>
+      ]], [[
+        if (hwloc_have_cpuid()) {
+          unsigned eax = 0, ebx, ecx = 0, edx;
+          hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+          printf("highest cpuid %x\n", eax);
+          return 0;
+        }
+      ]])],
+      [AC_MSG_RESULT([yes])
+       AC_DEFINE(HWLOC_HAVE_CPUID, 1, [Define to 1 if you have cpuid])
+       hwloc_have_cpuid=yes],
+      [AC_MSG_RESULT([no])])
+    if test "x$hwloc_have_cpuid" = xyes; then
+      hwloc_components="$hwloc_components x86"
+    fi
+    CPPFLAGS="$old_CPPFLAGS"
+
+    # Components require pthread_mutex, see if it needs -lpthread
+    hwloc_pthread_mutex_happy=no
+    # Try without explicit -lpthread first
+    AC_CHECK_FUNC([pthread_mutex_lock],
+      [hwloc_pthread_mutex_happy=yes
+      ],
+      [AC_MSG_CHECKING([fot pthread_mutex_lock with -lpthread])
+       # Try again with explicit -lpthread, but don't use AC_CHECK_FUNC to avoid the cache
+       tmp_save_LIBS=$LIBS
+       LIBS="$LIBS -lpthread"
+       AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_mutex_lock])],
+         [hwloc_pthread_mutex_happy=yes
+          HWLOC_LIBS="$HWLOC_LIBS -lpthread"
+	  HWLOC_REQUIRES="$HWLOC_REQUIRES libpthread"
+         ])
+       AC_MSG_RESULT([$hwloc_pthread_mutex_happy])
+       LIBS="$tmp_save_LIBS"
+      ])
+    AS_IF([test "x$hwloc_pthread_mutex_happy" = "xyes"],
+      [AC_DEFINE([HWLOC_HAVE_PTHREAD_MUTEX], 1, [Define to 1 if pthread mutexes are available])])
+
+    AS_IF([test "x$hwloc_pthread_mutex_happy" != xyes -a "x$hwloc_windows" != xyes],
+      [AC_MSG_WARN([pthread_mutex_lock not available, required for thread-safe initialization on non-Windows platforms.])
+       AC_MSG_WARN([Please report this to the hwloc-devel mailing list.])
+       AC_MSG_ERROR([Cannot continue])])
+
+    #
+    # Now enable registration of listed components
+    #
+
+    # Plugin support
+    AC_MSG_CHECKING([if plugin support is enabled])
+    # Plugins (even core support) are totally disabled by default
+    AS_IF([test "x$enable_plugins" = "x"], [enable_plugins=no])
+    # libltdl doesn't work on AIX as of 2.4.2
+    AS_IF([test "x$enable_plugins" = "xyes" -a "x$hwloc_aix" = "xyes"],
+      [AC_MSG_WARN([libltdl does not work on AIX, plugins support cannot be enabled.])
+       AC_MSG_ERROR([Cannot continue])])
+    # posix linkers don't work well with plugins and windows dll constraints
+    AS_IF([test "x$enable_plugins" = "xyes" -a "x$hwloc_windows" = "xyes"],
+      [AC_MSG_WARN([Plugins not supported on non-native Windows build, plugins support cannot be enabled.])
+       AC_MSG_ERROR([Cannot continue])])
+
+    AS_IF([test "x$enable_plugins" != "xno"], [hwloc_have_plugins=yes], [hwloc_have_plugins=no])
+    AC_MSG_RESULT([$hwloc_have_plugins])
+    AS_IF([test "x$hwloc_have_plugins" = "xyes"],
+          [AC_DEFINE([HWLOC_HAVE_PLUGINS], 1, [Define to 1 if the hwloc library should support dynamically-loaded plugins])])
+
+    # Static components output file
+    hwloc_static_components_dir=${HWLOC_top_builddir}/src
+    mkdir -p ${hwloc_static_components_dir}
+    hwloc_static_components_file=${hwloc_static_components_dir}/static-components.h
+    rm -f ${hwloc_static_components_file}
+
+    # Make $enable_plugins easier to use (it contains either "yes" (all) or a list of <name>)
+    HWLOC_PREPARE_FILTER_COMPONENTS([$enable_plugins])
+    # Now we have some hwloc_<name>_component_wantplugin=1
+
+    # See which core components want plugin and support it
+    HWLOC_FILTER_COMPONENTS
+    # Now we have some hwloc_<name>_component=plugin/static
+    # and hwloc_static/plugin_components
+    AC_MSG_CHECKING([components to build statically])
+    AC_MSG_RESULT($hwloc_static_components)
+    HWLOC_LIST_STATIC_COMPONENTS([$hwloc_static_components_file], [$hwloc_static_components])
+    AC_MSG_CHECKING([components to build as plugins])
+    AC_MSG_RESULT([$hwloc_plugin_components])
+
+    AS_IF([test "$hwloc_libpci_component" = "static"],
+          [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_PCI_LIBS"
+           HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_PCI_CFLAGS"
+           HWLOC_REQUIRES="$HWLOC_PCI_REQUIRES $HWLOC_REQUIRES"])
+    AS_IF([test "$hwloc_xml_libxml_component" = "static"],
+          [HWLOC_LIBS="$HWLOC_LIBS $HWLOC_LIBXML2_LIBS"
+           HWLOC_CFLAGS="$HWLOC_CFLAGS $HWLOC_LIBXML2_CFLAGS"
+           HWLOC_REQUIRES="$HWLOC_LIBXML2_REQUIRES $HWLOC_REQUIRES"])
+
+    #
     # Setup HWLOC's C, CPP, and LD flags, and LIBS
+    #
     AC_SUBST(HWLOC_REQUIRES)
     AC_SUBST(HWLOC_CFLAGS)
     HWLOC_CPPFLAGS='-I$(HWLOC_top_builddir)/include -I$(HWLOC_top_srcdir)/include'
@@ -762,28 +878,6 @@
     AC_SUBST(HWLOC_EMBEDDED_LDADD)
     AC_SUBST(HWLOC_EMBEDDED_LIBS)
 
-    # Try to compile the cpuid inlines
-    AC_MSG_CHECKING([for cpuid])
-    old_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -I$HWLOC_top_srcdir/include"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-        #include <stdio.h>
-        #define __hwloc_inline
-        #include <private/cpuid.h>
-      ]], [[
-        if (hwloc_have_cpuid()) {
-          unsigned eax = 0, ebx, ecx = 0, edx;
-          hwloc_cpuid(&eax, &ebx, &ecx, &edx);
-          printf("highest cpuid %x\n", eax);
-          return 0;
-        }
-      ]])],
-      [AC_MSG_RESULT([yes])
-       AC_DEFINE(HWLOC_HAVE_CPUID, 1, [Define to 1 if you have cpuid])
-       hwloc_have_cpuid=yes],
-      [AC_MSG_RESULT([no])])
-    CPPFLAGS="$old_CPPFLAGS"
-
     # Always generate these files
     AC_CONFIG_FILES(
         hwloc_config_prefix[Makefile]
@@ -858,8 +952,12 @@
         AM_CONDITIONAL([HWLOC_HAVE_X86_32], [test "x$hwloc_x86_32" = "xyes"])
         AM_CONDITIONAL([HWLOC_HAVE_X86_64], [test "x$hwloc_x86_64" = "xyes"])
         AM_CONDITIONAL([HWLOC_HAVE_CPUID], [test "x$hwloc_have_cpuid" = "xyes"])
-        AM_CONDITIONAL([HWLOC_BUILD_UTILS], [test "$hwloc_build_utils" = "yes"])
-        AM_CONDITIONAL([HWLOC_BUILD_TESTS], [test "$hwloc_build_tests" = "yes"])
+
+        AM_CONDITIONAL([HWLOC_HAVE_PLUGINS], [test "x$hwloc_have_plugins" = "xyes"])
+        AM_CONDITIONAL([HWLOC_LIBPCI_BUILD_STATIC], [test "x$hwloc_libpci_component" = "xstatic"])
+        AM_CONDITIONAL([HWLOC_XML_LIBXML_BUILD_STATIC], [test "x$hwloc_xml_libxml_component" = "xstatic"])
+
+        AM_CONDITIONAL([HWLOC_HAVE_CXX], [test "x$hwloc_have_cxx" = "xyes"])
     ])
     hwloc_did_am_conditionals=yes
 ])dnl

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_components.m4
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_components.m4	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_components.m4	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,63 @@
+# Copyright © 2012 Inria.  All rights reserved.
+# See COPYING in top-level directory.
+
+
+# HWLOC_PREPARE_FILTER_COMPONENTS
+#
+# Given a comma-separated list of names, define hwloc_<name>_component_maybeplugin=1.
+#
+# $1 = command-line given list of components to build as plugins
+#
+AC_DEFUN([HWLOC_PREPARE_FILTER_COMPONENTS], [
+  for name in `echo [$1] | sed -e 's/,/ /g'` ; do
+    str="hwloc_${name}_component_wantplugin=1"
+    eval $str
+  done
+])
+
+
+# HWLOC_FILTER_COMPONENTS
+#
+# For each component in hwloc_components,
+# check if hwloc_<name>_component_wantplugin=1 or enable_plugin=yes,
+# and check if hwloc_<name>_component_maybeplugin=1.
+# Add <name> to hwloc_[static|plugin]_components accordingly.
+# And set hwloc_<name>_component=[static|plugin] accordingly.
+#
+AC_DEFUN([HWLOC_FILTER_COMPONENTS], [
+for name in $hwloc_components ; do
+  str="maybeplugin=\$hwloc_${name}_component_maybeplugin"
+  eval $str
+  str="wantplugin=\$hwloc_${name}_component_wantplugin"
+  eval $str
+  if test x$hwloc_have_plugins = xyes && test x$maybeplugin = x1 && test x$wantplugin = x1 -o x$enable_plugins = xyes; then
+    hwloc_plugin_components="$hwloc_plugin_components $name"
+    str="hwloc_${name}_component=plugin"
+  else
+    hwloc_static_components="$hwloc_static_components $name"
+    str="hwloc_${name}_component=static"
+  fi
+  eval $str
+done
+])
+
+
+# HWLOC_LIST_STATIC_COMPONENTS
+#
+# Append to file $1 an array of components by listing component names in $2.
+#
+# $1 = filename
+# $2 = list of component names
+#
+AC_DEFUN([HWLOC_LIST_STATIC_COMPONENTS], [
+cat <<EOF >>[$1]
+static const struct hwloc_component * hwloc_static_components[[]] = {
+EOF
+for comp in [$2]; do
+  echo "  &hwloc_${comp}_component," >>[$1]
+done
+cat <<EOF >>[$1]
+  NULL
+};
+EOF
+])

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_internal.m4
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_internal.m4	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/config/hwloc_internal.m4	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 dnl -*- Autoconf -*-
 dnl
-dnl Copyright (c) 2009 inria.  All rights reserved.
+dnl Copyright (c) 2009-2012 Inria.  All rights reserved.
 dnl Copyright (c) 2009, 2011 Université Bordeaux 1
 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 dnl                         University Research and Technology
@@ -70,6 +70,11 @@
                   AS_HELP_STRING([--disable-libnuma],
                                  [Disable the Linux libnuma]))
 
+    # Plugins
+    AC_ARG_ENABLE([plugins],
+                  AS_HELP_STRING([--enable-plugins=name,...],
+                                 [Build the given components as dynamically-loaded plugins]))
+
 ])dnl
 
 #-----------------------------------------------------------------------
@@ -201,7 +206,7 @@
         add="$add -Wmissing-prototypes -Wstrict-prototypes"
         add="$add -Wcomment -pedantic"
 
-        CFLAGS="$CFLAGS $add"
+        HWLOC_CFLAGS="$HWLOC_CFLAGS $add"
     fi
 
     # Generate some files for the docs
@@ -221,8 +226,6 @@
 ###
 EOF
 
-    hwloc_build_utils=yes
-
     # Cairo support
     hwloc_cairo_happy=no
     if test "x$enable_cairo" != "xno"; then
@@ -328,8 +331,6 @@
 ###
 EOF
 
-    hwloc_build_tests=yes
-
     AC_CHECK_LIB([pthread], [pthread_self], [hwloc_have_pthread=yes])
 
     # linux-libnuma.h testing requires libnuma with numa_bitmask_alloc()
@@ -386,6 +387,19 @@
 
     AC_CHECK_PROGS(BUNZIPP, bunzip2, false)
 
+    AC_MSG_CHECKING(if CXX works)
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <iostream>
+using namespace std;
+int foo(void) {
+  cout << "test" << endl;
+  return 0;
+}
+	]])], [hwloc_have_cxx=yes], [hwloc_have_cxx=no])
+    AC_LANG_POP([C++])
+    AC_MSG_RESULT([$hwloc_have_cxx])
+
     _HWLOC_CHECK_DIFF_U
 
     # Only generate these files if we're making the tests
@@ -400,14 +414,17 @@
         hwloc_config_prefix[tests/linux/gather/test-gather-topology.sh]
         hwloc_config_prefix[tests/linux/test-topology.sh]
         hwloc_config_prefix[tests/xml/test-topology.sh]
+        hwloc_config_prefix[tests/wrapper.sh]
         hwloc_config_prefix[utils/hwloc-assembler-remote]
+        hwloc_config_prefix[utils/test-hwloc-annotate.sh]
         hwloc_config_prefix[utils/test-hwloc-assembler.sh]
         hwloc_config_prefix[utils/test-hwloc-calc.sh]
         hwloc_config_prefix[utils/test-hwloc-distances.sh]
         hwloc_config_prefix[utils/test-hwloc-distrib.sh]
-        hwloc_config_prefix[utils/test-hwloc-ls.sh])
+        hwloc_config_prefix[utils/test-hwloc-ls.sh]
+        hwloc_config_prefix[utils/test-fake-plugin.sh])
 
-    AC_CONFIG_COMMANDS([chmoding-scripts], [chmod +x ]hwloc_config_prefix[tests/linux/test-topology.sh ]hwloc_config_prefix[tests/xml/test-topology.sh ]hwloc_config_prefix[tests/linux/hwloc-gather-topology ]hwloc_config_prefix[tests/linux/gather/test-gather-topology.sh ]hwloc_config_prefix[utils/hwloc-assembler-remote ]hwloc_config_prefix[utils/test-hwloc-assembler.sh ]hwloc_config_prefix[utils/test-hwloc-calc.sh ]hwloc_config_prefix[utils/test-hwloc-distances.sh ]hwloc_config_prefix[utils/test-hwloc-distrib.sh ]hwloc_config_prefix[utils/test-hwloc-ls.sh])
+    AC_CONFIG_COMMANDS([chmoding-scripts], [chmod +x ]hwloc_config_prefix[tests/linux/test-topology.sh ]hwloc_config_prefix[tests/xml/test-topology.sh ]hwloc_config_prefix[tests/linux/hwloc-gather-topology ]hwloc_config_prefix[tests/linux/gather/test-gather-topology.sh ]hwloc_config_prefix[tests/wrapper.sh ]hwloc_config_prefix[utils/hwloc-assembler-remote ]hwloc_config_prefix[utils/test-hwloc-annotate.sh ]hwloc_config_prefix[utils/test-hwloc-assembler.sh ]hwloc_config_prefix[utils/test-hwloc-calc.sh ]hwloc_config_prefix[utils/test-hwloc-distances.sh ]hwloc_config_prefix[utils/test-hwloc-distrib.sh ]hwloc_config_prefix[utils/test-hwloc-ls.sh ]hwloc_config_prefix[utils/test-fake-plugin.sh])
 
     # These links are only needed in standalone mode.  It would
     # be nice to m4 foreach this somehow, but whenever I tried

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/configure.ac
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/configure.ac	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/configure.ac	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 # -*- shell-script -*-
 #
 # Copyright © 2009      CNRS
-# Copyright © 2009-2010 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009, 2011-2012      Université Bordeaux 1
 # Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 #
@@ -147,6 +147,13 @@
        HWLOC_SETUP_UTILS
        HWLOC_SETUP_TESTS])
 
+cat <<EOF
+
+###
+### Performing final hwloc configuration
+###
+EOF
+
 # Run the AM_CONDITIONALs
 HWLOC_DO_AM_CONDITIONALS
 
@@ -159,23 +166,16 @@
 # Compiler support -- we don't need that stuff.
 AM_ENABLE_SHARED
 AM_DISABLE_STATIC
-AM_PROG_LIBTOOL([win32-dll])
+AM_PROG_LIBTOOL([dlopen win32-dll])
 LT_LANG([C])
+LT_CONFIG_LTDL_DIR([src/libltdl])
+LTDL_INIT([recursive convenience])
+AC_CONFIG_FILES([src/libltdl/Makefile])
 
-## Enable creation of libtool-style versioning or no versioning
-AC_ARG_ENABLE(versioning,
-        [AC_HELP_STRING([--enable-versioning],[Enable library versioning])],,
-        [enable_versioning=yes])
+# Workarounds for libtool LT_CONFIG_H bug
+#CPPFLAGS="$CPPFLAGS -I$HWLOC_top_builddir"
+AC_CONFIG_COMMANDS_PRE([LT_CONFIG_H=`expr "$LT_CONFIG_H" : '.*/\(.*\)'`])
 
-if test "$enable_versioning" = "yes" ; then
-   libhwloc_so_versionflags="-version-info \$(libhwloc_so_version)"
-else
-   libhwloc_so_versionflags="-avoid-version"
-fi
-export libhwloc_so_versionflags
-AC_SUBST(libhwloc_so_versionflags)
-
-
 # Party on
 AC_OUTPUT
 
@@ -207,6 +207,7 @@
 Probe / display PCI devices: $hwloc_pci_happy
 Graphical output (Cairo):    $hwloc_cairo_happy
 XML input / output:          $hwloc_xml_status
+Plugin support:              $hwloc_have_plugins
 EOF
 
 # Linux specific support

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/dist/make_dist_tarball
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/dist/make_dist_tarball	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/dist/make_dist_tarball	2012-12-10 03:23:44 UTC (rev 10739)
@@ -11,6 +11,7 @@
 # Copyright (c) 2004-2005 The Regents of the University of California.
 #                         All rights reserved.
 # Copyright © 2008-2010  Cisco Systems, Inc.  All rights reserved.
+# Copyright © 2012 Inria.  All rights reserved.
 # $COPYRIGHT$
 # 
 # Additional copyrights may follow
@@ -22,7 +23,7 @@
 # Version of auto tools that we want
 #
 
-AM_TARGET_VERSION=1.12.2
+AM_TARGET_VERSION=1.12.4
 AC_TARGET_VERSION=2.69
 LT_TARGET_VERSION=2.4.2
 
@@ -93,7 +94,7 @@
     cd doc
     rm -rf doxygen-doc
     rm -f success
-    (make doc 2>&1 && touch success) | tee config.out
+    (make doc 2>&1 && touch success) | tee doc.out
     if test ! -f success; then 
         echo "Making doxygen docs failed.  Aborting"
         exit 1
@@ -105,11 +106,12 @@
     echo "*** Making README..."
     rm -rf ../README
     rm -f success
-    (make readme 2>&1 && touch success) | tee config.out
+    (make readme 2>&1 && touch success) | tee readme.out
     if test ! -f success; then 
         echo "Making README failed.  Aborting"
         exit 1
     fi
+    rm -f success
     cd ..
 
     #

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/hwloc-valgrind.supp
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/hwloc-valgrind.supp	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/contrib/hwloc-valgrind.supp	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,4 +1,4 @@
-# Copyright © 2012      inria.  All rights reserved.
+# Copyright © 2012      Inria.  All rights reserved.
 # See COPYING in top-level directory.
 
 # suppressions file to be passed to valgrind with
@@ -29,3 +29,28 @@
    ...
    fun:xmlDictCreate
 }
+
+# ltdl dlopen global state?
+{
+   ltdl_dlopen_malloc
+   Memcheck:Leak
+   fun:malloc
+   fun:_dl_map_object_deps
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+}
+
+# lt_dlforeachfile abusing paths
+{
+   fun:lt_dlforeachfile_path
+   Memcheck:Addr8
+   fun:_wordcopy_fwd_dest_aligned
+   fun:__GI_memmove
+   fun:argz_insert
+   ...
+   fun:lt_dlforeachfile
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,4 +1,4 @@
-# Copyright © 2009-2012 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009-2012 Université Bordeaux 1
 # Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 # See COPYING in top-level directory.
@@ -236,6 +236,9 @@
 # in _DATA suffix names, because AM won't allow us to do things like
 # man3_extra_MANS = ...group...
 
+# When adding a new _DATA line below, remember to add it to the
+# list of dependencies too.
+
 man3_MANS = \
         $(DOX_MAN_DIR)/man3/hwlocality_api_version.3 \
         $(DOX_MAN_DIR)/man3/HWLOC_API_VERSION.3 \
@@ -344,12 +347,20 @@
         $(DOX_MAN_DIR)/man3/hwloc_topology_support.3 \
         $(DOX_MAN_DIR)/man3/hwloc_topology_get_support.3
 
+man3_xmlexportdir = $(man3dir)
+man3_xmlexport_DATA = \
+        $(DOX_MAN_DIR)/man3/hwlocality_xmlexport.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_topology_export_xml.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_topology_export_xmlbuffer.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_free_xmlbuffer.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_topology_set_userdata_export_callback.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_export_obj_userdata.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_export_obj_userdata_base64.3 \
+        $(DOX_MAN_DIR)/man3/hwloc_topology_set_userdata_import_callback.3
+
 man3_tinkerdir = $(man3dir)
 man3_tinker_DATA = \
         $(DOX_MAN_DIR)/man3/hwlocality_tinker.3 \
-        $(DOX_MAN_DIR)/man3/hwloc_topology_export_xml.3 \
-        $(DOX_MAN_DIR)/man3/hwloc_topology_export_xmlbuffer.3 \
-        $(DOX_MAN_DIR)/man3/hwloc_free_xmlbuffer.3 \
         $(DOX_MAN_DIR)/man3/hwloc_topology_insert_misc_object_by_cpuset.3 \
         $(DOX_MAN_DIR)/man3/hwloc_topology_insert_misc_object_by_parent.3 \
         $(DOX_MAN_DIR)/man3/HWLOC_RESTRICT_FLAG_ADAPT_DISTANCES.3 \
@@ -670,6 +681,8 @@
 # *first* before we can try to process/install man pages, the HTML,
 # run pdflatex, .etc.).
 
+# The list below should match the list of _DATA lines above
+
 $(man3_MANS): $(DOX_TAG)
 $(man3_topology_DATA): $(DOX_TAG)
 $(man3_sets_DATA): $(DOX_TAG)
@@ -677,6 +690,7 @@
 $(man3_objects_DATA): $(DOX_TAG)
 $(man3_creation_DATA): $(DOX_TAG)
 $(man3_configuration_DATA): $(DOX_TAG)
+$(man3_xmlexport_DATA): $(DOX_TAG)
 $(man3_tinker_DATA): $(DOX_TAG)
 $(man3_information_DATA): $(DOX_TAG)
 $(man3_traversal_DATA): $(DOX_TAG)
@@ -688,8 +702,8 @@
 $(man3_helper_types_DATA): $(DOX_TAG)
 $(man3_helper_traversal_basic_DATA): $(DOX_TAG)
 $(man3_helper_find_inside_DATA): $(DOX_TAG)
+$(man3_helper_find_covering_DATA): $(DOX_TAG)
 $(man3_helper_find_coverings_DATA): $(DOX_TAG)
-$(man3_helper_find_covering_DATA): $(DOX_TAG)
 $(man3_helper_find_cache_DATA): $(DOX_TAG)
 $(man3_helper_traversal_DATA): $(DOX_TAG)
 $(man3_helper_binding_DATA): $(DOX_TAG)
@@ -720,10 +734,12 @@
 # Make sure that the documentation example works
 #
 
-if HWLOC_BUILD_TESTS
-TESTS = hwloc-hello hwloc-hello-cpp
+TESTS = hwloc-hello
+if HWLOC_HAVE_CXX
+TESTS += hwloc-hello-cpp
+endif HWLOC_HAVE_CXX
+
 check_PROGRAMS = $(TESTS)
-endif HWLOC_BUILD_TESTS
 
 hwloc-hello-cpp.cpp: $(srcdir)/hwloc-hello.c
 	cp -f $(srcdir)/hwloc-hello.c $@

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/hwloc.doxy
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/hwloc.doxy	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/doc/hwloc.doxy	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux 1
+ * Copyright © 2009-2012 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.
  */
@@ -63,7 +63,7 @@
 independant from the processor type (x86, powerpc, ...) and just relies on the
 Operating System support. The only exception to this is kFreeBSD, which does
 not support topology information, and hwloc thus uses an x86-only CPUID-based
-backend (which could be used for other OSes too).
+backend (which can be used for other OSes too, see the \ref plugins section).
 
 To check whether hwloc works on a particular machine, just try to build it
 and run <tt>lstopo</tt> or <tt>lstopo-no-graphics</tt>. If some things do not look right
@@ -151,8 +151,12 @@
     XML files that were exported by the same hwloc release).
     See \ref xml for details.</li>
 </ul>
+libpci and libxml2 support may be statically built inside the main
+hwloc library, or as separate dynamically-loaded plugins
+(see the \ref plugins section).
 
 
+
 \htmlonly
 </div><div class="section" id="cli_examples">
 \endhtmlonly
@@ -590,9 +594,12 @@
 <li> \ref cpu_mem_bind
 <li> \ref iodevices
 <li> \ref multinode
+<li> \ref attributes
 <li> \ref xml
+<li> \ref synthetic
 <li> \ref interoperability
 <li> \ref threadsafety
+<li> \ref plugins
 <li> \ref embed
 <li> \ref faq
 </ul>
@@ -684,7 +691,7 @@
   object.  This may be completely arbitrary, non-unique, non-contiguous, not
   representative of logical proximity, and may depend on the BIOS
   configuration. That is why hwloc almost never uses them, only in the default
-  lstopo output (<tt>P#x</tt>) and cpuset masks.</dd>
+  lstopo output (<tt>P\#x</tt>) and cpuset masks.</dd>
 
 <dt>Logical index</dt>
   <dd>Index to uniquely identify objects of the same type and depth,
@@ -692,7 +699,7 @@
   logical proximity in a generic way, i.e. objects which have adjacent logical
   indexes are adjacent in the topology. That is why hwloc almost always uses
   it in its API, since it expresses logical proximity. They can be shown (as
-  <tt>L#x</tt>) by <tt>lstopo</tt> thanks to the <tt>-l</tt> option.  This index
+  <tt>L\#x</tt>) by <tt>lstopo</tt> thanks to the <tt>-l</tt> option.  This index
   is always linear and in
   the range [0, num_objs_same_type_same_level-1].  Think of it as ``cousin
   rank.'' The ordering is based on topology first, and then on OS CPU numbers,
@@ -703,14 +710,19 @@
   index (as computed according to logical proximity by hwloc).
   </dd>
 
-<dt>Logical processor</dt>
 <dt>Processing unit</dt>
   <dd>The smallest processing element that can be represented by a hwloc
   object. It may be a single-core processor, a core of a multicore
-  processor, or a single thread in SMT processor.
+  processor, or a single thread in a SMT processor.
+  hwloc's PU acronym stands for Processing Unit.
+  </dd>
+
+<!-- don't use a single <dd> for both PU and logicalproc <dt> because
+ it may be rendered poorly (big vfill between the <dt> lines -->
+<dt>Logical processor</dt>
+  <dd>Synonym of "Processing unit".
   "Logical processor" should not be confused with "Logical index of a
-  processor". "Logical processor" is only one of the names which can be found in
-  various documentations to designate a processing unit.
+  processor".
   </dd>
 
 </dl>
@@ -816,6 +828,13 @@
 hwloc-distances also displays matrices that ignore part
 of the topology.
 
+\section cli_hwloc_annotate hwloc-annotate
+
+hwloc-annotate may add object attributes such as string
+information (see \ref attributes_info for details).
+It reads an input topology from a XML file and outputs
+the annotated topology as another XML file.
+
 \section cli_hwloc_assembler hwloc-assembler
 
 hwloc-assembler combines several XML topology files into a single
@@ -861,6 +880,7 @@
   understanding failures to parse input XML topologies.
   Similarly, enabling verbose messages in the synthetic topology
   backend can help understand why the description string is invalid.
+  See also \ref synthetic.
   </dd>
 
 <dt>HWLOC_FSROOT=/path/to/linux/filesystem-root/</dt>
@@ -963,10 +983,49 @@
   of the corresponding host bridge.
   </dd>
 
+<dt>HWLOC_PLUGINS_PATH=/path/to/hwloc/plugins/:...</dt>
+  <dd>changes the default search directory for plugins.
+  By default, <tt>$libdir/hwloc</tt> is used.
+  The variable may contain several colon-separated directories.
+  </dd>
+
+<dt>HWLOC_PLUGINS_VERBOSE=1</dt>
+  <dd>display verbose information about plugins.
+  List which directories are scanned, which files are loaded,
+  and which components are successfully loaded.
+  </dd>
+
+<dt>HWLOC_COMPONENTS=list,of,components</dt>
+  <dd>forces a list of components to enable.
+  Enable the given comma-separated list of components
+   (if they do not conflict with each other).
+  Once the end of the list is reached, hwloc falls back to
+  enabling the remaining components (sorted by priority) that do not
+  conflict with the already enabled ones.
+  If <tt>stop</tt> is met, the enabling loop immediately stops, no
+  more component is enabled.
+  If the variable is set to an empty string, no specific component is
+  loaded first, all components are loaded in priority order,
+  this is strictly identical to not specifying any variable.
+  The <tt>xml</tt> component name may be followed by a XML file to
+  load (<tt>xml=file.xml</tt>).
+  The synthetic component may be followed by a synthetic topology
+  description (<tt>synthetic=node:2 pu:3</tt>).
+  See \ref plugins for details.
+  </dd>
+
+<dt>HWLOC_COMPONENTS_VERBOSE=1</dt>
+  <dd>display verbose information about components.
+  Display messages when components are registered or enabled.
+  This is the recommended way to list the available components
+  with their priority
+  (all of them are <em>registered</em> at startup).
+  </dd>
+
 </dl>
 
 <!-- not documented:
- HWLOC_FORCE_FSROOT/XMLFILE/THISSYSTEM
+ HWLOC_FORCE_FSROOT/XMLFILE
   force backend anyway (while variables without FORCE in their name do not
   force the backend if the default was already changed)
  HWLOC_LINUX_USE_CPUINFO
@@ -976,8 +1035,6 @@
   run sanity checks during discovery, as if --enable-debug was passed but
   without debug messages
   may be useful in the doc for debugging?
- add a HWLOC_USE_x86_BACKEND?
-  to force testing of the x86 backend
 -->
 
 
@@ -1369,6 +1426,89 @@
 
 
 
+\page attributes Object attributes
+
+\section attributes_normal Normal attributes
+
+hwloc objects have many attributes.
+The ::hwloc_obj structure contains a common set of attributes that
+are available for object types, for instance their <tt>type</tt> or
+<tt>logical_index</tt>.
+
+Each object also contains an <tt>attr</tt> field that, if non NULL,
+points to a union ::hwloc_obj_attr_u of type-specific attribute
+structures.
+For instance, a Cache object <tt>obj</tt> contains cache-specific
+information in <tt>obj->attr->cache</tt>, such as its size and
+associativity.
+See ::hwloc_obj_attr_u for details.
+
+\section attributes_info Custom string infos
+
+Aside from the <tt>name</tt> field of each object, hwloc annotates
+many objects with string attributes that are made of a key and a
+value.
+Each object contains a list of such pairs that may be consulted
+manually (looking at the object <tt>infos</tt> array field)
+or using the hwloc_obj_get_info_by_name().
+The user may additionally add new key-value pairs to any object using
+::hwloc_obj_add_info() or the \ref cli_hwloc_annotate program.
+
+Here is a non-exhaustive list of attributes that may be automatically
+added by hwloc (with the usual corresponding object in parentheses).
+Note that these attributes heavily depend on the ability of the
+operating system to report them.
+Many of them will therefore be missing on some OS.
+<dl>
+<dt>OSName, OSRelease, OSVersion, HostName, Architecture
+(Machine object)</dt>
+<dd>The operating system name, release, version, the hostname and the
+architecture name, as reported by the Unix <tt>uname</tt> command.
+</dd>
+<dt>Backend (Machine object or topology root object)</dt>
+<dd>The name of the hwloc backend/component that filled the topology.
+If several components were combined, multiple Backend keys may exist,
+with different values, for instance <tt>x86</tt>, <tt>Linux</tt>
+and <tt>libpci</tt>.
+</dd>
+<dt>LinuxCgroup (Machine object)</dt>
+<dd>The name the Linux control group where the calling process is
+placed.
+</dd>
+<dt>SyntheticDescription (topology root object)</dt>
+<dd>The description string that was given to hwloc to build this
+synthetic topology.
+</dd>
+<dt>CPUModel, CPUType (Socket or Machine)</dt>
+<dd>The processor model name,
+and a more-general processor type name when applicable (Solaris/Sparc).
+These attributes are usually added to Socket objects.
+However, when hwloc cannot detect the number of sockets but still
+knows their (same) model, the attribute may be added to the Machine
+object instead.
+</dd>
+<dt>PCIVendor, PCIDevice (PCI devices and bridges)</dt>
+<dd>The vendor and device names of the PCI device.
+</dd>
+<dt>DMIBoardVendor, DMIBoardName, etc. (Machine object)</dt>
+<dd>DMI hardware information such as the motherboard and chassis
+models and vendors, the BIOS revision, etc.,
+as reported by Linux under <tt>/sys/class/dmi/id/</tt>.
+</dd>
+<dt>Address, Port (Network interface OS devices)</dt>
+<dd>The MAC address and the port number of a software network
+interface, such as <tt>eth4</tt> on Linux.
+</dd>
+<dt>NodeGUID, SysImageGUID, Port3LID, Port4LMC, Port5GID6
+(OpenFabrics OS devices)</dt>
+<dd>The node GUID and GUID mask, the LID and LID mask count of a given
+port, and a GID of a port.
+</dd>
+</dl>
+
+
+
+
 \page xml Importing and exporting topologies from/to XML files
 
 hwloc offers the ability to export topologies to XML files and reload
@@ -1417,6 +1557,14 @@
 Its advantage is however to always be available without requiring
 any external dependency.
 
+If libxml2 is available but the core hwloc library should not directly
+depend on it, the libxml2 support may be built as a dynamicall-loaded
+plugin.
+One should pass <tt>--enable-plugins</tt> to enable plugin support
+(when supported) and build as plugins all component that support it.
+Or pass <tt>--enable-plugins=xml_libxml</tt> to only build this
+libxml2 support as a plugin.
+
 \section xml_errors XML import error management
 
 Importing XML files can fail at least because of file access errors,
@@ -1435,6 +1583,101 @@
 
 
 
+\page synthetic Synthetic topologies
+
+hwloc may load fake or remote topologies so as to consult them
+without having the underlying hardware available.
+Aside from loading XML topologies, hwloc also enables the building of
+<em>synthetic</em> topologies that are described by a single string
+listing the arity of each levels.
+
+For instance, lstopo may create a topology made of 2 NUMA nodes,
+containing a single socket each, with one cache above two
+single-threaded cores:
+
+\verbatim
+$ lstopo -i "node:2 sock:1 cache:1 core:2 pu:1" -
+Machine (2048MB)
+  NUMANode L#0 (P#0 1024MB) + Socket L#0 + L2 L#0 (4096KB)
+    Core L#0 + PU L#0 (P#0)
+    Core L#1 + PU L#1 (P#1)
+  NUMANode L#1 (P#1 1024MB) + Socket L#1 + L2 L#1 (4096KB)
+    Core L#2 + PU L#2 (P#2)
+    Core L#3 + PU L#3 (P#3)
+\endverbatim
+
+Replacing <tt>-</tt> with <tt>file.xml</tt> in this command line
+will export this topology to XML as usual.
+
+\section synthetic_string Synthetic description string
+
+Each item in the description string gives the type of the level and
+the number of such children under each object of the previous level.
+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).
+Note that I/O objects are not available.
+
+The root object does not appear in the string.
+A Machine object is used by default, and a System object replaces it
+if a Machine level is specified in the string.
+
+Cache level depths are automatically chosen by hwloc (only a L2 first,
+then a L1 under it, then L3 above, then L4 etc.).
+Memory and cache sizes are also automatically chosen.
+The only way to modifying them is to export to XML and manually modify
+the file.
+
+\section synthetic_use Loading a synthetic topology
+
+Aside from lstopo, the hwloc programming interface offers the same
+ability by passing the synthetic description string to
+::hwloc_topology_set_synthetic() before hwloc_topology_load().
+
+Synthetic topologies are created by the <tt>synthetic</tt> component.
+This component may be enabled by force by setting the HWLOC_COMPONENTS
+environment variable to something such as
+<tt>synthetic="node:2 core:3 pu:4"</tt>.
+
+Loading a synthetic topology disables binding support since the
+topology usually does not match the underlying hardware.
+Binding may be reenabled as usual by setting HWLOC_THISSYSTEM=1 in the
+environment or by setting the HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM
+topology flag.
+
+\section synthetic_export Exporting a topology as a synthetic string
+
+lstopo may export a topology as a synthetic string by forcing its
+output format. 
+It offers a convenient way to quickly describe the contents of a
+machine.
+
+\verbatim
+$ lstopo --of synthetic --no-io
+Socket:1 Cache:1 Cache:2 Cache:1 Cache:1 Core:1 PU:2 
+\endverbatim
+
+The exported string may be passed back to hwloc for recreating
+another similar topology.
+The entire tree will be similar, but cache types and memory sizes
+may be different from the originals.
+
+Such an export is only possible if the topology is totally symmetric,
+which means the <tt>symmetric_subtree</tt> field of the root object
+is set.
+This usually implies that I/O objects are disabled since attaching I/O
+busses often cause the topology to become assymetric.
+Passing <tt>--no-io</tt> to lstopo is therefore often useful to make
+synthetic export work (as well as not passing any I/O topology flag
+when using ::hwloc_topology_set_synthetic() manually).
+
+
+
+
 \page interoperability Interoperability With Other Software
 
 Although hwloc offers its own portable interface, it still may have to
@@ -1585,6 +1828,152 @@
 
 
 
+\page plugins Components and plugins
+
+hwloc is organized in components that are responsible for discovering
+objects.
+Depending on the topology configuration, some components will be used,
+some will be ignored.
+The usual default is to enable the native operating system component,
+(e.g. <tt>linux</tt> or <tt>solaris</tt>) and the
+<tt>libpci</tt> additional component.
+If available, an architecture-specific component (such as <tt>x86</tt>)
+may also improve the topology detection.
+
+If a XML topology is loaded, the <tt>xml</tt> discovery  component
+will be used instead of all other components.
+It internally uses a specific class of components for the actual XML
+import/export routines (<tt>xml_libxml</tt> and <tt>xml_nolibxml</tt>)
+but these will not be discussed here (see \ref xml_backends).
+
+\section plugins_default Components enabled by default
+
+The hwloc core contains a list of components sorted by priority.
+Each one is enabled as long as it does not conflict with the
+previously enabled ones.
+This includes native operating system components,
+architecture-specific ones, and if available, I/O components
+such as <tt>libpci</tt>.
+
+Usually the native operating system component
+(when it exists, e.g. <tt>linux</tt> or <tt>aix</tt>)
+is enabled first.
+Then hwloc looks for an architecture specific component
+(e.g. <tt>x86</tt>).
+Finally these also exist a basic component (<tt>no_os</tt>)
+that just tries to discover the number of PUs in the system.
+
+Each component discovers as much topology information as possible.
+Most of them, including most native OS components, do nothing
+unless the topology is still empty.
+Some others, such as <tt>x86</tt> and <tt>libpci</tt>,
+can complete and annotate what other backends still earlier.
+
+Default priorities ensure that clever components are invoked first.
+Native operating system components have higher priorities,
+and are therefore invoked first, because they likely offer
+very detailed topology information.
+If needed, it will be later extended by architecture-specific
+information (e.g. from the <tt>x86</tt> component).
+
+If any configuration function such as hwloc_topology_set_xml()
+is used before loading the topology, the corresponding component
+is enabled first.
+Then, as usual, hwloc enables any other component (based on
+priorities) that does not conflict.
+
+Certain components that manage a virtual topology, for instance XML
+topology import, synthetic topology description, or custom building,
+conflict with all other components.
+Therefore, one of them may only be loaded
+(e.g. with <tt>hwloc_topology_set_xml()</tt>)
+if no other component is enabled.
+
+The environment variable <tt>HWLOC_COMPONENTS_VERBOSE</tt>
+may be set to get verbose messages about component registration
+(including their priority) and enabling.
+
+\section plugins_select Selecting which components to use
+
+Aside from topology configuration function such as
+<tt>hwloc_topology_set_custom()</tt>, the default priority order may
+be changed through the  <tt>HWLOC_COMPONENTS</tt> environment
+variable (component names must be separated by commas).
+
+Specifying <tt>x86</tt> in this variable will cause the <tt>x86</tt>
+component to take precedence over any other component,
+including the native operating system component.
+It is therefore loaded first, before hwloc tries to load all remaining
+non-conflicting components.
+In this case, <tt>x86</tt> would take care of discovering everything
+it supports, instead of only completing what the native OS information.
+This may be useful if the native component is buggy on some platforms.
+
+It is possible to prevent all remaining components from being loaded
+by placing <tt>stop</tt> in the environment variable.
+Only the components listed before this keyword will be enabled.
+
+Certain component names (<tt>xml</tt> and <tt>synthetic</tt>)
+accept an argument (e.g. <tt>xml=file.xml</tt>).
+These arguments behave exactly as if the corresponding string had
+been passed to <tt>hwloc_topology_set_xml()</tt>
+or <tt>hwloc_topology_set_synthetic()</tt>.
+
+\section plugins_config Building components as plugins
+
+Components may optionally be built as plugins so that the hwloc core
+library does not directly depend on their dependencies (for instance
+the <tt>libpci</tt> library).
+Plugin support may be enabled with the <tt>--enable-plugins</tt>
+configure option.
+All components buildable as plugins will then be built as plugins.
+The configure option may be given a comma-separated list of component
+names to specify the exact list of components to build as plugins.
+
+Plugins are built as independent dynamic libraries that are installed
+in <tt>$libdir/hwloc</tt>.
+All plugins found in this directory are loaded during
+<tt>topology_init()</tt>.
+A specific list of directories (colon-separated) to scan may be
+specified in the <tt>HWLOC_PLUGINS_PATH</tt> environment variable.
+
+Plugin filenames must start with <tt>hwloc_</tt>.
+For instance the <tt>libpci</tt> plugin is usually built as
+<tt>hwloc_libpci.so</tt>.
+
+Note that loading a plugin just means that the corresponding component
+is registered to the hwloc core.
+Components are then only enabled if the topology configuration
+requests it, as explained in the previous sections.
+
+\section plugins_adding Adding new discovery components and plugins
+
+Each new discovery component requires a new <tt>hwloc_component</tt>
+structure to be exported to the hwloc core with name
+<tt>hwloc_<name>_component</tt>.
+The configure script should then be modified to add
+<tt><name></tt> to the <tt>hwloc_components</tt>
+variable so that the component is actually available at runtime.
+
+If the new component may be built as a plugin, the configure script
+should also define <tt>hwloc_<name>_component_maybeplugin=1</tt>.
+If the configure scripts decides to enable the component as a plugin,
+the variable <tt>hwloc_<name>_component</tt>
+will be set to <tt>plugin</tt>.
+The build system may then use this variable to actually
+change the way the component is built.
+
+The component structure contains a data field that points to an
+<tt>hwloc_disc_component</tt> which defines an <tt>instantiate</tt>
+callback.
+This function is invoked when this component is actually used by a topology.
+It creates a <tt>backend</tt> structure that usually contains a
+<tt>discover</tt> and/or <tt>notify_new_object</tt> callback taking
+care of the actual topology discovery.
+
+
+
+
 \page embed Embedding hwloc in Other Software
 
 It can be desirable to include hwloc in a larger software package (be
@@ -1917,16 +2306,24 @@
 \section faq_annotate How do I annotate the topology with private notes?
 
 Each hwloc object contains a <tt>userdata</tt> field that may be used by
-applications to store private pointers. This field is kept intact as long
-as the object is valid, which means as long as topology objects are not
-modified by reloading or restricting the topology.
+applications to store private pointers. This field is only valid
+during the lifetime of these container object and topology.
+It becomes invalid as soon the topology is reloaded or destroyed,
+or as soon as the object disappears, for instance when restricting
+the topology.
+The userdata field is not exported/imported to/from XML by default since
+hwloc does not know what it contains.
+This behavior may be changed by specifying application-specific callbacks
+with <tt>hwloc_topology_set_userdata_export_callback()</tt>
+and <tt>hwloc_topology_set_userdata_import_callback()</tt>.
 
 Each object may also contain some <em>info</em> attributes
-(key name and value) that are setup by hwloc and may be extended
-by the user with <tt>hwloc_obj_add_info()</tt>.
+(key name and value) that are setup by hwloc during discovery
+and that may be extended by the user with
+<tt>hwloc_obj_add_info()</tt> (see also \ref attributes).
 Contrary to the <tt>userdata</tt> field which is unique, multiple info
 attributes may exist for each object, even with the same name.
-These attributes are also exported to XML together with the topology.
+These attributes are always exported to XML.
 However only character strings may be used as key names and values.
 
 It is also possible to insert Misc objects with custom names anywhere

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,4 +1,4 @@
-# Copyright © 2009-2010 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009-2010 Université Bordeaux 1
 # Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
 # Copyright © 2011      Oracle and/or its affiliates.  All rights reserved.
@@ -26,6 +26,7 @@
         private/debug.h \
         private/misc.h \
         private/xml.h \
+        private/components.h \
         private/cpuid.h
 
 if HWLOC_HAVE_LINUX

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc/rename.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc/rename.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc/rename.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
- * Copyright © 2010-2012 inria.  All rights reserved.
+ * Copyright © 2010-2012 Inria.  All rights reserved.
  * See COPYING in top-level directory.
  */
 
@@ -136,6 +136,10 @@
 #define hwloc_topology_export_xml HWLOC_NAME(topology_export_xml)
 #define hwloc_topology_export_xmlbuffer HWLOC_NAME(topology_export_xmlbuffer)
 #define hwloc_free_xmlbuffer HWLOC_NAME(free_xmlbuffer)
+#define hwloc_topology_set_userdata_export_callback HWLOC_NAME(topology_set_userdata_import_callback)
+#define hwloc_export_obj_userdata HWLOC_NAME(export_obj_userdata)
+#define hwloc_export_obj_userdata_base64 HWLOC_NAME(export_obj_userdata_base64)
+#define hwloc_topology_set_userdata_import_callback HWLOC_NAME(topology_set_userdata_export_callback)
 
 #define hwloc_topology_insert_misc_object_by_cpuset HWLOC_NAME(topology_insert_misc_object_by_cpuset)
 #define hwloc_topology_insert_misc_object_by_parent HWLOC_NAME(topology_insert_misc_object_by_parent)
@@ -313,6 +317,7 @@
 #define hwloc_get_obj_inside_cpuset_by_type HWLOC_NAME(get_obj_inside_cpuset_by_type)
 #define hwloc_get_nbobjs_inside_cpuset_by_depth HWLOC_NAME(get_nbobjs_inside_cpuset_by_depth)
 #define hwloc_get_nbobjs_inside_cpuset_by_type HWLOC_NAME(get_nbobjs_inside_cpuset_by_type)
+#define hwloc_get_obj_index_inside_cpuset HWLOC_NAME(get_obj_index_inside_cpuset)
 #define hwloc_get_child_covering_cpuset HWLOC_NAME(get_child_covering_cpuset)
 #define hwloc_get_obj_covering_cpuset HWLOC_NAME(get_obj_covering_cpuset)
 #define hwloc_get_next_obj_covering_cpuset_by_depth HWLOC_NAME(get_next_obj_covering_cpuset_by_depth)
@@ -407,16 +412,77 @@
 #define hwloc_cpuid HWLOC_NAME(cpuid)
 
 /* private/xml.h */
-#define hwloc_nolibxml_backend_init HWLOC_NAME(nolibxml_backend_init)
-#define hwloc_nolibxml_export_file HWLOC_NAME(nolibxml_export_file)
-#define hwloc_nolibxml_export_buffer HWLOC_NAME(nolibxml_export_buffer)
-#define hwloc_nolibxml_free_buffer HWLOC_NAME(nolibxml_free_buffer)
 
-#define hwloc_libxml_backend_init HWLOC_NAME(libxml_backend_init)
-#define hwloc_libxml_export_file HWLOC_NAME(libxml_export_file)
-#define hwloc_libxml_export_buffer HWLOC_NAME(libxml_export_buffer)
-#define hwloc_libxml_free_buffer HWLOC_NAME(libxml_free_buffer)
+#define hwloc__xml_verbose HWLOC_NAME(_xml_verbose)
 
+#define hwloc__xml_import_state_s HWLOC_NAME(_xml_import_state_s)
+#define hwloc__xml_import_state_t HWLOC_NAME(_xml_import_state_t)
+#define hwloc_xml_backend_data_s HWLOC_NAME(xml_backend_data_s)
+#define hwloc__xml_export_state_s HWLOC_NAME(_xml_export_state_s)
+#define hwloc__xml_export_state_t HWLOC_NAME(_xml_export_state_t)
+#define hwloc__xml_export_object HWLOC_NAME(_xml_export_object)
+
+#define hwloc_xml_callbacks HWLOC_NAME(xml_callbacks)
+#define hwloc_xml_component HWLOC_NAME(xml_component)
+#define hwloc_xml_callbacks_register HWLOC_NAME(xml_callbacks_register)
+#define hwloc_xml_callbacks_reset HWLOC_NAME(xml_callbacks_reset)
+
+/* private/components.h */
+
+#define HWLOC_DISC_COMPONENT_TYPE_CPU HWLOC_NAME_CAPS(DISC_COMPONENT_TYPE_CPU)
+#define HWLOC_DISC_COMPONENT_TYPE_GLOBAL HWLOC_NAME_CAPS(DISC_COMPONENT_TYPE_GLOBAL)
+#define HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL HWLOC_NAME_CAPS(DISC_COMPONENT_TYPE_ADDITIONAL)
+#define HWLOC_DISC_COMPONENT_TYPE_MAX HWLOC_NAME_CAPS(DISC_COMPONENT_TYPE_MAX)
+
+#define hwloc_disc_component_type_e HWLOC_NAME(disc_component_type_e)
+#define hwloc_disc_component_type_t HWLOC_NAME(disc_component_type_t)
+#define hwloc_disc_component HWLOC_NAME(disc_component)
+
+#define hwloc_disc_component_force_enable HWLOC_NAME(disc_component_force_enable)
+#define hwloc_disc_components_enable_others HWLOC_NAME(disc_components_instantiate_others)
+
+#define hwloc_backend HWLOC_NAME(backend)
+#define hwloc_backend_alloc HWLOC_NAME(backend_alloc)
+#define hwloc_backend_enable HWLOC_NAME(backend_enable)
+#define hwloc_backends_reset HWLOC_NAME(backends_reset)
+#define hwloc_backends_disable_all HWLOC_NAME(backends_disable_all)
+#define hwloc_backends_is_thissystem HWLOC_NAME(backends_is_thissystem)
+#define hwloc_backends_get_obj_cpuset HWLOC_NAME(backends_get_obj_cpuset)
+#define hwloc_backends_notify_new_object HWLOC_NAME(backends_notify_new_object)
+
+#define hwloc_backend_flag_e HWLOC_NAME(backend_flag_e)
+#define HWLOC_BACKEND_FLAG_NEED_LEVELS HWLOC_NAME_CAPS(BACKEND_FLAG_NEED_LEVELS)
+
+#define hwloc_components_init HWLOC_NAME(components_init)
+#define hwloc_components_destroy_all HWLOC_NAME(components_destroy_all)
+
+#define HWLOC_COMPONENT_TYPE_DISC HWLOC_NAME_CAPS(COMPONENT_TYPE_DISC)
+#define HWLOC_COMPONENT_TYPE_XML HWLOC_NAME_CAPS(COMPONENT_TYPE_XML)
+#define HWLOC_COMPONENT_TYPE_MAX HWLOC_NAME_CAPS(COMPONENT_TYPE_MAX)
+
+#define hwloc_component_type_e HWLOC_NAME(component_type_e)
+#define hwloc_component_type_t HWLOC_NAME(component_type_t)
+
+#define hwloc_component HWLOC_NAME(component)
+
+#define hwloc_linux_component HWLOC_NAME(linux_component)
+#define hwloc_xml_component HWLOC_NAME(xml_component)
+#define hwloc_solaris_component HWLOC_NAME(solaris_component)
+#define hwloc_aix_component HWLOC_NAME(aix_component)
+#define hwloc_osf_component HWLOC_NAME(osf_component)
+#define hwloc_windows_component HWLOC_NAME(windows_component)
+#define hwloc_darwin_component HWLOC_NAME(darwin_component)
+#define hwloc_freebsd_component HWLOC_NAME(freebsd_component)
+#define hwloc_hpux_component HWLOC_NAME(hpux_component)
+#define hwloc_synthetic_component HWLOC_NAME(synthetic_component)
+#define hwloc_custom_component HWLOC_NAME(custom_component)
+#define hwloc_x86_component HWLOC_NAME(x86_component)
+#define hwloc_noos_component HWLOC_NAME(noos_component)
+#define hwloc_libpci_component HWLOC_NAME(libpci_component)
+
+#define hwloc_xml_nolibxml_component HWLOC_NAME(xml_nolibxml_component)
+#define hwloc_xml_libxml_component HWLOC_NAME(xml_libxml_component)
+
 /* private/private.h */
 
 #define hwloc_ignore_type_e HWLOC_NAME(ignore_type_e)
@@ -426,23 +492,10 @@
 #define HWLOC_IGNORE_TYPE_ALWAYS HWLOC_NAME_CAPS(IGNORE_TYPE_ALWAYS)
 
 #define hwloc_os_distances_s HWLOC_NAME(os_distances_s)
-#define hwloc_backend_e HWLOC_NAME(backend_e)
-#define hwloc_backend_t HWLOC_NAME(backend_t)
 
-#define HWLOC_BACKEND_NONE HWLOC_NAME_CAPS(BACKEND_NONE)
-#define HWLOC_BACKEND_SYNTHETIC HWLOC_NAME_CAPS(BACKEND_SYNTHETIC)
-#define HWLOC_BACKEND_LINUXFS HWLOC_NAME_CAPS(BACKEND_LINUXFS)
-#define HWLOC_BACKEND_XML HWLOC_NAME_CAPS(BACKEND_XML)
-#define HWLOC_BACKEND_MAX HWLOC_NAME_CAPS(BACKEND_MAX)
-
-#define hwloc_backend_params_u HWLOC_NAME(backend_params_u)
-#define hwloc_backend_params_linuxfs_s HWLOC_NAME(backend_params_linuxfs_s)
-#define hwloc_backend_params_osf HWLOC_NAME(backend_params_osf)
-#define hwloc_backend_params_xml_s HWLOC_NAME(backend_params_xml_s)
-#define hwloc_backend_params_synthetic_s HWLOC_NAME(backend_params_synthetic_s)
-
 #define hwloc_xml_imported_distances_s HWLOC_NAME(xml_imported_distances_s)
 
+#define hwloc_alloc_obj_cpusets HWLOC_NAME(alloc_obj_cpusets)
 #define hwloc_setup_pu_level HWLOC_NAME(setup_pu_level)
 #define hwloc_get_sysctlbyname HWLOC_NAME(get_sysctlbyname)
 #define hwloc_get_sysctl HWLOC_NAME(get_sysctl)
@@ -450,46 +503,22 @@
 #define hwloc_connect_children HWLOC_NAME(connect_children)
 #define hwloc_connect_levels HWLOC_NAME(connect_levels)
 
-#define hwloc_look_linuxfs HWLOC_NAME(look_linuxfs)
-#define hwloc_set_linuxfs_hooks HWLOC_NAME(set_linuxfs_hooks)
-#define hwloc_backend_linuxfs_init HWLOC_NAME(backend_linuxfs_init)
-#define hwloc_backend_linuxfs_exit HWLOC_NAME(backend_linuxfs_exit)
-#define hwloc_linuxfs_pci_lookup_osdevices HWLOC_NAME(linuxfs_pci_lookup_osdevices)
-#define hwloc_linuxfs_get_pcidev_cpuset HWLOC_NAME(linuxfs_get_pcidev_cpuset)
+#define hwloc_topology_setup_defaults HWLOC_NAME(topology_setup_defaults)
+#define hwloc_topology_clear HWLOC_NAME(topology_clear)
 
-#define hwloc_backend_xml_init HWLOC_NAME(backend_xml_init)
-#define hwloc_look_xml HWLOC_NAME(look_xml)
-#define hwloc_backend_xml_exit HWLOC_NAME(backend_xml_exit)
+#define hwloc_binding_hooks HWLOC_NAME(binding_hooks)
+#define hwloc_set_native_binding_hooks HWLOC_NAME(set_native_binding_hooks)
+#define hwloc_set_binding_hooks HWLOC_NAME(set_binding_hooks)
 
-#define hwloc_look_solaris HWLOC_NAME(look_solaris)
+#define hwloc_set_linuxfs_hooks HWLOC_NAME(set_linuxfs_hooks)
 #define hwloc_set_solaris_hooks HWLOC_NAME(set_solaris_hooks)
-
-#define hwloc_look_aix HWLOC_NAME(look_aix)
 #define hwloc_set_aix_hooks HWLOC_NAME(set_aix_hooks)
-
-#define hwloc_look_osf HWLOC_NAME(look_osf)
 #define hwloc_set_osf_hooks HWLOC_NAME(set_osf_hooks)
-
-#define hwloc_look_windows HWLOC_NAME(look_windows)
 #define hwloc_set_windows_hooks HWLOC_NAME(set_windows_hooks)
-
-#define hwloc_look_darwin HWLOC_NAME(look_darwin)
 #define hwloc_set_darwin_hooks HWLOC_NAME(set_darwin_hooks)
-
-#define hwloc_look_freebsd HWLOC_NAME(look_freebsd)
 #define hwloc_set_freebsd_hooks HWLOC_NAME(set_freebsd_hooks)
-
-#define hwloc_look_hpux HWLOC_NAME(look_hpux)
 #define hwloc_set_hpux_hooks HWLOC_NAME(set_hpux_hooks)
 
-#define hwloc_look_libpci HWLOC_NAME(look_libpci)
-
-#define hwloc_look_x86 HWLOC_NAME(look_x86)
-
-#define hwloc_backend_synthetic_init HWLOC_NAME(backend_synthetic_init)
-#define hwloc_backend_synthetic_exit HWLOC_NAME(backend_synthetic_exit)
-#define hwloc_look_synthetic  HWLOC_NAME(look_synthetic )
-
 #define hwloc_insert_object_by_cpuset HWLOC_NAME(insert_object_by_cpuset)
 #define hwloc_report_error_t HWLOC_NAME(report_error_t)
 #define hwloc_report_os_error HWLOC_NAME(report_os_error)
@@ -500,6 +529,7 @@
 #define hwloc_bitmap_printf_value HWLOC_NAME(bitmap_printf_value)
 #define hwloc_alloc_setup_object HWLOC_NAME(alloc_setup_object)
 #define hwloc_free_unlinked_object HWLOC_NAME(free_unlinked_object)
+#define hwloc__duplicate_objects HWLOC_NAME(_duplicate_objects)
 
 #define hwloc_alloc_heap HWLOC_NAME(alloc_heap)
 #define hwloc_alloc_mmap HWLOC_NAME(alloc_mmap)
@@ -520,6 +550,9 @@
 #define hwloc_clear_object_distances_one HWLOC_NAME(clear_object_distances_one)
 #define hwloc_group_by_distances HWLOC_NAME(group_by_distances)
 
+#define hwloc_encode_to_base64 HWLOC_NAME(encode_to_base64)
+#define hwloc_decode_from_base64 HWLOC_NAME(decode_from_base64)
+
 #endif /* HWLOC_SYM_TRANSFORM */
 
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/hwloc.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -74,7 +74,7 @@
  */
 
 /** \brief Indicate at build time which hwloc API version is being used. */
-#define HWLOC_API_VERSION 0x00010500
+#define HWLOC_API_VERSION 0x00010600
 
 /** \brief Indicate at runtime which hwloc API version was used at build time. */
 HWLOC_DECLSPEC unsigned hwloc_get_api_version(void);
@@ -371,7 +371,10 @@
   struct hwloc_obj *last_child;		/**< \brief Last child */
 
   /* misc */
-  void *userdata;			/**< \brief Application-given private data pointer, initialized to \c NULL, use it as you wish */
+  void *userdata;			/**< \brief Application-given private data pointer,
+					 * initialized to \c NULL, use it as you wish.
+					 * See hwloc_topology_set_userdata_export_callback()
+					 * if you wish to export this field to XML. */
 
   /* cpusets and nodesets */
   hwloc_cpuset_t cpuset;		/**< \brief CPUs covered by this object
@@ -469,6 +472,8 @@
 
   int symmetric_subtree;		/**< \brief Set if the subtree of objects below this object is symmetric,
 					  * which means all children and their children have identical subtrees.
+					  * If set in the topology root object, lstopo may export the topology
+					  * as a synthetic string.
 					  */
 };
 /**
@@ -587,6 +592,9 @@
  *
  * \return 0 on success, -1 on error.
  *
+ * \note On failure, the topology is reinitialized. It should be either
+ * destroyed with hwloc_topology_destroy() or configured and loaded again.
+ * 
  * \sa hwlocality_configuration
  */
 HWLOC_DECLSPEC int hwloc_topology_load(hwloc_topology_t topology);
@@ -737,6 +745,9 @@
 /** \brief Set OR'ed flags to non-yet-loaded topology.
  *
  * Set a OR'ed set of ::hwloc_topology_flags_e onto a topology that was not yet loaded.
+ *
+ * If this function is called multiple times, the last invokation will erase
+ * and replace the set of flags that was previously set.
  */
 HWLOC_DECLSPEC int hwloc_topology_set_flags (hwloc_topology_t topology, unsigned long flags);
 
@@ -778,7 +789,9 @@
  * HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM has to be set to assert that the loaded
  * file is really the underlying system.
  *
- * \note The existing topology is cleared even on failure.
+ * \note On success, the Linux component replaces the previously enabled
+ * component (if any), but the topology is not actually modified until
+ * hwloc_topology_load().
  */
 HWLOC_DECLSPEC int hwloc_topology_set_fsroot(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict fsroot_path);
 
@@ -791,6 +804,7 @@
  * of a level.  If only some level types are enforced, hwloc will try to
  * choose the other types according to usual topologies, but it may fail
  * and you may have to specify more level types manually.
+ * See also the \ref synthetic.
  *
  * If \p description was properly parsed and describes a valid topology
  * configuration, this function returns 0.
@@ -804,7 +818,9 @@
  * \note For convenience, this backend provides empty binding hooks which just
  * return success.
  *
- * \note The existing topology is cleared even on failure.
+ * \note On success, the synthetic component replaces the previously enabled
+ * component (if any), but the topology is not actually modified until
+ * hwloc_topology_load().
  */
 HWLOC_DECLSPEC int hwloc_topology_set_synthetic(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict description);
 
@@ -822,12 +838,17 @@
  *
  * \return -1 with errno set to EINVAL on failure to read the XML file.
  *
+ * \note See also hwloc_topology_set_userdata_import_callback()
+ * for importing application-specific userdata.
+ *
  * \note For convenience, this backend provides empty binding hooks which just
  * return success.  To have hwloc still actually call OS-specific hooks, the
  * HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM has to be set to assert that the loaded
  * file is really the underlying system.
  *
- * \note The existing topology is cleared even on failure.
+ * \note On success, the XML component replaces the previously enabled
+ * component (if any), but the topology is not actually modified until
+ * hwloc_topology_load().
  */
 HWLOC_DECLSPEC int hwloc_topology_set_xml(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict xmlpath);
 
@@ -845,23 +866,35 @@
  *
  * \return -1 with errno set to EINVAL on failure to read the XML buffer.
  *
+ * \note See also hwloc_topology_set_userdata_import_callback()
+ * for importing application-specific userdata.
+ *
  * \note For convenience, this backend provides empty binding hooks which just
  * return success.  To have hwloc still actually call OS-specific hooks, the
  * HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM has to be set to assert that the loaded
  * file is really the underlying system.
  *
- * \note The existing topology is cleared even on failure.
+ * \note On success, the XML component replaces the previously enabled
+ * component (if any), but the topology is not actually modified until
+ * hwloc_topology_load().
  */
 HWLOC_DECLSPEC int hwloc_topology_set_xmlbuffer(hwloc_topology_t __hwloc_restrict topology, const char * __hwloc_restrict buffer, int size);
 
 /** \brief Prepare the topology for custom assembly.
  *
  * The topology then contains a single root object.
- * It may then be built by inserting other topologies with
+ * It must then be built by inserting other topologies with
  * hwloc_custom_insert_topology() or single objects with
  * hwloc_custom_insert_group_object_by_parent().
  * hwloc_topology_load() must be called to finalize the new
  * topology as usual.
+ *
+ * \note If nothing is inserted in the topology,
+ * hwloc_topology_load() will fail with errno set to EINVAL.
+ *
+ * \note On success, the custom component replaces the previously enabled
+ * component (if any), but the topology is not actually modified until
+ * hwloc_topology_load().
  */
 HWLOC_DECLSPEC int hwloc_topology_set_custom(hwloc_topology_t topology);
 
@@ -972,7 +1005,7 @@
 
 
 
-/** \defgroup hwlocality_tinker Tinker With Topologies.
+/** \defgroup hwlocality_xmlexport Exporting Topologies to XML.
  * @{
  */
 
@@ -982,6 +1015,9 @@
  *
  * \return -1 if a failure occured.
  *
+ * \note See also hwloc_topology_set_userdata_export_callback()
+ * for exporting application-specific userdata.
+ *
  * \note Only printable characters may be exported to XML string attributes.
  * Any other character, especially any non-ASCII character, will be silently
  * dropped.
@@ -997,6 +1033,9 @@
  *
  * \return -1 if a failure occured.
  *
+ * \note See also hwloc_topology_set_userdata_export_callback()
+ * for exporting application-specific userdata.
+ *
  * \note Only printable characters may be exported to XML string attributes.
  * Any other character, especially any non-ASCII character, will be silently
  * dropped.
@@ -1006,6 +1045,98 @@
 /** \brief Free a buffer allocated by hwloc_topology_export_xmlbuffer() */
 HWLOC_DECLSPEC void hwloc_free_xmlbuffer(hwloc_topology_t topology, char *xmlbuffer);
 
+/** \brief Set the application-specific callback for exporting userdata
+ *
+ * The object userdata pointer is not exported to XML by default because hwloc
+ * does not know what it contains.
+ *
+ * This function lets applications set \p export_cb to a callback function
+ * that converts this opaque userdata into an exportable string.
+ *
+ * \p export_cb is invoked during XML export for each object whose
+ * \p userdata pointer is not \c NULL.
+ * The callback should use hwloc_export_obj_userdata() or
+ * hwloc_export_obj_userdata_base64() to actually export
+ * something to XML (possibly multiple times per object).
+ *
+ * \p export_cb may be set to \c NULL if userdata should not be exported to XML.
+ */
+HWLOC_DECLSPEC void hwloc_topology_set_userdata_export_callback(hwloc_topology_t topology,
+								void (*export_cb)(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj));
+
+/** \brief Export some object userdata to XML
+ *
+ * This function may only be called from within the export() callback passed
+ * to hwloc_topology_set_userdata_export_callback().
+ * It may be invoked one of multiple times to export some userdata to XML.
+ * The \p buffer content of length \p length is stored with optional name
+ * \p name.
+ *
+ * When importing this XML file, the import() callback (if set) will be
+ * called exactly as many times as hwloc_export_obj_userdata() was called
+ * during export(). It will receive the corresponding \p name, \p buffer
+ * and \p length arguments.
+ *
+ * \p reserved, \p topology and \p obj must be the first three parameters
+ * that were given to the export callback.
+ *
+ * Only printable characters may be exported to XML string attributes.
+ * If a non-printable character is passed in \p name or \p buffer,
+ * the function returns -1 with errno set to EINVAL.
+ *
+ * If exporting binary data, the application should first encode into
+ * printable characters only (or use hwloc_export_obj_userdata_base64()).
+ * It should also take care of portability issues if the export may
+ * be reimported on a different architecture.
+ */
+HWLOC_DECLSPEC int hwloc_export_obj_userdata(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length);
+
+/** \brief Encode and export some object userdata to XML
+ *
+ * This function is similar to hwloc_export_obj_userdata() but it encodes
+ * the input buffer into printable characters before exporting.
+ * On import, decoding is automatically performed before the data is given
+ * to the import() callback if any.
+ *
+ * This function may only be called from within the export() callback passed
+ * to hwloc_topology_set_userdata_export_callback().
+ *
+ * The function does not take care of portability issues if the export
+ * may be reimported on a different architecture.
+ */
+HWLOC_DECLSPEC int hwloc_export_obj_userdata_base64(void *reserved, hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length);
+
+/** \brief Set the application-specific callback for importing userdata
+ *
+ * On XML import, userdata is ignored by default because hwloc does not know
+ * how to store it in memory.
+ *
+ * This function lets applications set \p import_cb to a callback function
+ * that will get the XML-stored userdata and store it in the object as expected
+ * by the application.
+ *
+ * \p import_cb is called during hwloc_topology_load() as many times as
+ * hwloc_export_obj_userdata() was called during export. The topology
+ * is not entirely setup yet. Object attributes are ready to consult,
+ * but links between objects are not.
+ *
+ * \p import_cb may be \c NULL if userdata should be ignored during import.
+ *
+ * \note \p buffer contains \p length characters followed by a null byte ('\0').
+ *
+ * \note This function should be called before hwloc_topology_load().
+ */
+HWLOC_DECLSPEC void hwloc_topology_set_userdata_import_callback(hwloc_topology_t topology,
+								void (*import_cb)(hwloc_topology_t topology, hwloc_obj_t obj, const char *name, const void *buffer, size_t length));
+
+/** @} */
+
+
+
+/** \defgroup hwlocality_tinker Tinker With Topologies.
+ * @{
+ */
+
 /** \brief Add a MISC object to the topology
  *
  * A new MISC object will be created and inserted into the topology at the
@@ -1069,6 +1200,15 @@
  * \note This call may not be reverted by restricting back to a larger
  * cpuset. Once dropped during restriction, objects may not be brought
  * back, except by reloading the entire topology with hwloc_topology_load().
+ *
+ * \return 0 on success.
+ *
+ * \return -1 with errno set to EINVAL if the input cpuset is invalid.
+ * The topology is not modified in this case.
+ *
+ * \return -1 with errno set to ENOMEM on failure to allocate internal data.
+ * The topology is reinitialized in this case. It should be either
+ * destroyed with hwloc_topology_destroy() or configured and loaded again.
  */
 HWLOC_DECLSPEC int hwloc_topology_restrict(hwloc_topology_t __hwloc_restrict topology, hwloc_const_cpuset_t cpuset, unsigned long flags);
 

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/components.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/components.h	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/components.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,210 @@
+/*
+ * Copyright © 2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#ifndef PRIVATE_COMPONENTS_H
+#define PRIVATE_COMPONENTS_H 1
+
+struct hwloc_backend;
+
+/************************
+ * Discovery components *
+ ************************/
+
+/* Discovery components taking care of the discovery.
+ * They are registered by generic components, either static or plugins.
+ */
+
+typedef enum hwloc_disc_component_type_e {
+  HWLOC_DISC_COMPONENT_TYPE_CPU = (1<<0), /* CPU-only discovery through the OS, or generic no-OS support.
+					   */
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL = (1<<1), /* xml, synthetic or custom.
+					      * no additional backend is used.
+					      */
+  HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL = (1<<2), /* pci, etc.
+						  */
+  /* This value is only here so that we can end the enum list without
+     a comma (thereby preventing compiler warnings) */
+  HWLOC_DISC_COMPONENT_TYPE_MAX
+} hwloc_disc_component_type_t;
+
+struct hwloc_disc_component {
+  hwloc_disc_component_type_t type;
+  const char *name;
+  unsigned excludes; /* ORed set of (1<<HWLOC_DISC_COMPONENT_TYPE_*) */
+  struct hwloc_backend * (*instantiate)(struct hwloc_disc_component *component, const void *data1, const void *data2, const void *data3);
+
+  unsigned priority; /* used to sort topology->components, higher priority first.
+		      * 50 for native OS components,
+		      * 45 for x86,
+		      * 40 for no-OS fallback,
+		      * 30 for global components (xml/synthetic/custom),
+		      * 20 for libpci, likely less for other additional components.
+		      */
+  struct hwloc_disc_component * next; /* used internally to list components by priority on topology->components */
+};
+
+extern int hwloc_disc_component_force_enable(struct hwloc_topology *topology,
+					     int envvar_forced, /* 1 if forced through envvar, 0 if forced through API */
+					     int type, const char *name,
+					     const void *data1, const void *data2, const void *data3);
+extern void hwloc_disc_components_enable_others(struct hwloc_topology *topology);
+
+/************
+ * Backends *
+ ************/
+
+/* A backend is the instantiation of a discovery component.
+ * When a component gets enabled for a topology,
+ * its instantiate() callback creates a backend.
+ *
+ * hwloc_backend_alloc() initializes all fields to default values
+ * that the component may change (except "component" and "next")
+ * before enabling the backend with hwloc_backend_enable().
+ */
+
+struct hwloc_backend {
+  struct hwloc_disc_component * component; /* Reserved for the core, set by hwloc_backend_alloc() */
+  struct hwloc_topology * topology; /* Reserved for the core, set by hwloc_backend_enable() */
+
+  unsigned long flags; /* OR'ed set of HWLOC_BACKEND_FLAG_* */
+
+  /* main discovery callback.
+   * returns > 0 if it modified the topology tree, -1 on error, 0 otherwise.
+   * maybe NULL if type is HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL. */
+  int (*discover)(struct hwloc_backend *backend);
+
+  /* used by the libpci backend to retrieve pci device locality from the OS/cpu backend */
+  int (*get_obj_cpuset)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset); /* may be NULL */
+
+  /* used by additional backends to notify other backend when new objects are added.
+   * returns > 0 if it modified the topology tree, 0 otherwise. */
+  int (*notify_new_object)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj); /* may be NULL */
+
+  void (*disable)(struct hwloc_backend *backend); /* may be NULL */
+  void * private_data;
+  int is_custom; /* shortcut on !strcmp(..->component->name, "custom") */
+  int is_thissystem; /* -1 if doesn't matter, 0 or 1 if should enforce thissystem when enabling */
+
+  int envvar_forced; /* 1 if forced through envvar, 0 otherwise */
+
+  struct hwloc_backend * next; /* Used internally to list backends topology->backends.
+				* Reserved for the core.
+				*/
+};
+
+enum hwloc_backend_flag_e {
+  HWLOC_BACKEND_FLAG_NEED_LEVELS = (1<<0) /* Levels should be reconnected before this backend discover() is used */
+};
+
+/* Allocate a backend structure, set good default values, initialize backend->component.
+ * The caller will then modify whatever needed, and call hwloc_backend_enable().
+ */
+HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_disc_component *component);
+
+/* Enable a previously allocated and setup backend. */
+HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend);
+
+/* Compute the topology is_thissystem flag based on enabled backends */
+HWLOC_DECLSPEC void hwloc_backends_is_thissystem(struct hwloc_topology *topology);
+
+/* Used by backends discovery callbacks to request information from others.
+ */
+HWLOC_DECLSPEC int hwloc_backends_get_obj_cpuset(struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
+
+/* Used by backends discovery callbacks to notify other backends (all but caller)
+ * that they are adding a new object.
+ */
+HWLOC_DECLSPEC int hwloc_backends_notify_new_object(struct hwloc_backend *caller, struct hwloc_obj *obj);
+
+/* Reset the list of currently enabled backend */
+extern void hwloc_backends_reset(struct hwloc_topology *topology);
+/* Disable and destroy all backends used by a topology */
+extern void hwloc_backends_disable_all(struct hwloc_topology *topology);
+
+/**********************
+ * Generic components *
+ **********************/
+
+/* Generic components structure, either static listed by configure in static-components.h
+ * or dynamically loaded as a plugin.
+ */
+
+/* Used by the core to setup/destroy the list of components */
+extern void hwloc_components_init(struct hwloc_topology *topology); /* increases components refcount, should be called exactly once per topology (during init) */
+extern void hwloc_components_destroy_all(struct hwloc_topology *topology); /* decreases components refcount, should be called exactly once per topology (during destroy) */
+
+#define HWLOC_COMPONENT_ABI 1
+
+typedef enum hwloc_component_type_e {
+  HWLOC_COMPONENT_TYPE_DISC,	/* The data field must point to a struct hwloc_disc_component. */
+  HWLOC_COMPONENT_TYPE_XML,	/* The data field must point to a struct hwloc_xml_component. */
+  HWLOC_COMPONENT_TYPE_MAX
+} hwloc_component_type_t;
+
+struct hwloc_component {
+  unsigned abi;
+  hwloc_component_type_t type;
+  unsigned long flags; /* unused for now */
+  void * data;
+};
+
+/****************************************
+ * Misc component registration routines *
+ ****************************************/
+
+#if defined(HWLOC_LINUX_SYS)
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_linux_component;
+#endif /* HWLOC_LINUX_SYS */
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_component;
+
+#ifdef HWLOC_SOLARIS_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_solaris_component;
+#endif /* HWLOC_SOLARIS_SYS */
+
+#ifdef HWLOC_AIX_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_aix_component;
+#endif /* HWLOC_AIX_SYS */
+
+#ifdef HWLOC_OSF_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_osf_component;
+#endif /* HWLOC_OSF_SYS */
+
+#ifdef HWLOC_WIN_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_windows_component;
+#endif /* HWLOC_WIN_SYS */
+
+#ifdef HWLOC_DARWIN_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_darwin_component;
+#endif /* HWLOC_DARWIN_SYS */
+
+#ifdef HWLOC_FREEBSD_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_freebsd_component;
+#endif /* HWLOC_FREEBSD_SYS */
+
+#ifdef HWLOC_HPUX_SYS
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_hpux_component;
+#endif /* HWLOC_HPUX_SYS */
+
+#ifdef HWLOC_HAVE_LIBPCI
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_libpci_component;
+#endif /* HWLOC_HAVE_LIBPCI */
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_synthetic_component;
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_x86_component;
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_noos_component;
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_custom_component;
+
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_nolibxml_component;
+#ifdef HWLOC_HAVE_LIBXML2
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_xml_libxml_component;
+#endif
+
+#endif /* PRIVATE_COMPONENTS_H */
+

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/cpuid.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/cpuid.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/cpuid.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -51,24 +51,29 @@
 
 static __hwloc_inline void hwloc_cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
 {
+  /* Note: gcc might want to use bx or the stack for %1 addressing, so we can't
+   * use them :/ */
 #ifdef HWLOC_X86_64_ARCH
-  unsigned long sav_ebx;
-#endif
+  unsigned long sav_rbx;
   asm(
-#ifdef HWLOC_X86_32_ARCH
-  "push %%ebx\n\t"
-#else
   "mov %%rbx,%2\n\t"
-#endif
   "cpuid\n\t"
-#ifdef HWLOC_X86_32_ARCH
-  "mov %%ebx,%1\n\t"
-  "pop %%ebx\n\t"
+  "xchg %2,%%rbx\n\t"
+  "movl %k2,%1\n\t"
+  : "+a" (*eax), "=m" (*ebx), "=&r"(sav_rbx),
+    "+c" (*ecx), "=&d" (*edx));
+#elif defined(HWLOC_X86_32_ARCH)
+  unsigned long sav_ebx;
+  asm(
+  "mov %%ebx,%2\n\t"
+  "cpuid\n\t"
+  "xchg %2,%%ebx\n\t"
+  "movl %k2,%1\n\t"
+  : "+a" (*eax), "=m" (*ebx), "=&r"(sav_ebx),
+    "+c" (*ecx), "=&d" (*edx));
 #else
-  "mov %%ebx,%1\n\t"
-  "mov %2,%%rbx\n\t"
+#error unknown architecture
 #endif
-  : "+a" (*eax), "=r" (*ebx), "=r"(sav_ebx), "+c" (*ecx), "=d" (*edx));
 }
 
 #endif /* HWLOC_PRIVATE_CPUID_H */

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/private.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/private.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/private.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009      CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2012 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  *
@@ -15,8 +15,12 @@
 #include <private/autogen/config.h>
 #include <hwloc.h>
 #include <hwloc/bitmap.h>
+#include <private/components.h>
 #include <private/debug.h>
 #include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -25,10 +29,6 @@
 #endif
 #include <string.h>
 
-#if defined(HAVE_GETPAGESIZE) && defined(NEEDS_GETPAGESIZE_DECL)
-int getpagesize(void);
-#endif
-
 #ifdef HWLOC_HAVE_ATTRIBUTE_FORMAT
 # if HWLOC_HAVE_ATTRIBUTE_FORMAT
 #  define __hwloc_attribute_format(type, str, arg)  __attribute__((__format__(type, str, arg)))
@@ -47,21 +47,6 @@
 
 #define HWLOC_DEPTH_MAX 128
 
-typedef enum hwloc_backend_e {
-  HWLOC_BACKEND_NONE,
-  HWLOC_BACKEND_SYNTHETIC,
-#ifdef HWLOC_LINUX_SYS
-  HWLOC_BACKEND_LINUXFS,
-#endif
-  HWLOC_BACKEND_XML,
-  HWLOC_BACKEND_CUSTOM,
-  /* This value is only here so that we can end the enum list without
-     a comma (thereby preventing compiler warnings) */
-  HWLOC_BACKEND_MAX
-} hwloc_backend_t;
-
-struct hwloc__xml_import_state_s;
-
 struct hwloc_topology {
   unsigned nb_levels;					/* Number of horizontal levels */
   unsigned next_group_depth;				/* Depth of the next Group object that we may create */
@@ -84,38 +69,43 @@
   struct hwloc_obj **osdev_level;
   struct hwloc_obj *first_osdev, *last_osdev;
 
-  int (*set_thisproc_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
-  int (*get_thisproc_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
-  int (*set_thisthread_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
-  int (*get_thisthread_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
-  int (*set_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags);
-  int (*get_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
+  struct hwloc_binding_hooks {
+    int (*set_thisproc_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
+    int (*get_thisproc_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
+    int (*set_thisthread_cpubind)(hwloc_topology_t topology, hwloc_const_cpuset_t set, int flags);
+    int (*get_thisthread_cpubind)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
+    int (*set_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_cpuset_t set, int flags);
+    int (*get_proc_cpubind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
 #ifdef hwloc_thread_t
-  int (*set_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int flags);
-  int (*get_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int flags);
+    int (*set_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_const_cpuset_t set, int flags);
+    int (*get_thread_cpubind)(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_cpuset_t set, int flags);
 #endif
 
-  int (*get_thisproc_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
-  int (*get_thisthread_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
-  int (*get_proc_last_cpu_location)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
+    int (*get_thisproc_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
+    int (*get_thisthread_last_cpu_location)(hwloc_topology_t topology, hwloc_cpuset_t set, int flags);
+    int (*get_proc_last_cpu_location)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_cpuset_t set, int flags);
 
-  int (*set_thisproc_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
-  int (*get_thisproc_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
-  int (*set_thisthread_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
-  int (*get_thisthread_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
-  int (*set_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
-  int (*get_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
-  int (*set_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
-  int (*get_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
-  /* This has to return the same kind of pointer as alloc_membind, so that free_membind can be used on it */
-  void *(*alloc)(hwloc_topology_t topology, size_t len);
-  /* alloc_membind has to always succeed if !(flags & HWLOC_MEMBIND_STRICT).
-   * see hwloc_alloc_or_fail which is convenient for that.  */
-  void *(*alloc_membind)(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
-  int (*free_membind)(hwloc_topology_t topology, void *addr, size_t len);
+    int (*set_thisproc_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
+    int (*get_thisproc_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
+    int (*set_thisthread_membind)(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
+    int (*get_thisthread_membind)(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
+    int (*set_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
+    int (*get_proc_membind)(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
+    int (*set_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
+    int (*get_area_membind)(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags);
+    /* This has to return the same kind of pointer as alloc_membind, so that free_membind can be used on it */
+    void *(*alloc)(hwloc_topology_t topology, size_t len);
+    /* alloc_membind has to always succeed if !(flags & HWLOC_MEMBIND_STRICT).
+     * see hwloc_alloc_or_fail which is convenient for that.  */
+    void *(*alloc_membind)(hwloc_topology_t topology, size_t len, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags);
+    int (*free_membind)(hwloc_topology_t topology, void *addr, size_t len);
+  } binding_hooks;
 
   struct hwloc_topology_support support;
 
+  void (*userdata_export_cb)(void *reserved, struct hwloc_topology *topology, struct hwloc_obj *obj);
+  void (*userdata_import_cb)(struct hwloc_topology *topology, struct hwloc_obj *obj, const char *name, const void *buffer, size_t length);
+
   struct hwloc_os_distances_s {
     hwloc_obj_type_t type;
     int nbobjs;
@@ -134,46 +124,11 @@
     struct hwloc_os_distances_s *prev, *next;
   } *first_osdist, *last_osdist;
 
-  hwloc_backend_t backend_type;
-  union hwloc_backend_params_u {
-#ifdef HWLOC_LINUX_SYS
-    struct hwloc_backend_params_linuxfs_s {
-      /* FS root parameters */
-      char *root_path; /* The path of the file system root, used when browsing, e.g., Linux' sysfs and procfs. */
-      int root_fd; /* The file descriptor for the file system root, used when browsing, e.g., Linux' sysfs and procfs. */
-      struct utsname utsname; /* cached result of uname, used multiple times */
-    } linuxfs;
-#endif /* HWLOC_LINUX_SYS */
-#if defined(HWLOC_OSF_SYS) || defined(HWLOC_COMPILE_PORTS)
-    struct hwloc_backend_params_osf {
-      int nbnodes;
-    } osf;
-#endif /* HWLOC_OSF_SYS */
-    struct hwloc_backend_params_xml_s {
-      /* xml backend parameters */
-      int (*look)(struct hwloc_topology *topology, struct hwloc__xml_import_state_s *state);
-      void (*look_failed)(struct hwloc_topology *topology);
-      void (*backend_exit)(struct hwloc_topology *topology);
-      void *data; /* libxml2 doc, or nolibxml buffer */
-      struct hwloc_xml_imported_distances_s {
-	hwloc_obj_t root;
-	struct hwloc_distances_s distances;
-	struct hwloc_xml_imported_distances_s *prev, *next;
-      } *first_distances, *last_distances;
-    } xml;
-    struct hwloc_backend_params_synthetic_s {
-      /* synthetic backend parameters */
-      char *string;
-#define HWLOC_SYNTHETIC_MAX_DEPTH 128
-      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 */
-    } synthetic;
-  } backend_params;
+  /* list of enabled backends. */
+  struct hwloc_backend * backends;
 };
 
-
+extern void hwloc_alloc_obj_cpusets(hwloc_obj_t obj);
 extern void hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus);
 extern int hwloc_get_sysctlbyname(const char *name, int64_t *n);
 extern int hwloc_get_sysctl(int name[], unsigned namelen, int *n);
@@ -181,65 +136,46 @@
 extern void hwloc_connect_children(hwloc_obj_t obj);
 extern int hwloc_connect_levels(hwloc_topology_t topology);
 
+extern void hwloc_topology_setup_defaults(struct hwloc_topology *topology);
+extern void hwloc_topology_clear(struct hwloc_topology *topology);
 
+/* set native OS binding hooks */
+extern void hwloc_set_native_binding_hooks(struct hwloc_binding_hooks *hooks, struct hwloc_topology_support *support);
+/* set either native OS binding hooks (if thissystem), or dummy ones */
+extern void hwloc_set_binding_hooks(struct hwloc_topology *topology);
+
 #if defined(HWLOC_LINUX_SYS)
-extern void hwloc_look_linuxfs(struct hwloc_topology *topology);
-extern void hwloc_set_linuxfs_hooks(struct hwloc_topology *topology);
-extern int hwloc_backend_linuxfs_init(struct hwloc_topology *topology, const char *fsroot_path);
-extern void hwloc_backend_linuxfs_exit(struct hwloc_topology *topology);
-extern void hwloc_linuxfs_pci_lookup_osdevices(struct hwloc_topology *topology, struct hwloc_obj *pcidev);
-extern int hwloc_linuxfs_get_pcidev_cpuset(struct hwloc_topology *topology, struct hwloc_obj *pcidev, hwloc_bitmap_t cpuset);
+extern void hwloc_set_linuxfs_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_LINUX_SYS */
 
-extern int hwloc_backend_xml_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int buflen);
-extern int hwloc_look_xml(struct hwloc_topology *topology);
-extern void hwloc_backend_xml_exit(struct hwloc_topology *topology);
-
 #ifdef HWLOC_SOLARIS_SYS
-extern void hwloc_look_solaris(struct hwloc_topology *topology);
-extern void hwloc_set_solaris_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_solaris_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_SOLARIS_SYS */
 
 #ifdef HWLOC_AIX_SYS
-extern void hwloc_look_aix(struct hwloc_topology *topology);
-extern void hwloc_set_aix_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_aix_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_AIX_SYS */
 
 #ifdef HWLOC_OSF_SYS
-extern void hwloc_look_osf(struct hwloc_topology *topology);
-extern void hwloc_set_osf_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_osf_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_OSF_SYS */
 
 #ifdef HWLOC_WIN_SYS
-extern void hwloc_look_windows(struct hwloc_topology *topology);
-extern void hwloc_set_windows_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_windows_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_WIN_SYS */
 
 #ifdef HWLOC_DARWIN_SYS
-extern void hwloc_look_darwin(struct hwloc_topology *topology);
-extern void hwloc_set_darwin_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_darwin_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_DARWIN_SYS */
 
 #ifdef HWLOC_FREEBSD_SYS
-extern void hwloc_look_freebsd(struct hwloc_topology *topology);
-extern void hwloc_set_freebsd_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_freebsd_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_FREEBSD_SYS */
 
 #ifdef HWLOC_HPUX_SYS
-extern void hwloc_look_hpux(struct hwloc_topology *topology);
-extern void hwloc_set_hpux_hooks(struct hwloc_topology *topology);
+extern void hwloc_set_hpux_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
 #endif /* HWLOC_HPUX_SYS */
 
-extern void hwloc_look_x86(struct hwloc_topology *topology, unsigned nbprocs);
-
-#ifdef HWLOC_HAVE_LIBPCI
-extern void hwloc_look_libpci(struct hwloc_topology *topology);
-#endif /* HWLOC_HAVE_LIBPCI */
-
-extern int hwloc_backend_synthetic_init(struct hwloc_topology *topology, const char *description);
-extern void hwloc_backend_synthetic_exit(struct hwloc_topology *topology);
-extern void hwloc_look_synthetic (struct hwloc_topology *topology);
-
 /*
  * Add an object to the topology.
  * It is sorted along the tree of other objects according to the inclusion of
@@ -256,16 +192,16 @@
  *
  * In case of error, hwloc_report_os_error() is called.
  */
-extern void hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
+HWLOC_DECLSPEC void hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
 
 /* Error reporting */
 typedef void (*hwloc_report_error_t)(const char * msg, int line);
-extern void hwloc_report_os_error(const char * msg, int line);
-extern int hwloc_hide_errors(void);
+HWLOC_DECLSPEC void hwloc_report_os_error(const char * msg, int line);
+HWLOC_DECLSPEC int hwloc_hide_errors(void);
 /*
  * Add an object to the topology and specify which error callback to use
  */
-extern int hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
+HWLOC_DECLSPEC int hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
 
 /*
  * Insert an object somewhere in the topology.
@@ -278,7 +214,7 @@
  *
  * Remember to call topology_connect() afterwards to fix handy pointers.
  */
-extern void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
+HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
 
 /* Insert uname-specific names/values in the object infos array */
 extern void hwloc_add_uname_info(struct hwloc_topology *topology);
@@ -306,10 +242,14 @@
   /* do not allocate the cpuset here, let the caller do it */
   return obj;
 }
+#endif
 
+/* Free obj and its attributes assuming it doesn't have any children/parent anymore */
 extern void hwloc_free_unlinked_object(hwloc_obj_t obj);
-#endif
 
+/* Duplicate src and its children under newparent in newtopology */
+extern void hwloc__duplicate_objects(struct hwloc_topology *newtopology, struct hwloc_obj *newparent, struct hwloc_obj *src);
+
 /* This can be used for the alloc field to get allocated data that can be freed by free() */
 void *hwloc_alloc_heap(hwloc_topology_t topology, size_t len);
 
@@ -372,4 +312,27 @@
 #define fabsf(f) fabs((double)(f))
 #endif
 
+#if HAVE_DECL__SC_PAGE_SIZE
+#define hwloc_getpagesize() sysconf(_SC_PAGE_SIZE)
+#elif HAVE_DECL__SC_PAGESIZE
+#define hwloc_getpagesize() sysconf(_SC_PAGESIZE)
+#elif defined HAVE_GETPAGESIZE
+#define hwloc_getpagesize() getpagesize()
+#else
+#undef hwloc_getpagesize
+#endif
+
+/* encode src buffer into target buffer.
+ * targsize must be at least 4*((srclength+2)/3)+1.
+ * target will be 0-terminated.
+ */
+extern int hwloc_encode_to_base64(const char *src, size_t srclength, char *target, size_t targsize);
+/* decode src buffer into target buffer.
+ * src is 0-terminated.
+ * targsize must be at least srclength*3/4+1 (srclength not including \0)
+ * but only srclength*3/4 characters will be meaningful
+ * (the next one may be partially written during decoding, but it should be ignored).
+ */
+extern int hwloc_decode_from_base64(char const *src, char *target, size_t targsize);
+
 #endif /* HWLOC_PRIVATE_H */

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/xml.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/xml.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/include/private/xml.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,17 +1,18 @@
+/*
+ * Copyright © 2009-2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
 #ifndef PRIVATE_XML_H
 #define PRIVATE_XML_H 1
 
-struct hwloc_topology;
-struct hwloc_obj;
+#include <hwloc.h>
+#include <private/private.h>
 
 #include <sys/types.h>
 
-#ifdef HWLOC_HAVE_LIBXML2
-#include <libxml/tree.h>
-#endif
+HWLOC_DECLSPEC int hwloc__xml_verbose(void);
 
-extern int hwloc__xml_verbose(void);
-
 typedef struct hwloc__xml_import_state_s {
   struct hwloc__xml_import_state_s *parent;
 
@@ -19,6 +20,8 @@
   int (*find_child)(struct hwloc__xml_import_state_s * state, struct hwloc__xml_import_state_s * childstate, char **tagp);
   int (*close_tag)(struct hwloc__xml_import_state_s * state); /* look for an explicit closing tag </name> */
   void (*close_child)(struct hwloc__xml_import_state_s * state);
+  int (*get_content)(struct hwloc__xml_import_state_s * state, char **beginp, size_t expected_length);
+  void (*close_content)(struct hwloc__xml_import_state_s * state);
 
   /* opaque data used to store backend-specific data.
    * statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
@@ -26,28 +29,52 @@
   char data[32];
 } * hwloc__xml_import_state_t;
 
-typedef struct hwloc__xml_export_output_s {
-  void (*new_child)(struct hwloc__xml_export_output_s *output, const char *name);
-  void (*new_prop)(struct hwloc__xml_export_output_s *output, const char *name, const char *value);
-  void (*end_props)(struct hwloc__xml_export_output_s *output, unsigned nr_children);
-  void (*end_child)(struct hwloc__xml_export_output_s *output, const char *name, unsigned nr_children);
+struct hwloc_xml_backend_data_s {
+  /* xml backend parameters */
+  int (*look_init)(struct hwloc_xml_backend_data_s *bdata, struct hwloc__xml_import_state_s *state);
+  void (*look_failed)(struct hwloc_xml_backend_data_s *bdata);
+  void (*backend_exit)(struct hwloc_xml_backend_data_s *bdata);
+  void *data; /* libxml2 doc, or nolibxml buffer */
+  struct hwloc_xml_imported_distances_s {
+    hwloc_obj_t root;
+    struct hwloc_distances_s distances;
+    struct hwloc_xml_imported_distances_s *prev, *next;
+  } *first_distances, *last_distances;
+};
 
-  /* allocated by the backend (a single output is needed for the entire export) */
-  void *data;
-} * hwloc__xml_export_output_t;
+typedef struct hwloc__xml_export_state_s {
+  struct hwloc__xml_export_state_s *parent;
 
-extern void hwloc__xml_export_object (hwloc__xml_export_output_t output, struct hwloc_topology *topology, struct hwloc_obj *obj);
+  void (*new_child)(struct hwloc__xml_export_state_s *parentstate, struct hwloc__xml_export_state_s *state, const char *name);
+  void (*new_prop)(struct hwloc__xml_export_state_s *state, const char *name, const char *value);
+  void (*add_content)(struct hwloc__xml_export_state_s *state, const char *buffer, size_t length);
+  void (*end_object)(struct hwloc__xml_export_state_s *state, const char *name);
 
-extern int hwloc_nolibxml_backend_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int xmlbuflen);
-extern int hwloc_nolibxml_export_file(struct hwloc_topology *topology, const char *filename);
-extern int hwloc_nolibxml_export_buffer(struct hwloc_topology *topology, char **xmlbuffer, int *buflen);
-extern void hwloc_nolibxml_free_buffer(void *xmlbuffer);
+  /* opaque data used to store backend-specific data.
+   * statically allocated to allow stack-allocation by the common code without knowing actual backend needs.
+   */
+  char data[40];
+} * hwloc__xml_export_state_t;
 
-#ifdef HWLOC_HAVE_LIBXML2
-extern int hwloc_libxml_backend_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int xmlbuflen);
-extern int hwloc_libxml_export_file(struct hwloc_topology *topology, const char *filename);
-extern int hwloc_libxml_export_buffer(struct hwloc_topology *topology, char **xmlbuffer, int *buflen);
-extern void hwloc_libxml_free_buffer(void *xmlbuffer);
-#endif
+HWLOC_DECLSPEC void hwloc__xml_export_object (hwloc__xml_export_state_t state, struct hwloc_topology *topology, struct hwloc_obj *obj);
 
+/******************
+ * XML components *
+ ******************/
+
+struct hwloc_xml_callbacks {
+  int (*backend_init)(struct hwloc_xml_backend_data_s *bdata, const char *xmlpath, const char *xmlbuffer, int xmlbuflen);
+  int (*export_file)(struct hwloc_topology *topology, const char *filename);
+  int (*export_buffer)(struct hwloc_topology *topology, char **xmlbuffer, int *buflen);
+  void (*free_buffer)(void *xmlbuffer);
+};
+
+struct hwloc_xml_component {
+  struct hwloc_xml_callbacks *nolibxml_callbacks;
+  struct hwloc_xml_callbacks *libxml_callbacks;
+};
+
+HWLOC_DECLSPEC void hwloc_xml_callbacks_register(struct hwloc_xml_component *component);
+HWLOC_DECLSPEC void hwloc_xml_callbacks_reset(void);
+
 #endif /* PRIVATE_XML_H */

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,4 +1,4 @@
-# Copyright © 2009-2010 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009-2010, 2012 Université Bordeaux 1
 # Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 # Copyright © 2011-2012 Oracle and/or its affiliates.  All rights reserved.
@@ -19,28 +19,51 @@
 noinst_LTLIBRARIES = libhwloc_embedded.la
 endif
 
+pluginsdir = $(libdir)/hwloc
+plugins_LTLIBRARIES = 
+plugins_ldflags = -module -avoid-version
+AM_CPPFLAGS += -DHWLOC_PLUGINS_DIR=\"$(pluginsdir)\"
+
 # Sources and ldflags
 
 sources = \
         topology.c \
         traversal.c \
         distances.c \
+        components.c \
+        bind.c \
+        bitmap.c \
+        misc.c \
+        base64.c \
+        topology-noos.c \
         topology-synthetic.c \
+        topology-custom.c \
         topology-xml.c \
-        topology-xml-nolibxml.c \
-        bind.c \
-        bitmap.c \
-        misc.c
+        topology-xml-nolibxml.c
 ldflags =
 
 # Conditionally add to the sources and ldflags
 
 if HWLOC_HAVE_LIBXML2
+if HWLOC_XML_LIBXML_BUILD_STATIC
 sources += topology-xml-libxml.c
+else
+plugins_LTLIBRARIES += hwloc_xml_libxml.la
+hwloc_xml_libxml_la_SOURCES = topology-xml-libxml.c
+hwloc_xml_libxml_la_CFLAGS = $(AM_CFLAGS) $(HWLOC_LIBXML2_CFLAGS)
+hwloc_xml_libxml_la_LDFLAGS = $(plugins_ldflags) $(HWLOC_LIBXML2_LIBS)
+endif
 endif HWLOC_HAVE_LIBXML2
 
 if HWLOC_HAVE_LIBPCI
+if HWLOC_LIBPCI_BUILD_STATIC
 sources += topology-libpci.c
+else
+plugins_LTLIBRARIES += hwloc_libpci.la
+hwloc_libpci_la_SOURCES = topology-libpci.c
+hwloc_libpci_la_CFLAGS = $(AM_CFLAGS) $(HWLOC_PCI_CFLAGS)
+hwloc_libpci_la_LDFLAGS = $(plugins_ldflags) $(HWLOC_PCI_LIBS)
+endif
 endif HWLOC_HAVE_LIBPCI
 
 if HWLOC_HAVE_SOLARIS
@@ -79,6 +102,10 @@
 sources += topology-freebsd.c
 endif HWLOC_HAVE_FREEBSD
 
+if HWLOC_HAVE_CPUID
+sources += topology-x86.c
+endif HWLOC_HAVE_CPUID
+
 if HWLOC_HAVE_GCC
 ldflags += -no-undefined
 endif HWLOC_HAVE_GCC
@@ -106,13 +133,20 @@
 endif HWLOC_HAVE_MS_LIB
 endif HWLOC_HAVE_WINDOWS
 
-sources += topology-x86.c
-
 # Installable library
 
 libhwloc_la_SOURCES = $(sources)
-libhwloc_la_LDFLAGS = $(ldflags) $(libhwloc_so_versionflags) $(HWLOC_LIBS)
+libhwloc_la_LDFLAGS = $(ldflags) -version-info $(libhwloc_so_version) $(HWLOC_LIBS)
 
+if HWLOC_HAVE_PLUGINS
+AM_CPPFLAGS += $(LTDLINCL)
+libhwloc_la_LDFLAGS += -export-dynamic
+libhwloc_la_LIBADD = $(LIBLTDL)
+libhwloc_la_DEPENDENCIES = $(LTDLDEPS)
+
+SUBDIRS = libltdl
+endif
+
 # Embedded library (note the lack of a .so version number -- that
 # intentionally only appears in the installable library).  Also note
 # the lack of _LDFLAGS -- all libs are added by the upper layer (via
@@ -127,3 +161,11 @@
 xmldir = $(pkgdatadir)
 EXTRA_DIST += hwloc.dtd
 endif
+
+DISTCLEANFILES = static-components.h
+
+if HWLOC_HAVE_PLUGINS
+check_LTLIBRARIES = hwloc_fake.la
+hwloc_fake_la_SOURCES = topology-fake.c
+hwloc_fake_la_LDFLAGS = $(plugins_ldflags) -rpath /nowhere # force libtool to build a shared-library even it's check-only
+endif

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/base64.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/base64.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/base64.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,306 @@
+/*
+ * Copyright © 2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ *
+ * Modifications after import:
+ * - removed all #if
+ * - updated prototypes
+ * - updated #include
+ */
+
+/*	$OpenBSD: base64.c,v 1.5 2006/10/21 09:55:03 otto Exp $	*/
+
+/*
+ * Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software.  No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/net/base64.c */
+
+static const char Base64[] =
+	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char Pad64 = '=';
+
+/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
+   The following encoding technique is taken from RFC 1521 by Borenstein
+   and Freed.  It is reproduced here in a slightly edited form for
+   convenience.
+
+   A 65-character subset of US-ASCII is used, enabling 6 bits to be
+   represented per printable character. (The extra 65th character, "=",
+   is used to signify a special processing function.)
+
+   The encoding process represents 24-bit groups of input bits as output
+   strings of 4 encoded characters. Proceeding from left to right, a
+   24-bit input group is formed by concatenating 3 8-bit input groups.
+   These 24 bits are then treated as 4 concatenated 6-bit groups, each
+   of which is translated into a single digit in the base64 alphabet.
+
+   Each 6-bit group is used as an index into an array of 64 printable
+   characters. The character referenced by the index is placed in the
+   output string.
+
+                         Table 1: The Base64 Alphabet
+
+      Value Encoding  Value Encoding  Value Encoding  Value Encoding
+          0 A            17 R            34 i            51 z
+          1 B            18 S            35 j            52 0
+          2 C            19 T            36 k            53 1
+          3 D            20 U            37 l            54 2
+          4 E            21 V            38 m            55 3
+          5 F            22 W            39 n            56 4
+          6 G            23 X            40 o            57 5
+          7 H            24 Y            41 p            58 6
+          8 I            25 Z            42 q            59 7
+          9 J            26 a            43 r            60 8
+         10 K            27 b            44 s            61 9
+         11 L            28 c            45 t            62 +
+         12 M            29 d            46 u            63 /
+         13 N            30 e            47 v
+         14 O            31 f            48 w         (pad) =
+         15 P            32 g            49 x
+         16 Q            33 h            50 y
+
+   Special processing is performed if fewer than 24 bits are available
+   at the end of the data being encoded.  A full encoding quantum is
+   always completed at the end of a quantity.  When fewer than 24 input
+   bits are available in an input group, zero bits are added (on the
+   right) to form an integral number of 6-bit groups.  Padding at the
+   end of the data is performed using the '=' character.
+
+   Since all base64 input is an integral number of octets, only the
+         -------------------------------------------------                       
+   following cases can arise:
+   
+       (1) the final quantum of encoding input is an integral
+           multiple of 24 bits; here, the final unit of encoded
+	   output will be an integral multiple of 4 characters
+	   with no "=" padding,
+       (2) the final quantum of encoding input is exactly 8 bits;
+           here, the final unit of encoded output will be two
+	   characters followed by two "=" padding characters, or
+       (3) the final quantum of encoding input is exactly 16 bits;
+           here, the final unit of encoded output will be three
+	   characters followed by one "=" padding character.
+   */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <private/private.h>
+
+int
+hwloc_encode_to_base64(const char *src, size_t srclength, char *target, size_t targsize)
+{
+	size_t datalength = 0;
+	unsigned char input[3];
+	unsigned char output[4];
+	unsigned int i;
+
+	while (2 < srclength) {
+		input[0] = *src++;
+		input[1] = *src++;
+		input[2] = *src++;
+		srclength -= 3;
+
+		output[0] = input[0] >> 2;
+		output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+		output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+		output[3] = input[2] & 0x3f;
+
+		if (datalength + 4 > targsize)
+			return (-1);
+		target[datalength++] = Base64[output[0]];
+		target[datalength++] = Base64[output[1]];
+		target[datalength++] = Base64[output[2]];
+		target[datalength++] = Base64[output[3]];
+	}
+    
+	/* Now we worry about padding. */
+	if (0 != srclength) {
+		/* Get what's left. */
+		input[0] = input[1] = input[2] = '\0';
+		for (i = 0; i < srclength; i++)
+			input[i] = *src++;
+	
+		output[0] = input[0] >> 2;
+		output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
+		output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
+
+		if (datalength + 4 > targsize)
+			return (-1);
+		target[datalength++] = Base64[output[0]];
+		target[datalength++] = Base64[output[1]];
+		if (srclength == 1)
+			target[datalength++] = Pad64;
+		else
+			target[datalength++] = Base64[output[2]];
+		target[datalength++] = Pad64;
+	}
+	if (datalength >= targsize)
+		return (-1);
+	target[datalength] = '\0';	/* Returned value doesn't count \0. */
+	return (datalength);
+}
+
+/* skips all whitespace anywhere.
+   converts characters, four at a time, starting at (or after)
+   src from base - 64 numbers into three 8 bit bytes in the target area.
+   it returns the number of data bytes stored at the target, or -1 on error.
+ */
+
+int
+hwloc_decode_from_base64(char const *src, char *target, size_t targsize)
+{
+	unsigned int tarindex, state;
+	int ch;
+	char *pos;
+
+	state = 0;
+	tarindex = 0;
+
+	while ((ch = *src++) != '\0') {
+		if (isspace(ch))	/* Skip whitespace anywhere. */
+			continue;
+
+		if (ch == Pad64)
+			break;
+
+		pos = strchr(Base64, ch);
+		if (pos == 0) 		/* A non-base64 character. */
+			return (-1);
+
+		switch (state) {
+		case 0:
+			if (target) {
+				if (tarindex >= targsize)
+					return (-1);
+				target[tarindex] = (pos - Base64) << 2;
+			}
+			state = 1;
+			break;
+		case 1:
+			if (target) {
+				if (tarindex + 1 >= targsize)
+					return (-1);
+				target[tarindex]   |=  (pos - Base64) >> 4;
+				target[tarindex+1]  = ((pos - Base64) & 0x0f)
+							<< 4 ;
+			}
+			tarindex++;
+			state = 2;
+			break;
+		case 2:
+			if (target) {
+				if (tarindex + 1 >= targsize)
+					return (-1);
+				target[tarindex]   |=  (pos - Base64) >> 2;
+				target[tarindex+1]  = ((pos - Base64) & 0x03)
+							<< 6;
+			}
+			tarindex++;
+			state = 3;
+			break;
+		case 3:
+			if (target) {
+				if (tarindex >= targsize)
+					return (-1);
+				target[tarindex] |= (pos - Base64);
+			}
+			tarindex++;
+			state = 0;
+			break;
+		}
+	}
+
+	/*
+	 * We are done decoding Base-64 chars.  Let's see if we ended
+	 * on a byte boundary, and/or with erroneous trailing characters.
+	 */
+
+	if (ch == Pad64) {		/* We got a pad char. */
+		ch = *src++;		/* Skip it, get next. */
+		switch (state) {
+		case 0:		/* Invalid = in first position */
+		case 1:		/* Invalid = in second position */
+			return (-1);
+
+		case 2:		/* Valid, means one byte of info */
+			/* Skip any number of spaces. */
+			for (; ch != '\0'; ch = *src++)
+				if (!isspace(ch))
+					break;
+			/* Make sure there is another trailing = sign. */
+			if (ch != Pad64)
+				return (-1);
+			ch = *src++;		/* Skip the = */
+			/* Fall through to "single trailing =" case. */
+			/* FALLTHROUGH */
+
+		case 3:		/* Valid, means two bytes of info */
+			/*
+			 * We know this char is an =.  Is there anything but
+			 * whitespace after it?
+			 */
+			for (; ch != '\0'; ch = *src++)
+				if (!isspace(ch))
+					return (-1);
+
+			/*
+			 * Now make sure for cases 2 and 3 that the "extra"
+			 * bits that slopped past the last full byte were
+			 * zeros.  If we don't check them, they become a
+			 * subliminal channel.
+			 */
+			if (target && target[tarindex] != 0)
+				return (-1);
+		}
+	} else {
+		/*
+		 * We ended by seeing the end of the string.  Make sure we
+		 * have no partial bytes lying around.
+		 */
+		if (state != 0)
+			return (-1);
+	}
+
+	return (tarindex);
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/bind.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/bind.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/bind.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -67,16 +67,16 @@
     return -1;
 
   if (flags & HWLOC_CPUBIND_PROCESS) {
-    if (topology->set_thisproc_cpubind)
-      return topology->set_thisproc_cpubind(topology, set, flags);
+    if (topology->binding_hooks.set_thisproc_cpubind)
+      return topology->binding_hooks.set_thisproc_cpubind(topology, set, flags);
   } else if (flags & HWLOC_CPUBIND_THREAD) {
-    if (topology->set_thisthread_cpubind)
-      return topology->set_thisthread_cpubind(topology, set, flags);
+    if (topology->binding_hooks.set_thisthread_cpubind)
+      return topology->binding_hooks.set_thisthread_cpubind(topology, set, flags);
   } else {
-    if (topology->set_thisproc_cpubind)
-      return topology->set_thisproc_cpubind(topology, set, flags);
-    else if (topology->set_thisthread_cpubind)
-      return topology->set_thisthread_cpubind(topology, set, flags);
+    if (topology->binding_hooks.set_thisproc_cpubind)
+      return topology->binding_hooks.set_thisproc_cpubind(topology, set, flags);
+    else if (topology->binding_hooks.set_thisthread_cpubind)
+      return topology->binding_hooks.set_thisthread_cpubind(topology, set, flags);
   }
 
   errno = ENOSYS;
@@ -87,16 +87,16 @@
 hwloc_get_cpubind(hwloc_topology_t topology, hwloc_bitmap_t set, int flags)
 {
   if (flags & HWLOC_CPUBIND_PROCESS) {
-    if (topology->get_thisproc_cpubind)
-      return topology->get_thisproc_cpubind(topology, set, flags);
+    if (topology->binding_hooks.get_thisproc_cpubind)
+      return topology->binding_hooks.get_thisproc_cpubind(topology, set, flags);
   } else if (flags & HWLOC_CPUBIND_THREAD) {
-    if (topology->get_thisthread_cpubind)
-      return topology->get_thisthread_cpubind(topology, set, flags);
+    if (topology->binding_hooks.get_thisthread_cpubind)
+      return topology->binding_hooks.get_thisthread_cpubind(topology, set, flags);
   } else {
-    if (topology->get_thisproc_cpubind)
-      return topology->get_thisproc_cpubind(topology, set, flags);
-    else if (topology->get_thisthread_cpubind)
-      return topology->get_thisthread_cpubind(topology, set, flags);
+    if (topology->binding_hooks.get_thisproc_cpubind)
+      return topology->binding_hooks.get_thisproc_cpubind(topology, set, flags);
+    else if (topology->binding_hooks.get_thisthread_cpubind)
+      return topology->binding_hooks.get_thisthread_cpubind(topology, set, flags);
   }
 
   errno = ENOSYS;
@@ -110,8 +110,8 @@
   if (!set)
     return -1;
 
-  if (topology->set_proc_cpubind)
-    return topology->set_proc_cpubind(topology, pid, set, flags);
+  if (topology->binding_hooks.set_proc_cpubind)
+    return topology->binding_hooks.set_proc_cpubind(topology, pid, set, flags);
 
   errno = ENOSYS;
   return -1;
@@ -120,8 +120,8 @@
 int
 hwloc_get_proc_cpubind(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, int flags)
 {
-  if (topology->get_proc_cpubind)
-    return topology->get_proc_cpubind(topology, pid, set, flags);
+  if (topology->binding_hooks.get_proc_cpubind)
+    return topology->binding_hooks.get_proc_cpubind(topology, pid, set, flags);
 
   errno = ENOSYS;
   return -1;
@@ -135,8 +135,8 @@
   if (!set)
     return -1;
 
-  if (topology->set_thread_cpubind)
-    return topology->set_thread_cpubind(topology, tid, set, flags);
+  if (topology->binding_hooks.set_thread_cpubind)
+    return topology->binding_hooks.set_thread_cpubind(topology, tid, set, flags);
 
   errno = ENOSYS;
   return -1;
@@ -145,8 +145,8 @@
 int
 hwloc_get_thread_cpubind(hwloc_topology_t topology, hwloc_thread_t tid, hwloc_bitmap_t set, int flags)
 {
-  if (topology->get_thread_cpubind)
-    return topology->get_thread_cpubind(topology, tid, set, flags);
+  if (topology->binding_hooks.get_thread_cpubind)
+    return topology->binding_hooks.get_thread_cpubind(topology, tid, set, flags);
 
   errno = ENOSYS;
   return -1;
@@ -157,16 +157,16 @@
 hwloc_get_last_cpu_location(hwloc_topology_t topology, hwloc_bitmap_t set, int flags)
 {
   if (flags & HWLOC_CPUBIND_PROCESS) {
-    if (topology->get_thisproc_last_cpu_location)
-      return topology->get_thisproc_last_cpu_location(topology, set, flags);
+    if (topology->binding_hooks.get_thisproc_last_cpu_location)
+      return topology->binding_hooks.get_thisproc_last_cpu_location(topology, set, flags);
   } else if (flags & HWLOC_CPUBIND_THREAD) {
-    if (topology->get_thisthread_last_cpu_location)
-      return topology->get_thisthread_last_cpu_location(topology, set, flags);
+    if (topology->binding_hooks.get_thisthread_last_cpu_location)
+      return topology->binding_hooks.get_thisthread_last_cpu_location(topology, set, flags);
   } else {
-    if (topology->get_thisproc_last_cpu_location)
-      return topology->get_thisproc_last_cpu_location(topology, set, flags);
-    else if (topology->get_thisthread_last_cpu_location)
-      return topology->get_thisthread_last_cpu_location(topology, set, flags);
+    if (topology->binding_hooks.get_thisproc_last_cpu_location)
+      return topology->binding_hooks.get_thisproc_last_cpu_location(topology, set, flags);
+    else if (topology->binding_hooks.get_thisthread_last_cpu_location)
+      return topology->binding_hooks.get_thisthread_last_cpu_location(topology, set, flags);
   }
 
   errno = ENOSYS;
@@ -176,8 +176,8 @@
 int
 hwloc_get_proc_last_cpu_location(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_bitmap_t set, int flags)
 {
-  if (topology->get_proc_last_cpu_location)
-    return topology->get_proc_last_cpu_location(topology, pid, set, flags);
+  if (topology->binding_hooks.get_proc_last_cpu_location)
+    return topology->binding_hooks.get_proc_last_cpu_location(topology, pid, set, flags);
 
   errno = ENOSYS;
   return -1;
@@ -265,16 +265,16 @@
     return -1;
 
   if (flags & HWLOC_MEMBIND_PROCESS) {
-    if (topology->set_thisproc_membind)
-      return topology->set_thisproc_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.set_thisproc_membind)
+      return topology->binding_hooks.set_thisproc_membind(topology, nodeset, policy, flags);
   } else if (flags & HWLOC_MEMBIND_THREAD) {
-    if (topology->set_thisthread_membind)
-      return topology->set_thisthread_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.set_thisthread_membind)
+      return topology->binding_hooks.set_thisthread_membind(topology, nodeset, policy, flags);
   } else {
-    if (topology->set_thisproc_membind)
-      return topology->set_thisproc_membind(topology, nodeset, policy, flags);
-    else if (topology->set_thisthread_membind)
-      return topology->set_thisthread_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.set_thisproc_membind)
+      return topology->binding_hooks.set_thisproc_membind(topology, nodeset, policy, flags);
+    else if (topology->binding_hooks.set_thisthread_membind)
+      return topology->binding_hooks.set_thisthread_membind(topology, nodeset, policy, flags);
   }
 
   errno = ENOSYS;
@@ -300,16 +300,16 @@
 hwloc_get_membind_nodeset(hwloc_topology_t topology, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
 {
   if (flags & HWLOC_MEMBIND_PROCESS) {
-    if (topology->get_thisproc_membind)
-      return topology->get_thisproc_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.get_thisproc_membind)
+      return topology->binding_hooks.get_thisproc_membind(topology, nodeset, policy, flags);
   } else if (flags & HWLOC_MEMBIND_THREAD) {
-    if (topology->get_thisthread_membind)
-      return topology->get_thisthread_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.get_thisthread_membind)
+      return topology->binding_hooks.get_thisthread_membind(topology, nodeset, policy, flags);
   } else {
-    if (topology->get_thisproc_membind)
-      return topology->get_thisproc_membind(topology, nodeset, policy, flags);
-    else if (topology->get_thisthread_membind)
-      return topology->get_thisthread_membind(topology, nodeset, policy, flags);
+    if (topology->binding_hooks.get_thisproc_membind)
+      return topology->binding_hooks.get_thisproc_membind(topology, nodeset, policy, flags);
+    else if (topology->binding_hooks.get_thisthread_membind)
+      return topology->binding_hooks.get_thisthread_membind(topology, nodeset, policy, flags);
   }
 
   errno = ENOSYS;
@@ -339,8 +339,8 @@
   if (!nodeset)
     return -1;
 
-  if (topology->set_proc_membind)
-    return topology->set_proc_membind(topology, pid, nodeset, policy, flags);
+  if (topology->binding_hooks.set_proc_membind)
+    return topology->binding_hooks.set_proc_membind(topology, pid, nodeset, policy, flags);
 
   errno = ENOSYS;
   return -1;
@@ -365,8 +365,8 @@
 int
 hwloc_get_proc_membind_nodeset(hwloc_topology_t topology, hwloc_pid_t pid, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
 {
-  if (topology->get_proc_membind)
-    return topology->get_proc_membind(topology, pid, nodeset, policy, flags);
+  if (topology->binding_hooks.get_proc_membind)
+    return topology->binding_hooks.get_proc_membind(topology, pid, nodeset, policy, flags);
 
   errno = ENOSYS;
   return -1;
@@ -395,8 +395,8 @@
   if (!nodeset)
     return -1;
 
-  if (topology->set_area_membind)
-    return topology->set_area_membind(topology, addr, len, nodeset, policy, flags);
+  if (topology->binding_hooks.set_area_membind)
+    return topology->binding_hooks.set_area_membind(topology, addr, len, nodeset, policy, flags);
 
   errno = ENOSYS;
   return -1;
@@ -420,8 +420,8 @@
 int
 hwloc_get_area_membind_nodeset(hwloc_topology_t topology, const void *addr, size_t len, hwloc_nodeset_t nodeset, hwloc_membind_policy_t * policy, int flags)
 {
-  if (topology->get_area_membind)
-    return topology->get_area_membind(topology, addr, len, nodeset, policy, flags);
+  if (topology->binding_hooks.get_area_membind)
+    return topology->binding_hooks.get_area_membind(topology, addr, len, nodeset, policy, flags);
 
   errno = ENOSYS;
   return -1;
@@ -447,12 +447,12 @@
 hwloc_alloc_heap(hwloc_topology_t topology __hwloc_attribute_unused, size_t len)
 {
   void *p;
-#if defined(HAVE_GETPAGESIZE) && defined(HAVE_POSIX_MEMALIGN)
-  errno = posix_memalign(&p, getpagesize(), len);
+#if defined(hwloc_getpagesize) && defined(HAVE_POSIX_MEMALIGN)
+  errno = posix_memalign(&p, hwloc_getpagesize(), len);
   if (errno)
     p = NULL;
-#elif defined(HAVE_GETPAGESIZE) && defined(HAVE_MEMALIGN)
-  p = memalign(getpagesize(), len);
+#elif defined(hwloc_getpagesize) && defined(HAVE_MEMALIGN)
+  p = memalign(hwloc_getpagesize(), len);
 #else
   p = malloc(len);
 #endif
@@ -487,8 +487,8 @@
 void *
 hwloc_alloc(hwloc_topology_t topology, size_t len)
 {
-  if (topology->alloc)
-    return topology->alloc(topology, len);
+  if (topology->binding_hooks.alloc)
+    return topology->binding_hooks.alloc(topology, len);
   return hwloc_alloc_heap(topology, len);
 }
 
@@ -504,13 +504,13 @@
     goto fallback;
   }
 
-  if (topology->alloc_membind)
-    return topology->alloc_membind(topology, len, nodeset, policy, flags);
-  else if (topology->set_area_membind) {
+  if (topology->binding_hooks.alloc_membind)
+    return topology->binding_hooks.alloc_membind(topology, len, nodeset, policy, flags);
+  else if (topology->binding_hooks.set_area_membind) {
     p = hwloc_alloc(topology, len);
     if (!p)
       return NULL;
-    if (topology->set_area_membind(topology, p, len, nodeset, policy, flags) && flags & HWLOC_MEMBIND_STRICT) {
+    if (topology->binding_hooks.set_area_membind(topology, p, len, nodeset, policy, flags) && flags & HWLOC_MEMBIND_STRICT) {
       int error = errno;
       free(p);
       errno = error;
@@ -550,7 +550,223 @@
 int
 hwloc_free(hwloc_topology_t topology, void *addr, size_t len)
 {
-  if (topology->free_membind)
-    return topology->free_membind(topology, addr, len);
+  if (topology->binding_hooks.free_membind)
+    return topology->binding_hooks.free_membind(topology, addr, len);
   return hwloc_free_heap(topology, addr, len);
 }
+
+/*
+ * Empty binding hooks always returning success
+ */
+
+static int dontset_return_complete_cpuset(hwloc_topology_t topology, hwloc_cpuset_t set)
+{
+  hwloc_const_cpuset_t cpuset = hwloc_topology_get_complete_cpuset(topology);
+  if (cpuset) {
+    hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
+    return 0;
+  } else
+    return -1;
+}
+
+static int dontset_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_cpuset(topology, set);
+}
+static int dontset_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_cpuset(topology, set);
+}
+static int dontset_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_cpuset(topology, cpuset);
+}
+#ifdef hwloc_thread_t
+static int dontset_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_cpuset(topology, cpuset);
+}
+#endif
+
+static int dontset_return_complete_nodeset(hwloc_topology_t topology, hwloc_nodeset_t set, hwloc_membind_policy_t *policy)
+{
+  hwloc_const_nodeset_t nodeset = hwloc_topology_get_complete_nodeset(topology);
+  if (nodeset) {
+    hwloc_bitmap_copy(set, hwloc_topology_get_complete_nodeset(topology));
+    *policy = HWLOC_MEMBIND_DEFAULT;
+    return 0;
+  } else
+    return -1;
+}
+
+static int dontset_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_nodeset(topology, set, policy);
+}
+
+static int dontset_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_nodeset(topology, set, policy);
+}
+
+static int dontset_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_nodeset(topology, set, policy);
+}
+
+static int dontset_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return 0;
+}
+static int dontget_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
+{
+  return dontset_return_complete_nodeset(topology, set, policy);
+}
+
+static void * dontalloc_membind(hwloc_topology_t topology __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
+{
+  return malloc(size);
+}
+static int dontfree_membind(hwloc_topology_t topology __hwloc_attribute_unused, void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused)
+{
+  free(addr);
+  return 0;
+}
+
+static void hwloc_set_dummy_hooks(struct hwloc_binding_hooks *hooks,
+				  struct hwloc_topology_support *support __hwloc_attribute_unused)
+{
+  hooks->set_thisproc_cpubind = dontset_thisproc_cpubind;
+  hooks->get_thisproc_cpubind = dontget_thisproc_cpubind;
+  hooks->set_thisthread_cpubind = dontset_thisthread_cpubind;
+  hooks->get_thisthread_cpubind = dontget_thisthread_cpubind;
+  hooks->set_proc_cpubind = dontset_proc_cpubind;
+  hooks->get_proc_cpubind = dontget_proc_cpubind;
+#ifdef hwloc_thread_t
+  hooks->set_thread_cpubind = dontset_thread_cpubind;
+  hooks->get_thread_cpubind = dontget_thread_cpubind;
+#endif
+  hooks->get_thisproc_last_cpu_location = dontget_thisproc_cpubind; /* cpubind instead of last_cpu_location is ok */
+  hooks->get_thisthread_last_cpu_location = dontget_thisthread_cpubind; /* cpubind instead of last_cpu_location is ok */
+  hooks->get_proc_last_cpu_location = dontget_proc_cpubind; /* cpubind instead of last_cpu_location is ok */
+  /* TODO: get_thread_last_cpu_location */
+  hooks->set_thisproc_membind = dontset_thisproc_membind;
+  hooks->get_thisproc_membind = dontget_thisproc_membind;
+  hooks->set_thisthread_membind = dontset_thisthread_membind;
+  hooks->get_thisthread_membind = dontget_thisthread_membind;
+  hooks->set_proc_membind = dontset_proc_membind;
+  hooks->get_proc_membind = dontget_proc_membind;
+  hooks->set_area_membind = dontset_area_membind;
+  hooks->get_area_membind = dontget_area_membind;
+  hooks->alloc_membind = dontalloc_membind;
+  hooks->free_membind = dontfree_membind;
+}
+
+void
+hwloc_set_native_binding_hooks(struct hwloc_binding_hooks *hooks, struct hwloc_topology_support *support)
+{
+#    ifdef HWLOC_LINUX_SYS
+    hwloc_set_linuxfs_hooks(hooks, support);
+#    endif /* HWLOC_LINUX_SYS */
+
+#    ifdef HWLOC_AIX_SYS
+    hwloc_set_aix_hooks(hooks, support);
+#    endif /* HWLOC_AIX_SYS */
+
+#    ifdef HWLOC_OSF_SYS
+    hwloc_set_osf_hooks(hooks, support);
+#    endif /* HWLOC_OSF_SYS */
+
+#    ifdef HWLOC_SOLARIS_SYS
+    hwloc_set_solaris_hooks(hooks, support);
+#    endif /* HWLOC_SOLARIS_SYS */
+
+#    ifdef HWLOC_WIN_SYS
+    hwloc_set_windows_hooks(hooks, support);
+#    endif /* HWLOC_WIN_SYS */
+
+#    ifdef HWLOC_DARWIN_SYS
+    hwloc_set_darwin_hooks(hooks, support);
+#    endif /* HWLOC_DARWIN_SYS */
+
+#    ifdef HWLOC_FREEBSD_SYS
+    hwloc_set_freebsd_hooks(hooks, support);
+#    endif /* HWLOC_FREEBSD_SYS */
+
+#    ifdef HWLOC_HPUX_SYS
+    hwloc_set_hpux_hooks(hooks, support);
+#    endif /* HWLOC_HPUX_SYS */
+}
+
+/* If the represented system is actually not this system, use dummy binding hooks. */
+void
+hwloc_set_binding_hooks(struct hwloc_topology *topology)
+{
+  if (topology->is_thissystem) {
+    hwloc_set_native_binding_hooks(&topology->binding_hooks, &topology->support);
+    /* every hook not set above will return ENOSYS */
+  } else {
+    /* not this system, use dummy binding hooks that do nothing (but don't return ENOSYS) */
+    hwloc_set_dummy_hooks(&topology->binding_hooks, &topology->support);
+  }
+
+  /* if not is_thissystem, set_cpubind is fake
+   * and get_cpubind returns the whole system cpuset,
+   * so don't report that set/get_cpubind as supported
+   */
+  if (topology->is_thissystem) {
+#define DO(which,kind) \
+    if (topology->binding_hooks.kind) \
+      topology->support.which##bind->kind = 1;
+    DO(cpu,set_thisproc_cpubind);
+    DO(cpu,get_thisproc_cpubind);
+    DO(cpu,set_proc_cpubind);
+    DO(cpu,get_proc_cpubind);
+    DO(cpu,set_thisthread_cpubind);
+    DO(cpu,get_thisthread_cpubind);
+#ifdef hwloc_thread_t
+    DO(cpu,set_thread_cpubind);
+    DO(cpu,get_thread_cpubind);
+#endif
+    DO(cpu,get_thisproc_last_cpu_location);
+    DO(cpu,get_proc_last_cpu_location);
+    DO(cpu,get_thisthread_last_cpu_location);
+    DO(mem,set_thisproc_membind);
+    DO(mem,get_thisproc_membind);
+    DO(mem,set_thisthread_membind);
+    DO(mem,get_thisthread_membind);
+    DO(mem,set_proc_membind);
+    DO(mem,get_proc_membind);
+    DO(mem,set_area_membind);
+    DO(mem,get_area_membind);
+    DO(mem,alloc_membind);
+  }
+}

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/components.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/components.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/components.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,633 @@
+/*
+ * Copyright © 2009-2012 Inria.  All rights reserved.
+ * Copyright © 2012 Université Bordeau 1
+ * See COPYING in top-level directory.
+ */
+
+#include <private/autogen/config.h>
+#include <hwloc.h>
+#include <private/private.h>
+#include <private/xml.h>
+
+/* list of all registered discovery components, sorted by priority, higher priority first.
+ * noos is last because its priority is 0.
+ * others' priority is 10.
+ */
+static struct hwloc_disc_component * hwloc_disc_components = NULL;
+
+static unsigned hwloc_components_users = 0; /* first one initializes, last ones destroys */
+
+static int hwloc_components_verbose = 0;
+#ifdef HWLOC_HAVE_PLUGINS
+static int hwloc_plugins_verbose = 0;
+#endif
+
+#ifdef HWLOC_WIN_SYS
+/* Basic mutex on top of InterlockedCompareExchange() on windows,
+ * Far from perfect, but easy to maintain, and way enough given that this code will never be needed for real. */
+#include <windows.h>
+static LONG hwloc_components_mutex = 0;
+#define HWLOC_COMPONENTS_LOCK() do {						\
+  while (InterlockedCompareExchange(&hwloc_components_mutex, 1, 0) != 0)	\
+    SwitchToThread();								\
+} while (0)
+#define HWLOC_COMPONENTS_UNLOCK() do {						\
+  assert(hwloc_components_mutex == 1);						\
+  hwloc_components_mutex = 0;							\
+} while (0)
+
+#elif defined HWLOC_HAVE_PTHREAD_MUTEX
+/* pthread mutex if available (except on windows) */
+#include <pthread.h>
+static pthread_mutex_t hwloc_components_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define HWLOC_COMPONENTS_LOCK() pthread_mutex_lock(&hwloc_components_mutex)
+#define HWLOC_COMPONENTS_UNLOCK() pthread_mutex_unlock(&hwloc_components_mutex)
+
+#else /* HWLOC_WIN_SYS || HWLOC_HAVE_PTHREAD_MUTEX */
+#error No mutex implementation available
+#endif
+
+
+#ifdef HWLOC_HAVE_PLUGINS
+
+#include <ltdl.h>
+
+/* array of pointers to dynamically loaded plugins */
+static struct hwloc__plugin_desc {
+  char *name;
+  struct hwloc_component *component;
+  char *filename;
+  lt_dlhandle handle;
+  struct hwloc__plugin_desc *next;
+} *hwloc_plugins = NULL;
+
+static int
+hwloc__dlforeach_cb(const char *filename, void *_data __hwloc_attribute_unused)
+{
+  const char *basename;
+  lt_dlhandle handle;
+  char *componentsymbolname = NULL;
+  struct hwloc_component *component;
+  struct hwloc__plugin_desc *desc;
+
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Plugin dlforeach found `%s'\n", filename);
+
+  basename = strrchr(filename, '/');
+  if (!basename)
+    basename = filename;
+  else
+    basename++;
+
+  /* dlopen and get the component structure */
+  handle = lt_dlopenext(filename);
+  if (!handle) {
+    if (hwloc_plugins_verbose)
+      fprintf(stderr, "Failed to load plugin: %s\n", lt_dlerror());
+    goto out;
+  }
+  componentsymbolname = malloc(6+strlen(basename)+10+1);
+  sprintf(componentsymbolname, "%s_component", basename);
+  component = lt_dlsym(handle, componentsymbolname);
+  if (!component) {
+    if (hwloc_plugins_verbose)
+      fprintf(stderr, "Failed to find component symbol `%s'\n",
+	      componentsymbolname);
+    goto out_with_handle;
+  }
+  if (component->abi != HWLOC_COMPONENT_ABI) {
+    if (hwloc_plugins_verbose)
+      fprintf(stderr, "Plugin symbol ABI %u instead of %u\n",
+	      component->abi, HWLOC_COMPONENT_ABI);
+    goto out_with_handle;
+  }
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Plugin contains expected symbol `%s'\n",
+	    componentsymbolname);
+  free(componentsymbolname);
+  componentsymbolname = NULL;
+
+  if (HWLOC_COMPONENT_TYPE_DISC == component->type) {
+    if (strncmp(basename, "hwloc_", 6)) {
+      if (hwloc_plugins_verbose)
+	fprintf(stderr, "Plugin name `%s' doesn't match its type DISCOVERY\n", basename);
+      goto out_with_handle;
+    }
+  } else if (HWLOC_COMPONENT_TYPE_XML == component->type) {
+    if (strncmp(basename, "hwloc_xml_", 10)) {
+      if (hwloc_plugins_verbose)
+	fprintf(stderr, "Plugin name `%s' doesn't match its type XML\n", basename);
+      goto out_with_handle;
+    }
+  } else {
+    if (hwloc_plugins_verbose)
+      fprintf(stderr, "Plugin name `%s' has invalid type %u\n",
+	      basename, (unsigned) component->type);
+    goto out_with_handle;
+  }
+
+  /* allocate a plugin_desc and queue it */
+  desc = malloc(sizeof(*desc));
+  if (!desc)
+    goto out_with_handle;
+  desc->name = strdup(basename);
+  desc->filename = strdup(filename);
+  desc->component = component;
+  desc->handle = handle;
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Plugin descriptor `%s' ready\n", basename);
+
+  desc->next = hwloc_plugins;
+  hwloc_plugins = desc;
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Plugin descriptor `%s' queued\n", basename);
+  return 0;
+
+ out_with_handle:
+  lt_dlclose(handle);
+  free(componentsymbolname); /* NULL if already freed */
+ out:
+  return 0;
+}
+
+static void
+hwloc_plugins_exit(void)
+{
+  struct hwloc__plugin_desc *desc, *next;
+
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Closing all plugins\n");
+
+  desc = hwloc_plugins;
+  while (desc) {
+    next = desc->next;
+    lt_dlclose(desc->handle);
+    free(desc->name);
+    free(desc->filename);
+    free(desc);
+    desc = next;
+  }
+  hwloc_plugins = NULL;
+
+  lt_dlexit();
+}
+
+static int
+hwloc_plugins_init(void)
+{
+  char *verboseenv;
+  char *path = HWLOC_PLUGINS_DIR;
+  char *env;
+  int err;
+
+  verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
+  hwloc_plugins_verbose = verboseenv ? atoi(verboseenv) : 0;
+
+  err = lt_dlinit();
+  if (err)
+    goto out;
+
+  env = getenv("HWLOC_PLUGINS_PATH");
+  if (env)
+    path = env;
+
+  hwloc_plugins = NULL;
+
+  if (hwloc_plugins_verbose)
+    fprintf(stderr, "Starting plugin dlforeach in %s\n", path);
+  err = lt_dlforeachfile(path, hwloc__dlforeach_cb, NULL);
+  if (err)
+    goto out_with_init;
+
+  return 0;
+
+ out_with_init:
+  hwloc_plugins_exit();
+ out:
+  return -1;
+}
+
+#endif /* HWLOC_HAVE_PLUGINS */
+
+static const char *
+hwloc_disc_component_type_string(hwloc_disc_component_type_t type)
+{
+  switch (type) {
+  case HWLOC_DISC_COMPONENT_TYPE_CPU: return "cpu";
+  case HWLOC_DISC_COMPONENT_TYPE_GLOBAL: return "global";
+  case HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL: return "additional";
+  default: return "Unknown";
+  }
+}
+
+static int
+hwloc_disc_component_register(struct hwloc_disc_component *component,
+			      const char *filename)
+{
+  struct hwloc_disc_component **prev;
+
+  prev = &hwloc_disc_components;
+  while (NULL != *prev) {
+    if (!strcmp((*prev)->name, component->name)) {
+      if (hwloc_components_verbose)
+	fprintf(stderr, "Multiple `%s' components, only registering the first one\n",
+		component->name);
+      return -1;
+    }
+    prev = &((*prev)->next);
+  }
+  if (hwloc_components_verbose)
+    fprintf(stderr, "Registered %s component `%s' with priority %u (%s%s)\n",
+	    hwloc_disc_component_type_string(component->type), component->name, component->priority,
+	    filename ? "from plugin " : "statically build", filename ? filename : "");
+
+  prev = &hwloc_disc_components;
+  while (NULL != *prev) {
+    if ((*prev)->priority < component->priority)
+      break;
+    prev = &((*prev)->next);
+  }
+  component->next = *prev;
+  *prev = component;
+  return 0;
+}
+
+#include <static-components.h>
+
+void
+hwloc_components_init(struct hwloc_topology *topology __hwloc_attribute_unused)
+{
+#ifdef HWLOC_HAVE_PLUGINS
+  struct hwloc__plugin_desc *desc;
+#endif
+  char *verboseenv;
+  unsigned i;
+
+  HWLOC_COMPONENTS_LOCK();
+  assert((unsigned) -1 != hwloc_components_users);
+  if (0 != hwloc_components_users++) {
+    HWLOC_COMPONENTS_UNLOCK();
+    goto ok;
+  }
+
+  verboseenv = getenv("HWLOC_COMPONENTS_VERBOSE");
+  hwloc_components_verbose = verboseenv ? atoi(verboseenv) : 0;
+
+#ifdef HWLOC_HAVE_PLUGINS
+  hwloc_plugins_init();
+#endif
+
+  /* hwloc_static_components is created by configure in static-components.h */
+  for(i=0; NULL != hwloc_static_components[i]; i++)
+    if (HWLOC_COMPONENT_TYPE_DISC == hwloc_static_components[i]->type)
+      hwloc_disc_component_register(hwloc_static_components[i]->data, NULL);
+    else if (HWLOC_COMPONENT_TYPE_XML == hwloc_static_components[i]->type)
+      hwloc_xml_callbacks_register(hwloc_static_components[i]->data);
+    else
+      assert(0);
+
+  /* dynamic plugins */
+#ifdef HWLOC_HAVE_PLUGINS
+  for(desc = hwloc_plugins; NULL != desc; desc = desc->next)
+    if (HWLOC_COMPONENT_TYPE_DISC == desc->component->type)
+      hwloc_disc_component_register(desc->component->data, desc->filename);
+    else if (HWLOC_COMPONENT_TYPE_XML == desc->component->type)
+      hwloc_xml_callbacks_register(desc->component->data);
+    else
+      assert(0);
+#endif
+
+  HWLOC_COMPONENTS_UNLOCK();
+
+ ok:
+  topology->backends = NULL;
+}
+
+static struct hwloc_disc_component *
+hwloc_disc_component_find(int type /* hwloc_disc_component_type_t or -1 if any */,
+			       const char *name /* name of NULL if any */)
+{
+  struct hwloc_disc_component *comp = hwloc_disc_components;
+  while (NULL != comp) {
+    if ((-1 == type || type == (int) comp->type)
+       && (NULL == name || !strcmp(name, comp->name)))
+      return comp;
+    comp = comp->next;
+  }
+  return NULL;
+}
+
+/* used by set_xml(), set_synthetic(), ... environment variables, ... to force the first backend */
+int
+hwloc_disc_component_force_enable(struct hwloc_topology *topology,
+				  int envvar_forced,
+				  int type, const char *name,
+				  const void *data1, const void *data2, const void *data3)
+{
+  struct hwloc_disc_component *comp;
+  struct hwloc_backend *backend;
+
+  comp = hwloc_disc_component_find(type, name);
+  if (!comp) {
+    errno = ENOSYS;
+    return -1;
+  }
+
+  backend = comp->instantiate(comp, data1, data2, data3);
+  if (backend) {
+    backend->envvar_forced = envvar_forced;
+    if (topology->backends)
+      hwloc_backends_reset(topology);
+    return hwloc_backend_enable(topology, backend);
+  } else
+    return -1;
+}
+
+static int
+hwloc_disc_component_try_enable(struct hwloc_topology *topology,
+				struct hwloc_disc_component *comp,
+				const char *comparg,
+				unsigned *excludes,
+				int envvar_forced,
+				int verbose_errors)
+{
+  struct hwloc_backend *backend;
+  int err;
+
+  if ((*excludes) & comp->type) {
+    if (hwloc_components_verbose)
+      fprintf(stderr, "Excluding %s component `%s', conflicts with excludes 0x%x\n",
+	      hwloc_disc_component_type_string(comp->type), comp->name, *excludes);
+    return -1;
+  }
+
+  backend = comp->instantiate(comp, comparg, NULL, NULL);
+  if (!backend) {
+    if (verbose_errors)
+      fprintf(stderr, "Failed to instantiate component `%s'\n", comp->name);
+    return -1;
+  }
+
+  backend->envvar_forced = envvar_forced;
+  err = hwloc_backend_enable(topology, backend);
+  if (err < 0)
+    return -1;
+
+  *excludes |= comp->excludes;
+
+  return 0;
+}
+
+void
+hwloc_disc_components_enable_others(struct hwloc_topology *topology)
+{
+  struct hwloc_disc_component *comp;
+  unsigned excludes = 0;
+  int tryall = 1;
+  char *env;
+
+  /* we have either no backends, or a single one, use its exclude */
+  if (topology->backends) {
+    excludes = topology->backends->component->excludes;
+    assert(!topology->backends->next);
+  }
+
+  env = getenv("HWLOC_COMPONENTS");
+  if (env) {
+    size_t s;
+
+    while (*env) {
+      s = strcspn(env, ",");
+      if (s) {
+	char *arg;
+	char c;
+	/* save the last char and replace with \0 */
+	c = env[s];
+	env[s] = '\0';
+
+	if (!strcmp(env, "stop")) {
+	  tryall = 0;
+	  break;
+	}
+
+	arg = strchr(env, '=');
+	if (arg) {
+	  *arg = '\0';
+	  arg++;
+	}
+
+	comp = hwloc_disc_component_find(-1, env);
+	if (comp) {
+	  hwloc_disc_component_try_enable(topology, comp, arg, &excludes, 1 /* envvar forced */, 1 /* envvar forced need warnings on conflicts */);
+	} else {
+	  fprintf(stderr, "Cannot find component `%s'\n", env);
+	}
+
+	/* restore last char */
+	env[s] = c;
+      }
+
+      env += s;
+      if (*env)
+	/* Skip comma */
+	env++;
+    }
+  }
+
+  if (tryall) {
+    comp = hwloc_disc_components;
+    while (NULL != comp) {
+      hwloc_disc_component_try_enable(topology, comp, NULL, &excludes, 0 /* defaults, not envvar forced */, 0 /* defaults don't need warnings on conflicts */);
+      comp = comp->next;
+    }
+  }
+}
+
+void
+hwloc_components_destroy_all(struct hwloc_topology *topology __hwloc_attribute_unused)
+{
+  HWLOC_COMPONENTS_LOCK();
+  assert(0 != hwloc_components_users);
+  if (0 != --hwloc_components_users) {
+    HWLOC_COMPONENTS_UNLOCK();
+    return;
+  }
+
+  /* no need to unlink/free the list of components, they'll be unloaded below */
+
+  hwloc_disc_components = NULL;
+  hwloc_xml_callbacks_reset();
+
+#ifdef HWLOC_HAVE_PLUGINS
+  hwloc_plugins_exit();
+#endif
+
+  HWLOC_COMPONENTS_UNLOCK();
+}
+
+struct hwloc_backend *
+hwloc_backend_alloc(struct hwloc_disc_component *component)
+{
+  struct hwloc_backend * backend = malloc(sizeof(*backend));
+  if (!backend) {
+    errno = ENOMEM;
+    return NULL;
+  }
+  backend->component = component;
+  backend->flags = 0;
+  backend->discover = NULL;
+  backend->get_obj_cpuset = NULL;
+  backend->notify_new_object = NULL;
+  backend->disable = NULL;
+  backend->is_custom = 0;
+  backend->is_thissystem = -1;
+  backend->next = NULL;
+  backend->envvar_forced = 0;
+  return backend;
+}
+
+static void
+hwloc_backend_disable(struct hwloc_backend *backend)
+{
+  if (backend->disable)
+    backend->disable(backend);
+  free(backend);
+}
+
+int
+hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend)
+{
+  struct hwloc_backend **pprev;
+
+  /* make sure we didn't already enable this backend, we don't want duplicates */
+  pprev = &topology->backends;
+  while (NULL != *pprev) {
+    if ((*pprev)->component == backend->component) {
+      if (hwloc_components_verbose)
+	fprintf(stderr, "Cannot enable %s component `%s' twice\n",
+		hwloc_disc_component_type_string(backend->component->type), backend->component->name);
+      hwloc_backend_disable(backend);
+      errno = EBUSY;
+      return -1;
+    }
+    pprev = &((*pprev)->next);
+  }
+
+  if (hwloc_components_verbose)
+    fprintf(stderr, "Enabling %s component `%s'\n",
+	    hwloc_disc_component_type_string(backend->component->type), backend->component->name);
+
+  /* enqueue at the end */
+  pprev = &topology->backends;
+  while (NULL != *pprev)
+    pprev = &((*pprev)->next);
+  backend->next = *pprev;
+  *pprev = backend;
+
+  backend->topology = topology;
+
+  return 0;
+}
+
+void
+hwloc_backends_is_thissystem(struct hwloc_topology *topology)
+{
+  struct hwloc_backend *backend;
+  char *local_env;
+
+  /* Apply is_thissystem topology flag before we enforce envvar backends.
+   * If the application changed the backend with set_foo(),
+   * it may use set_flags() update the is_thissystem flag here.
+   * If it changes the backend with environment variables below,
+   * it may use HWLOC_THISSYSTEM envvar below as well.
+   */
+
+  topology->is_thissystem = 1;
+
+  /* apply thissystem from normally-given backends (envvar_forced=0, either set_foo() or defaults) */
+  backend = topology->backends;
+  while (backend != NULL) {
+    if (backend->envvar_forced == 0 && backend->is_thissystem != -1) {
+      assert(backend->is_thissystem == 0);
+      topology->is_thissystem = 0;
+    }
+    backend = backend->next;
+  }
+
+  /* override set_foo() with flags */
+  if (topology->flags & HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM)
+    topology->is_thissystem = 1;
+
+  /* now apply envvar-forced backend (envvar_forced=1) */
+  backend = topology->backends;
+  while (backend != NULL) {
+    if (backend->envvar_forced == 1 && backend->is_thissystem != -1) {
+      assert(backend->is_thissystem == 0);
+      topology->is_thissystem = 0;
+    }
+    backend = backend->next;
+  }
+
+  /* override with envvar-given flag */
+  local_env = getenv("HWLOC_THISSYSTEM");
+  if (local_env)
+    topology->is_thissystem = atoi(local_env);
+}
+
+int
+hwloc_backends_get_obj_cpuset(struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset)
+{
+  struct hwloc_topology *topology = caller->topology;
+  struct hwloc_backend *backend = topology->backends;
+  /* use the first backend's get_obj_cpuset callback */
+  while (backend != NULL) {
+    if (backend->get_obj_cpuset)
+      return backend->get_obj_cpuset(backend, caller, obj, cpuset);
+    backend = backend->next;
+  }
+  return -1;
+}
+
+int
+hwloc_backends_notify_new_object(struct hwloc_backend *caller, struct hwloc_obj *obj)
+{
+  struct hwloc_backend *backend;
+  int res = 0;
+
+  backend = caller->topology->backends;
+  while (NULL != backend) {
+    if (backend != caller && backend->notify_new_object)
+      res += backend->notify_new_object(backend, caller, obj);
+    backend = backend->next;
+  }
+
+  return res;
+}
+
+void
+hwloc_backends_disable_all(struct hwloc_topology *topology)
+{
+  struct hwloc_backend *backend;
+
+  while (NULL != (backend = topology->backends)) {
+    struct hwloc_backend *next = backend->next;
+    if (hwloc_components_verbose)
+      fprintf(stderr, "Disabling %s component `%s'\n",
+	      hwloc_disc_component_type_string(backend->component->type), backend->component->name);
+    hwloc_backend_disable(backend);
+    topology->backends = next;
+  }
+  topology->backends = NULL;
+}
+
+void
+hwloc_backends_reset(struct hwloc_topology *topology)
+{
+  hwloc_backends_disable_all(topology);
+  if (topology->is_loaded) {
+    hwloc_topology_clear(topology);
+    hwloc_distances_destroy(topology);
+    hwloc_topology_setup_defaults(topology);
+    topology->is_loaded = 0;
+  }
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/distances.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/distances.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/distances.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2011 inria.  All rights reserved.
+ * Copyright © 2010-2012 Inria.  All rights reserved.
  * Copyright © 2011-2012 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -221,7 +221,7 @@
   } else {
     /* parse a comma separated list of distances */
     for(i=0; i<nbobjs*nbobjs; i++) {
-      distances[i] = atof(tmp);
+      distances[i] = (float) atof(tmp);
       next = strchr(tmp, ',');
       if (next) {
         tmp = next+1;
@@ -549,6 +549,10 @@
   }
   relative_depth = objs[0]->depth - root->depth; /* this assume that we have distances between objects of the same level */
 
+  if (nbobjs != hwloc_get_nbobjs_inside_cpuset_by_depth(topology, root->cpuset, root->depth + relative_depth))
+    /* the root does not cover the right number of objects, maybe we failed to insert a root (bad intersect or so). */
+    return;
+
   /* get the logical index offset, it's the min of all logical indexes */
   minl = UINT_MAX;
   for(i=0; i<nbobjs; i++)
@@ -927,7 +931,7 @@
   unsigned nbobjs;
   struct hwloc_os_distances_s * osdist;
   char *env;
-  float accuracies[5] = { 0.0, 0.01, 0.02, 0.05, 0.1 };
+  float accuracies[5] = { 0.0f, 0.01f, 0.02f, 0.05f, 0.1f };
   unsigned nbaccuracies = 5;
   hwloc_obj_t group_obj;
   int verbose = 0;
@@ -950,7 +954,7 @@
   } else if (strcmp(env, "try")) {
     /* use the given value */
     nbaccuracies = 1;
-    accuracies[0] = atof(env);
+    accuracies[0] = (float) atof(env);
   } /* otherwise try all values */
 
 #ifdef HWLOC_DEBUG

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/hwloc.dtd
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/hwloc.dtd	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/hwloc.dtd	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,14 @@
+<!--
+  Copyright © 2009      CNRS
+  Copyright © 2009-2012 Inria.  All rights reserved.
+  Copyright © 2009-2011 Université Bordeaux 1.
+  See COPYING in top-level directory.
+ -->
+
 <!ELEMENT topology (object)+>
 <!ELEMENT root (object)+>
 
-<!ELEMENT object (page_type*,info*,distances*,object*)>
+<!ELEMENT object (page_type*,info*,distances*,userdata*,object*)>
 <!ATTLIST object type (System | Machine | Misc | Group | NUMANode | Socket| Cache | Core | PU | Bridge | PCIDev | OSDev) #REQUIRED>
 <!ATTLIST object os_level CDATA "-1" >
 <!ATTLIST object os_index CDATA "-1" >
@@ -43,3 +50,8 @@
 
 <!ELEMENT latency EMPTY>
 <!ATTLIST latency value CDATA #REQUIRED>
+
+<!ELEMENT userdata (#PCDATA)>
+<!ATTLIST userdata name CDATA "" >
+<!ATTLIST userdata length CDATA "0" >
+<!ATTLIST userdata encoding CDATA "" >

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/misc.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/misc.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/misc.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -91,6 +91,10 @@
   if (uname(&utsname) < 0)
     return;
 
+  if (hwloc_obj_get_info_by_name(topology->levels[0][0], "OSName"))
+    /* don't annotate twice */
+    return;
+
   hwloc_obj_add_info(topology->levels[0][0], "OSName", utsname.sysname);
   hwloc_obj_add_info(topology->levels[0][0], "OSRelease", utsname.release);
   hwloc_obj_add_info(topology->levels[0][0], "OSVersion", utsname.version);

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-aix.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-aix.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-aix.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -613,7 +613,7 @@
 	obj->memory.page_types_len = 2;
 	obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types));
 	memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types));
-	obj->memory.page_types[0].size = getpagesize();
+	obj->memory.page_types[0].size = hwloc_getpagesize();
 #ifdef HAVE__SC_LARGE_PAGESIZE
 	obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE);
 #endif
@@ -674,10 +674,18 @@
   rs_free(rad);
 }
 
-void
-hwloc_look_aix(struct hwloc_topology *topology)
+static int
+hwloc_look_aix(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   int i;
+
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
   /* TODO: R_LGPGDEF/R_LGPGFREE for large pages */
 
   hwloc_debug("Note: SMPSDL is at %d\n", rs_getinfo(NULL, R_SMPSDL, 0));
@@ -739,50 +747,84 @@
     }
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "AIX");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_aix_hooks(struct hwloc_topology *topology)
+hwloc_set_aix_hooks(struct hwloc_binding_hooks *hooks,
+		    struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
-  topology->set_proc_cpubind = hwloc_aix_set_proc_cpubind;
-  topology->get_proc_cpubind = hwloc_aix_get_proc_cpubind;
+  hooks->set_proc_cpubind = hwloc_aix_set_proc_cpubind;
+  hooks->get_proc_cpubind = hwloc_aix_get_proc_cpubind;
 #ifdef R_THREAD
 #ifdef HWLOC_HAVE_PTHREAD_GETTHRDS_NP
-  topology->set_thread_cpubind = hwloc_aix_set_thread_cpubind;
-  topology->get_thread_cpubind = hwloc_aix_get_thread_cpubind;
+  hooks->set_thread_cpubind = hwloc_aix_set_thread_cpubind;
+  hooks->get_thread_cpubind = hwloc_aix_get_thread_cpubind;
 #endif /* HWLOC_HAVE_PTHREAD_GETTHRDS_NP */
 #endif /* R_THREAD */
-  topology->set_thisproc_cpubind = hwloc_aix_set_thisproc_cpubind;
-  topology->get_thisproc_cpubind = hwloc_aix_get_thisproc_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_aix_set_thisproc_cpubind;
+  hooks->get_thisproc_cpubind = hwloc_aix_get_thisproc_cpubind;
 #ifdef R_THREAD
-  topology->set_thisthread_cpubind = hwloc_aix_set_thisthread_cpubind;
-  topology->get_thisthread_cpubind = hwloc_aix_get_thisthread_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_aix_set_thisthread_cpubind;
+  hooks->get_thisthread_cpubind = hwloc_aix_get_thisthread_cpubind;
 #endif /* R_THREAD */
-  topology->get_thisthread_last_cpu_location = hwloc_aix_get_thisthread_last_cpu_location;
+  hooks->get_thisthread_last_cpu_location = hwloc_aix_get_thisthread_last_cpu_location;
   /* TODO: get_last_cpu_location: mycpu() only works for the current thread? */
 #ifdef P_DEFAULT
-  topology->set_proc_membind = hwloc_aix_set_proc_membind;
-  topology->get_proc_membind = hwloc_aix_get_proc_membind;
+  hooks->set_proc_membind = hwloc_aix_set_proc_membind;
+  hooks->get_proc_membind = hwloc_aix_get_proc_membind;
 #ifdef R_THREAD
 #if 0 /* def HWLOC_HAVE_PTHREAD_GETTHRDS_NP */
   /* Does it really make sense to set the memory binding of another thread? */
-  topology->set_thread_membind = hwloc_aix_set_thread_membind;
-  topology->get_thread_membind = hwloc_aix_get_thread_membind;
+  hooks->set_thread_membind = hwloc_aix_set_thread_membind;
+  hooks->get_thread_membind = hwloc_aix_get_thread_membind;
 #endif /* HWLOC_HAVE_PTHREAD_GETTHRDS_NP */
 #endif /* R_THREAD */
-  topology->set_thisproc_membind = hwloc_aix_set_thisproc_membind;
-  topology->get_thisproc_membind = hwloc_aix_get_thisproc_membind;
+  hooks->set_thisproc_membind = hwloc_aix_set_thisproc_membind;
+  hooks->get_thisproc_membind = hwloc_aix_get_thisproc_membind;
 #ifdef R_THREAD
-  topology->set_thisthread_membind = hwloc_aix_set_thisthread_membind;
-  topology->get_thisthread_membind = hwloc_aix_get_thisthread_membind;
+  hooks->set_thisthread_membind = hwloc_aix_set_thisthread_membind;
+  hooks->get_thisthread_membind = hwloc_aix_get_thisthread_membind;
 #endif /* R_THREAD */
-  /* topology->set_area_membind = hwloc_aix_set_area_membind; */
+  /* hooks->set_area_membind = hwloc_aix_set_area_membind; */
   /* get_area_membind is not available */
-  topology->alloc_membind = hwloc_aix_alloc_membind;
-  topology->alloc = hwloc_alloc_mmap;
-  topology->free_membind = hwloc_free_mmap;
-  topology->support.membind->firsttouch_membind = 1;
-  topology->support.membind->bind_membind = 1;
-  topology->support.membind->interleave_membind = 1;
+  hooks->alloc_membind = hwloc_aix_alloc_membind;
+  hooks->alloc = hwloc_alloc_mmap;
+  hooks->free_membind = hwloc_free_mmap;
+  support->membind->firsttouch_membind = 1;
+  support->membind->bind_membind = 1;
+  support->membind->interleave_membind = 1;
 #endif /* P_DEFAULT */
 }
+
+static struct hwloc_backend *
+hwloc_aix_component_instantiate(struct hwloc_disc_component *component,
+				const void *_data1 __hwloc_attribute_unused,
+				const void *_data2 __hwloc_attribute_unused,
+				const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_aix;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_aix_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "aix",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_aix_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_aix_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_aix_disc_component
+};

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-custom.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-custom.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-custom.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2011-2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#include <private/autogen/config.h>
+#include <hwloc.h>
+#include <private/private.h>
+
+hwloc_obj_t
+hwloc_custom_insert_group_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, int groupdepth)
+{
+  hwloc_obj_t obj = hwloc_alloc_setup_object(HWLOC_OBJ_GROUP, -1);
+  obj->attr->group.depth = groupdepth;
+
+  /* must be called between set_custom() and load(), so there's a single backend, the custom one */
+  if (topology->is_loaded || !topology->backends || !topology->backends->is_custom) {
+    errno = EINVAL;
+    return NULL;
+  }
+
+  hwloc_insert_object_by_parent(topology, parent, obj);
+
+  return obj;
+}
+
+int
+hwloc_custom_insert_topology(struct hwloc_topology *newtopology,
+			     struct hwloc_obj *newparent,
+			     struct hwloc_topology *oldtopology,
+			     struct hwloc_obj *oldroot)
+{
+  /* must be called between set_custom() and load(), so there's a single backend, the custom one */
+  if (newtopology->is_loaded || !newtopology->backends || !newtopology->backends->is_custom) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  if (!oldtopology->is_loaded) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  hwloc__duplicate_objects(newtopology, newparent, oldroot ? oldroot : oldtopology->levels[0][0]);
+  return 0;
+}
+
+static int
+hwloc_look_custom(struct hwloc_backend *backend)
+{
+  struct hwloc_topology *topology = backend->topology;
+
+  assert(!topology->levels[0][0]->cpuset);
+
+  if (!topology->levels[0][0]->first_child) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  topology->levels[0][0]->type = HWLOC_OBJ_SYSTEM;
+  return 1;
+}
+
+static struct hwloc_backend *
+hwloc_custom_component_instantiate(struct hwloc_disc_component *component,
+				   const void *_data1 __hwloc_attribute_unused,
+				   const void *_data2 __hwloc_attribute_unused,
+				   const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_custom;
+  backend->is_custom = 1;
+  backend->is_thissystem = 0;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_custom_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  "custom",
+  HWLOC_DISC_COMPONENT_TYPE_CPU | HWLOC_DISC_COMPONENT_TYPE_GLOBAL | HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL,
+  hwloc_custom_component_instantiate,
+  30,
+  NULL
+};
+
+const struct hwloc_component hwloc_custom_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_custom_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-darwin.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-darwin.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-darwin.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux 1
+ * Copyright © 2009-2012 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.
  */
@@ -22,9 +22,10 @@
 #include <private/private.h>
 #include <private/debug.h>
 
-void
-hwloc_look_darwin(struct hwloc_topology *topology)
+static int
+hwloc_look_darwin(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   int64_t _nprocs;
   unsigned nprocs;
   int64_t _npackages;
@@ -36,14 +37,25 @@
   int64_t l2cachesize;
   int64_t cachelinesize;
   int64_t memsize;
+  char cpumodel[64];
 
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
   if (hwloc_get_sysctlbyname("hw.ncpu", &_nprocs) || _nprocs <= 0)
-    return;
+    return -1;
   nprocs = _nprocs;
   topology->support.discovery->pu = 1;
 
   hwloc_debug("%u procs\n", nprocs);
 
+  size = sizeof(cpumodel);
+  if (sysctlbyname("machdep.cpu.brand_string", cpumodel, &size, NULL, 0))
+    cpumodel[0] = '\0';
+
   if (!hwloc_get_sysctlbyname("hw.packages", &_npackages) && _npackages > 0) {
     unsigned npackages = _npackages;
     int64_t _cores_per_package;
@@ -70,8 +82,14 @@
 
         hwloc_debug_1arg_bitmap("package %u has cpuset %s\n",
                    i, obj->cpuset);
+
+        if (cpumodel[0] != '\0')
+          hwloc_obj_add_info(obj, "CPUModel", cpumodel);
         hwloc_insert_object_by_cpuset(topology, obj);
       }
+    else
+      if (cpumodel[0] != '\0')
+        hwloc_obj_add_info(topology->levels[0][0], "CPUModel", cpumodel);
 
     if (!hwloc_get_sysctlbyname("machdep.cpu.cores_per_package", &_cores_per_package) && _cores_per_package > 0) {
       unsigned cores_per_package = _cores_per_package;
@@ -91,7 +109,9 @@
           hwloc_insert_object_by_cpuset(topology, obj);
         }
     }
-  }
+  } else
+    if (cpumodel[0] != '\0')
+      hwloc_obj_add_info(topology->levels[0][0], "CPUModel", cpumodel);
 
   if (hwloc_get_sysctlbyname("hw.l1dcachesize", &l1dcachesize))
     l1dcachesize = 0;
@@ -245,9 +265,43 @@
   hwloc_setup_pu_level(topology, nprocs);
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "Darwin");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_darwin_hooks(struct hwloc_topology *topology __hwloc_attribute_unused)
+hwloc_set_darwin_hooks(struct hwloc_binding_hooks *hooks __hwloc_attribute_unused,
+		       struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
 }
+
+static struct hwloc_backend *
+hwloc_darwin_component_instantiate(struct hwloc_disc_component *component,
+				   const void *_data1 __hwloc_attribute_unused,
+				   const void *_data2 __hwloc_attribute_unused,
+				   const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_darwin;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_darwin_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "darwin",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_darwin_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_darwin_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_darwin_disc_component
+};

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-fake.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-fake.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-fake.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#include <private/autogen/config.h>
+#include <hwloc.h>
+#include <private/private.h>
+
+#include <stdlib.h>
+
+static struct hwloc_backend *
+hwloc_fake_component_instantiate(struct hwloc_disc_component *component __hwloc_attribute_unused,
+				 const void *_data1 __hwloc_attribute_unused,
+				 const void *_data2 __hwloc_attribute_unused,
+				 const void *_data3 __hwloc_attribute_unused)
+{
+  if (getenv("HWLOC_DEBUG_FAKE_COMPONENT"))
+    printf("fake component instantiated\n");
+  return NULL;
+}
+
+static struct hwloc_disc_component hwloc_fake_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL, /* so that it's always enabled when using the OS discovery */
+  "fake",
+  0, /* nothing to exclude */
+  hwloc_fake_component_instantiate,
+  100, /* make sure it's loaded before anything conflicting excludes it */
+  NULL
+};
+
+HWLOC_DECLSPEC extern const struct hwloc_component hwloc_fake_component; /* never linked statically in the core */
+
+const struct hwloc_component hwloc_fake_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_fake_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-freebsd.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-freebsd.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-freebsd.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2010, 2012 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -174,44 +174,80 @@
 }
 #endif
 
-void
-hwloc_look_freebsd(struct hwloc_topology *topology)
+static int
+hwloc_look_freebsd(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   unsigned nbprocs = hwloc_fallback_nbprocessors(topology);
 
+  if (!topology->levels[0][0]->cpuset) {
+    /* Nobody (even the x86 backend) created objects yet, setup basic objects */
+    hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+    hwloc_setup_pu_level(topology, nbprocs);
+  }
+
+  /* Add FreeBSD specific information */
 #ifdef HAVE__SC_LARGE_PAGESIZE
   topology->levels[0][0]->attr->machine.huge_page_size_kB = sysconf(_SC_LARGE_PAGESIZE);
 #endif
-
-  hwloc_set_freebsd_hooks(topology);
-  hwloc_look_x86(topology, nbprocs);
-
-  hwloc_setup_pu_level(topology, nbprocs);
-
 #ifdef HAVE_SYSCTL
   hwloc_freebsd_node_meminfo_info(topology);
 #endif
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "FreeBSD");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_freebsd_hooks(struct hwloc_topology *topology)
+hwloc_set_freebsd_hooks(struct hwloc_binding_hooks *hooks __hwloc_attribute_unused,
+			struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
 #if defined(HAVE_SYS_CPUSET_H) && defined(HAVE_CPUSET_SETAFFINITY)
-  topology->set_thisproc_cpubind = hwloc_freebsd_set_thisproc_cpubind;
-  topology->get_thisproc_cpubind = hwloc_freebsd_get_thisproc_cpubind;
-  topology->set_thisthread_cpubind = hwloc_freebsd_set_thisthread_cpubind;
-  topology->get_thisthread_cpubind = hwloc_freebsd_get_thisthread_cpubind;
-  topology->set_proc_cpubind = hwloc_freebsd_set_proc_cpubind;
-  topology->get_proc_cpubind = hwloc_freebsd_get_proc_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_freebsd_set_thisproc_cpubind;
+  hooks->get_thisproc_cpubind = hwloc_freebsd_get_thisproc_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_freebsd_set_thisthread_cpubind;
+  hooks->get_thisthread_cpubind = hwloc_freebsd_get_thisthread_cpubind;
+  hooks->set_proc_cpubind = hwloc_freebsd_set_proc_cpubind;
+  hooks->get_proc_cpubind = hwloc_freebsd_get_proc_cpubind;
 #ifdef hwloc_thread_t
 #if HAVE_DECL_PTHREAD_SETAFFINITY_NP
-  topology->set_thread_cpubind = hwloc_freebsd_set_thread_cpubind;
+  hooks->set_thread_cpubind = hwloc_freebsd_set_thread_cpubind;
 #endif
 #if HAVE_DECL_PTHREAD_GETAFFINITY_NP
-  topology->get_thread_cpubind = hwloc_freebsd_get_thread_cpubind;
+  hooks->get_thread_cpubind = hwloc_freebsd_get_thread_cpubind;
 #endif
 #endif
 #endif
   /* TODO: get_last_cpu_location: find out ki_lastcpu */
 }
+
+static struct hwloc_backend *
+hwloc_freebsd_component_instantiate(struct hwloc_disc_component *component,
+				    const void *_data1 __hwloc_attribute_unused,
+				    const void *_data2 __hwloc_attribute_unused,
+				    const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_freebsd;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_freebsd_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "freebsd",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_freebsd_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_freebsd_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_freebsd_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-hpux.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-hpux.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-hpux.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2010 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -161,15 +161,22 @@
 }
 #endif /* MAP_MEM_FIRST_TOUCH */
 
-void
-hwloc_look_hpux(struct hwloc_topology *topology)
+static int
+hwloc_look_hpux(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   int has_numa = sysconf(_SC_CCNUMA_SUPPORT) == 1;
   hwloc_obj_t *nodes = NULL, obj;
   spu_t currentcpu;
   ldom_t currentnode;
   int i, nbnodes = 0;
 
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
 #ifdef HAVE__SC_LARGE_PAGESIZE
   topology->levels[0][0]->attr->machine.huge_page_size_kB = sysconf(_SC_LARGE_PAGESIZE);
 #endif
@@ -242,23 +249,57 @@
   topology->support.discovery->pu = 1;
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "HP-UX");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_hpux_hooks(struct hwloc_topology *topology)
+hwloc_set_hpux_hooks(struct hwloc_binding_hooks *hooks,
+		     struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
-  topology->set_proc_cpubind = hwloc_hpux_set_proc_cpubind;
-  topology->set_thisproc_cpubind = hwloc_hpux_set_thisproc_cpubind;
+  hooks->set_proc_cpubind = hwloc_hpux_set_proc_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_hpux_set_thisproc_cpubind;
 #ifdef hwloc_thread_t
-  topology->set_thread_cpubind = hwloc_hpux_set_thread_cpubind;
-  topology->set_thisthread_cpubind = hwloc_hpux_set_thisthread_cpubind;
+  hooks->set_thread_cpubind = hwloc_hpux_set_thread_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_hpux_set_thisthread_cpubind;
 #endif
 #ifdef MAP_MEM_FIRST_TOUCH
-  topology->alloc_membind = hwloc_hpux_alloc_membind;
-  topology->alloc = hwloc_alloc_mmap;
-  topology->free_membind = hwloc_free_mmap;
-  topology->support.membind->firsttouch_membind = 1;
-  topology->support.membind->bind_membind = 1;
-  topology->support.membind->interleave_membind = 1;
+  hooks->alloc_membind = hwloc_hpux_alloc_membind;
+  hooks->alloc = hwloc_alloc_mmap;
+  hooks->free_membind = hwloc_free_mmap;
+  support->membind->firsttouch_membind = 1;
+  support->membind->bind_membind = 1;
+  support->membind->interleave_membind = 1;
 #endif /* MAP_MEM_FIRST_TOUCH */
 }
+
+static struct hwloc_backend *
+hwloc_hpux_component_instantiate(struct hwloc_disc_component *component,
+				 const void *_data1 __hwloc_attribute_unused,
+				 const void *_data2 __hwloc_attribute_unused,
+				 const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_hpux;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_hpux_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "hpux",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_hpux_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_hpux_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_hpux_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-libpci.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-libpci.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-libpci.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * See COPYING in top-level directory.
  */
@@ -12,8 +12,6 @@
 #include <private/debug.h>
 #include <private/misc.h>
 
-#ifdef HWLOC_HAVE_LIBPCI
-
 #include <pci/pci.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -21,13 +19,12 @@
 #include <assert.h>
 #include <stdarg.h>
 #include <setjmp.h>
-#ifdef HWLOC_LINUX_SYS
-#endif
 
 #define CONFIG_SPACE_CACHESIZE 256
 
 static void
-hwloc_pci_traverse_print_cb(struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *pcidev, int depth __hwloc_attribute_unused)
+hwloc_pci_traverse_print_cb(void * cbdata __hwloc_attribute_unused,
+			    struct hwloc_obj *pcidev, int depth __hwloc_attribute_unused)
 {
   char busid[14];
   snprintf(busid, sizeof(busid), "%04x:%02x:%02x.%01x",
@@ -49,42 +46,44 @@
 }
 
 static void
-hwloc_pci_traverse_setbridgedepth_cb(struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *pcidev, int depth)
+hwloc_pci_traverse_setbridgedepth_cb(void * cbdata __hwloc_attribute_unused,
+				     struct hwloc_obj *pcidev, int depth)
 {
   if (pcidev->type == HWLOC_OBJ_BRIDGE)
     pcidev->attr->bridge.depth = depth;
 }
 
 static void
-hwloc_pci_traverse_lookuposdevices_cb(struct hwloc_topology *topology, struct hwloc_obj *pcidev, int depth __hwloc_attribute_unused)
+hwloc_pci_traverse_lookuposdevices_cb(void * cbdata,
+				      struct hwloc_obj *pcidev, int depth __hwloc_attribute_unused)
 {
+  struct hwloc_backend *backend = cbdata;
+
   if (pcidev->type == HWLOC_OBJ_BRIDGE)
     return;
 
-#ifdef HWLOC_LINUX_SYS
-  hwloc_linuxfs_pci_lookup_osdevices(topology, pcidev);
-#endif
+  hwloc_backends_notify_new_object(backend, pcidev);
 }
 
 static void
-hwloc_pci__traverse(struct hwloc_topology *topology, struct hwloc_obj *root,
-		    void (*cb)(struct hwloc_topology *, struct hwloc_obj *, int depth),
+hwloc_pci__traverse(void * cbdata, struct hwloc_obj *root,
+		    void (*cb)(void * cbdata, struct hwloc_obj *, int depth),
 		    int depth)
 {
   struct hwloc_obj *child = root->first_child;
   while (child) {
-    cb(topology, child, depth);
+    cb(cbdata, child, depth);
     if (child->type == HWLOC_OBJ_BRIDGE)
-      hwloc_pci__traverse(topology, child, cb, depth+1);
+      hwloc_pci__traverse(cbdata, child, cb, depth+1);
     child = child->next_sibling;
   }
 }
 
 static void
-hwloc_pci_traverse(struct hwloc_topology *topology, struct hwloc_obj *root,
-		   void (*cb)(struct hwloc_topology *, struct hwloc_obj *, int depth))
+hwloc_pci_traverse(void * cbdata, struct hwloc_obj *root,
+		   void (*cb)(void * cbdata, struct hwloc_obj *, int depth))
 {
-  hwloc_pci__traverse(topology, root, cb, 0);
+  hwloc_pci__traverse(cbdata, root, cb, 0);
 }
 
 enum hwloc_pci_busid_comparison_e {
@@ -227,7 +226,8 @@
 }
 
 static struct hwloc_obj *
-hwloc_pci_find_hostbridge_parent(struct hwloc_topology *topology, struct hwloc_obj *hostbridge, int *created)
+hwloc_pci_find_hostbridge_parent(struct hwloc_topology *topology, struct hwloc_backend *backend,
+				 struct hwloc_obj *hostbridge, int *created)
 {
   hwloc_bitmap_t cpuset = hwloc_bitmap_alloc();
   struct hwloc_obj *parent;
@@ -244,12 +244,10 @@
     hwloc_debug("Overriding localcpus using %s in the environment\n", envname);
     hwloc_bitmap_sscanf(cpuset, env);
   } else {
-    /* get the hostbridge cpuset. it's not a PCI device, so we use its first child locality info */
-#ifdef HWLOC_LINUX_SYS
-    err = hwloc_linuxfs_get_pcidev_cpuset(topology, hostbridge->first_child, cpuset);
-#else
-    err = -1;
-#endif
+    /* get the hostbridge cpuset by acking the OS backend.
+     * it's not a PCI device, so we use its first child locality info.
+     */
+    err = hwloc_backends_get_obj_cpuset(backend, hostbridge->first_child, cpuset);
     if (err < 0)
       /* if we got nothing, assume the hostbridge is attached to the top of hierarchy */
       hwloc_bitmap_copy(cpuset, hwloc_topology_get_topology_cpuset(topology));
@@ -310,15 +308,24 @@
 {
 }
 
-void
-hwloc_look_libpci(struct hwloc_topology *topology)
+static int
+hwloc_look_libpci(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   struct pci_access *pciaccess;
   struct pci_dev *pcidev;
   struct hwloc_obj fakehostbridge; /* temporary object covering the whole PCI hierarchy until its complete */
   unsigned current_hostbridge;
   int createdgroups = 0;
 
+  if (!(topology->flags & (HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO)))
+    return 0;
+
+  if (!topology->is_thissystem) {
+    hwloc_debug("%s", "\nno PCI detection (not thissystem)\n");
+    return 0;
+  }
+
   fakehostbridge.first_child = NULL;
   fakehostbridge.last_child = NULL;
 
@@ -330,7 +337,7 @@
 
   if (setjmp(err_buf)) {
     pci_cleanup(pciaccess);
-    return;
+    return -1;
   }
 
   pci_init(pciaccess);
@@ -480,15 +487,15 @@
   pci_cleanup(pciaccess);
 
   hwloc_debug("%s", "\nPCI hierarchy after basic scan:\n");
-  hwloc_pci_traverse(topology, &fakehostbridge, hwloc_pci_traverse_print_cb);
+  hwloc_pci_traverse(NULL, &fakehostbridge, hwloc_pci_traverse_print_cb);
 
   if (!fakehostbridge.first_child)
     /* found nothing, exit */
-    return;
+    return 0;
 
   /* walk the hierarchy, set bridge depth and lookup OS devices */
-  hwloc_pci_traverse(topology, &fakehostbridge, hwloc_pci_traverse_setbridgedepth_cb);
-  hwloc_pci_traverse(topology, &fakehostbridge, hwloc_pci_traverse_lookuposdevices_cb);
+  hwloc_pci_traverse(NULL, &fakehostbridge, hwloc_pci_traverse_setbridgedepth_cb);
+  hwloc_pci_traverse(backend, &fakehostbridge, hwloc_pci_traverse_lookuposdevices_cb);
 
   /*
    * fakehostbridge lists all objects connected to any upstream bus in the machine.
@@ -538,12 +545,45 @@
 		current_domain, current_bus, current_subordinate);
 
     /* attach the hostbridge where it belongs */
-    parent = hwloc_pci_find_hostbridge_parent(topology, hostbridge, &createdgroups);
+    parent = hwloc_pci_find_hostbridge_parent(topology, backend, hostbridge, &createdgroups);
     hwloc_insert_object_by_parent(topology, parent, hostbridge);
   }
 
   if (createdgroups)
     topology->next_group_depth++;
+
+  return 1;
 }
 
-#endif /* HWLOC_HAVE_LIBPCI */
+static struct hwloc_backend *
+hwloc_libpci_component_instantiate(struct hwloc_disc_component *component,
+				   const void *_data1 __hwloc_attribute_unused,
+				   const void *_data2 __hwloc_attribute_unused,
+				   const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+
+  /* thissystem may not be fully initialized yet, we'll check flags in discover() */
+
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_libpci;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_libpci_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL,
+  "libpci",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_libpci_component_instantiate,
+  20,
+  NULL
+};
+
+const struct hwloc_component hwloc_libpci_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_libpci_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-linux.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-linux.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-linux.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2012 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * Copyright © 2010 IBM
@@ -14,7 +14,6 @@
 #include <private/private.h>
 #include <private/misc.h>
 #include <private/debug.h>
-#include <sys/utsname.h>
 
 #include <limits.h>
 #include <stdio.h>
@@ -259,6 +258,11 @@
 #endif
 }
 
+struct hwloc_linux_backend_data_s {
+  char *root_path; /* The path of the file system root, used when browsing, e.g., Linux' sysfs and procfs. */
+  int root_fd; /* The file descriptor for the file system root, used when browsing, e.g., Linux' sysfs and procfs. */
+};
+
 int
 hwloc_linux_set_tid_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, pid_t tid __hwloc_attribute_unused, hwloc_const_bitmap_t hwloc_set __hwloc_attribute_unused)
 {
@@ -333,22 +337,29 @@
 static int
 hwloc_linux_find_kernel_nr_cpus(hwloc_topology_t topology)
 {
-  static int nr_cpus = -1;
+  static int _nr_cpus = -1;
+  int nr_cpus = _nr_cpus;
 
   if (nr_cpus != -1)
     /* already computed */
     return nr_cpus;
 
-  /* start with a nr_cpus that may contain the whole topology */
-  nr_cpus = hwloc_bitmap_last(topology->levels[0][0]->complete_cpuset) + 1;
+  if (topology->levels[0][0]->complete_cpuset)
+    /* start with a nr_cpus that may contain the whole topology */
+    nr_cpus = hwloc_bitmap_last(topology->levels[0][0]->complete_cpuset) + 1;
+  if (nr_cpus <= 0)
+    /* start from scratch, the topology isn't ready yet (complete_cpuset is missing (-1) or empty (0))*/
+    nr_cpus = 1;
+
   while (1) {
     cpu_set_t *set = CPU_ALLOC(nr_cpus);
     size_t setsize = CPU_ALLOC_SIZE(nr_cpus);
     int err = sched_getaffinity(0, setsize, set); /* always works, unless setsize is too small */
     CPU_FREE(set);
+    nr_cpus = setsize * 8; /* that's the value that was actually tested */
     if (!err)
       /* found it */
-      return nr_cpus;
+      return _nr_cpus = nr_cpus;
     nr_cpus *= 2;
   }
 }
@@ -379,8 +390,12 @@
     return -1;
   }
 
-  last = hwloc_bitmap_last(topology->levels[0][0]->complete_cpuset);
-  assert(last != -1);
+  last = -1;
+  if (topology->levels[0][0]->complete_cpuset)
+    last = hwloc_bitmap_last(topology->levels[0][0]->complete_cpuset);
+  if (last == -1)
+    /* round the maximal support number, the topology isn't ready yet (complete_cpuset is missing or empty)*/
+    last = kernel_nr_cpus-1;
 
   hwloc_bitmap_zero(hwloc_set);
   for(cpu=0; cpu<=(unsigned) last; cpu++)
@@ -1313,7 +1328,7 @@
   int mixed = 0;
   int full = 0;
   int first = 1;
-  int pagesize = getpagesize();
+  int pagesize = hwloc_getpagesize();
   char *tmpaddr;
   int err;
   unsigned i;
@@ -1382,50 +1397,6 @@
 
 #endif /* HWLOC_HAVE_SET_MEMPOLICY */
 
-int
-hwloc_backend_linuxfs_init(struct hwloc_topology *topology, const char *fsroot_path __hwloc_attribute_unused)
-{
-  int root = -1;
-
-  assert(topology->backend_type == HWLOC_BACKEND_NONE);
-
-  if (!fsroot_path)
-    fsroot_path = "/";
-
-#ifdef HAVE_OPENAT
-  root = open(fsroot_path, O_RDONLY | O_DIRECTORY);
-  if (root < 0)
-    return -1;
-
-  if (strcmp(fsroot_path, "/"))
-    topology->is_thissystem = 0;
-
-  topology->backend_params.linuxfs.root_path = strdup(fsroot_path);
-#else
-  if (strcmp(fsroot_path, "/")) {
-    errno = ENOSYS;
-    return -1;
-  }
-
-  topology->backend_params.linuxfs.root_path = NULL;
-#endif
-  topology->backend_params.linuxfs.root_fd = root;
-  topology->backend_type = HWLOC_BACKEND_LINUXFS;
-  return 0;
-}
-
-void
-hwloc_backend_linuxfs_exit(struct hwloc_topology *topology)
-{
-  assert(topology->backend_type == HWLOC_BACKEND_LINUXFS);
-#ifdef HAVE_OPENAT
-  close(topology->backend_params.linuxfs.root_fd);
-  free(topology->backend_params.linuxfs.root_path);
-  topology->backend_params.linuxfs.root_path = NULL;
-#endif
-  topology->backend_type = HWLOC_BACKEND_NONE;
-}
-
 /* cpuinfo array */
 struct hwloc_linux_cpuinfo_proc {
   /* set during hwloc_linux_parse_cpuinfo */
@@ -1770,7 +1741,7 @@
 }
 
 static void
-hwloc_admin_disable_set_from_cpuset(struct hwloc_topology *topology,
+hwloc_admin_disable_set_from_cpuset(struct hwloc_linux_backend_data_s *data,
 				    const char *cgroup_mntpnt, const char *cpuset_mntpnt, const char *cpuset_name,
 				    const char *attr_name,
 				    hwloc_bitmap_t admin_enabled_cpus_set)
@@ -1781,7 +1752,7 @@
   hwloc_bitmap_t tmpset;
 
   cpuset_mask = hwloc_read_linux_cpuset_mask(cgroup_mntpnt, cpuset_mntpnt, cpuset_name,
-					     attr_name, topology->backend_params.linuxfs.root_fd);
+					     attr_name, data->root_fd);
   if (!cpuset_mask)
     return;
 
@@ -1825,7 +1796,7 @@
 }
 
 static void
-hwloc_parse_meminfo_info(struct hwloc_topology *topology,
+hwloc_parse_meminfo_info(struct hwloc_linux_backend_data_s *data,
 			 const char *path,
 			 int prefixlength,
 			 uint64_t *local_memory,
@@ -1836,7 +1807,7 @@
   char string[64];
   FILE *fd;
 
-  fd = hwloc_fopen(path, "r", topology->backend_params.linuxfs.root_fd);
+  fd = hwloc_fopen(path, "r", data->root_fd);
   if (!fd)
     return;
 
@@ -1865,7 +1836,7 @@
 #define SYSFS_NUMA_NODE_PATH_LEN 128
 
 static void
-hwloc_parse_hugepages_info(struct hwloc_topology *topology,
+hwloc_parse_hugepages_info(struct hwloc_linux_backend_data_s *data,
 			   const char *dirpath,
 			   struct hwloc_obj_memory_s *memory,
 			   uint64_t *remaining_local_memory)
@@ -1877,14 +1848,14 @@
   char line[64];
   char path[SYSFS_NUMA_NODE_PATH_LEN];
 
-  dir = hwloc_opendir(dirpath, topology->backend_params.linuxfs.root_fd);
+  dir = hwloc_opendir(dirpath, data->root_fd);
   if (dir) {
     while ((dirent = readdir(dir)) != NULL) {
       if (strncmp(dirent->d_name, "hugepages-", 10))
         continue;
       memory->page_types[index_].size = strtoul(dirent->d_name+10, NULL, 0) * 1024ULL;
       sprintf(path, "%s/%s/nr_hugepages", dirpath, dirent->d_name);
-      hpfd = hwloc_fopen(path, "r", topology->backend_params.linuxfs.root_fd);
+      hpfd = hwloc_fopen(path, "r", data->root_fd);
       if (hpfd) {
         if (fgets(line, sizeof(line), hpfd)) {
           fclose(hpfd);
@@ -1901,7 +1872,9 @@
 }
 
 static void
-hwloc_get_kerrighed_node_meminfo_info(struct hwloc_topology *topology, unsigned long node, struct hwloc_obj_memory_s *memory)
+hwloc_get_kerrighed_node_meminfo_info(struct hwloc_topology *topology,
+				      struct hwloc_linux_backend_data_s *data,
+				      unsigned long node, struct hwloc_obj_memory_s *memory)
 {
   char path[128];
   uint64_t meminfo_hugepages_count, meminfo_hugepages_size = 0;
@@ -1914,11 +1887,11 @@
 #ifdef HAVE__SC_LARGE_PAGESIZE
     memory->page_types[1].size = sysconf(_SC_LARGE_PAGESIZE);
 #endif
-    memory->page_types[0].size = getpagesize();
+    memory->page_types[0].size = hwloc_getpagesize();
   }
 
   snprintf(path, sizeof(path), "/proc/nodes/node%lu/meminfo", node);
-  hwloc_parse_meminfo_info(topology, path, 0 /* no prefix */,
+  hwloc_parse_meminfo_info(data, path, 0 /* no prefix */,
 			   &memory->local_memory,
 			   &meminfo_hugepages_count, &meminfo_hugepages_size,
 			   memory->page_types == NULL);
@@ -1937,7 +1910,9 @@
 }
 
 static void
-hwloc_get_procfs_meminfo_info(struct hwloc_topology *topology, struct hwloc_obj_memory_s *memory)
+hwloc_get_procfs_meminfo_info(struct hwloc_topology *topology,
+			      struct hwloc_linux_backend_data_s *data,
+			      struct hwloc_obj_memory_s *memory)
 {
   uint64_t meminfo_hugepages_count, meminfo_hugepages_size = 0;
   struct stat st;
@@ -1946,7 +1921,7 @@
   int types = 2;
   int err;
 
-  err = hwloc_stat("/sys/kernel/mm/hugepages", &st, topology->backend_params.linuxfs.root_fd);
+  err = hwloc_stat("/sys/kernel/mm/hugepages", &st, data->root_fd);
   if (!err) {
     types = 1 + st.st_nlink-2;
     has_sysfs_hugepages = 1;
@@ -1965,10 +1940,10 @@
 #ifdef HAVE__SC_LARGE_PAGESIZE
     memory->page_types[1].size = sysconf(_SC_LARGE_PAGESIZE);
 #endif
-    memory->page_types[0].size = getpagesize(); /* might be overwritten later by /proc/meminfo or sysfs */
+    memory->page_types[0].size = hwloc_getpagesize(); /* might be overwritten later by /proc/meminfo or sysfs */
   }
 
-  hwloc_parse_meminfo_info(topology, "/proc/meminfo", 0 /* no prefix */,
+  hwloc_parse_meminfo_info(data, "/proc/meminfo", 0 /* no prefix */,
 			   &memory->local_memory,
 			   &meminfo_hugepages_count, &meminfo_hugepages_size,
 			   memory->page_types == NULL);
@@ -1977,7 +1952,7 @@
     uint64_t remaining_local_memory = memory->local_memory;
     if (has_sysfs_hugepages) {
       /* read from node%d/hugepages/hugepages-%skB/nr_hugepages */
-      hwloc_parse_hugepages_info(topology, "/sys/kernel/mm/hugepages", memory, &remaining_local_memory);
+      hwloc_parse_hugepages_info(data, "/sys/kernel/mm/hugepages", memory, &remaining_local_memory);
     } else {
       /* use what we found in meminfo */
       if (meminfo_hugepages_size) {
@@ -2006,8 +1981,9 @@
 
 static void
 hwloc_sysfs_node_meminfo_info(struct hwloc_topology *topology,
-			     const char *syspath, int node,
-			     struct hwloc_obj_memory_s *memory)
+			      struct hwloc_linux_backend_data_s *data,
+			      const char *syspath, int node,
+			      struct hwloc_obj_memory_s *memory)
 {
   char path[SYSFS_NUMA_NODE_PATH_LEN];
   char meminfopath[SYSFS_NUMA_NODE_PATH_LEN];
@@ -2019,7 +1995,7 @@
   int err;
 
   sprintf(path, "%s/node%d/hugepages", syspath, node);
-  err = hwloc_stat(path, &st, topology->backend_params.linuxfs.root_fd);
+  err = hwloc_stat(path, &st, data->root_fd);
   if (!err) {
     types = 1 + st.st_nlink-2;
     has_sysfs_hugepages = 1;
@@ -2032,7 +2008,7 @@
   }
 
   sprintf(meminfopath, "%s/node%d/meminfo", syspath, node);
-  hwloc_parse_meminfo_info(topology, meminfopath,
+  hwloc_parse_meminfo_info(data, meminfopath,
 			   hwloc_snprintf(NULL, 0, "Node %d ", node),
 			   &memory->local_memory,
 			   &meminfo_hugepages_count, NULL /* no hugepage size in node-specific meminfo */,
@@ -2042,7 +2018,7 @@
     uint64_t remaining_local_memory = memory->local_memory;
     if (has_sysfs_hugepages) {
       /* read from node%d/hugepages/hugepages-%skB/nr_hugepages */
-      hwloc_parse_hugepages_info(topology, path, memory, &remaining_local_memory);
+      hwloc_parse_hugepages_info(data, path, memory, &remaining_local_memory);
     } else {
       /* get hugepage size from machine-specific meminfo since there is no size in node-specific meminfo,
        * hwloc_get_procfs_meminfo_info must have been called earlier */
@@ -2057,7 +2033,7 @@
       }
     }
     /* update what's remaining as normal pages */
-    memory->page_types[0].size = getpagesize();
+    memory->page_types[0].size = hwloc_getpagesize();
     memory->page_types[0].count = remaining_local_memory / memory->page_types[0].size;
   }
 }
@@ -2095,7 +2071,9 @@
 }
 
 static int
-look_sysfsnode(struct hwloc_topology *topology, const char *path, unsigned *found)
+look_sysfsnode(struct hwloc_topology *topology,
+	       struct hwloc_linux_backend_data_s *data,
+	       const char *path, unsigned *found)
 {
   unsigned osnode;
   unsigned nbnodes = 0;
@@ -2107,7 +2085,7 @@
   *found = 0;
 
   /* Get the list of nodes first */
-  dir = hwloc_opendir(path, topology->backend_params.linuxfs.root_fd);
+  dir = hwloc_opendir(path, data->root_fd);
   if (dir)
     {
       nodeset = hwloc_bitmap_alloc();
@@ -2170,7 +2148,7 @@
 	  osnode = indexes[index_];
 
           sprintf(nodepath, "%s/node%u/cpumap", path, osnode);
-          cpuset = hwloc_parse_cpumap(nodepath, topology->backend_params.linuxfs.root_fd);
+          cpuset = hwloc_parse_cpumap(nodepath, data->root_fd);
           if (!cpuset)
               continue;
 
@@ -2179,7 +2157,7 @@
           node->nodeset = hwloc_bitmap_alloc();
           hwloc_bitmap_set(node->nodeset, osnode);
 
-          hwloc_sysfs_node_meminfo_info(topology, path, osnode, &node->memory);
+          hwloc_sysfs_node_meminfo_info(topology, data, path, osnode, &node->memory);
 
           hwloc_debug_1arg_bitmap("os node %u has cpuset %s\n",
                                   osnode, node->cpuset);
@@ -2189,7 +2167,7 @@
 	  /* Linux nodeX/distance file contains distance from X to other localities (from ACPI SLIT table or so),
 	   * store them in slots X*N...X*N+N-1 */
           sprintf(nodepath, "%s/node%u/distance", path, osnode);
-          hwloc_parse_node_distance(nodepath, nbnodes, distances+index_*nbnodes, topology->backend_params.linuxfs.root_fd);
+          hwloc_parse_node_distance(nodepath, nbnodes, distances+index_*nbnodes, data->root_fd);
       }
 
       hwloc_distances_set(topology, HWLOC_OBJ_NODE, nbnodes, indexes, nodes, distances, 0 /* OS cannot force */);
@@ -2362,7 +2340,8 @@
 
 static void
 try_add_cache_from_device_tree_cpu(struct hwloc_topology *topology,
-  const char *cpu, unsigned int level, hwloc_bitmap_t cpuset)
+				   struct hwloc_linux_backend_data_s *data,
+				   const char *cpu, unsigned int level, hwloc_bitmap_t cpuset)
 {
   /* d-cache-block-size - ignore */
   /* d-cache-line-size - to read, in bytes */
@@ -2380,20 +2359,20 @@
   int unified;
 
   snprintf(unified_path, sizeof(unified_path), "%s/cache-unified", cpu);
-  unified = (hwloc_stat(unified_path, &statbuf, topology->backend_params.linuxfs.root_fd) == 0);
+  unified = (hwloc_stat(unified_path, &statbuf, data->root_fd) == 0);
 
   hwloc_read_unit32be(cpu, "d-cache-line-size", &d_cache_line_size,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
   hwloc_read_unit32be(cpu, "d-cache-size", &d_cache_size,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
   hwloc_read_unit32be(cpu, "d-cache-sets", &d_cache_sets,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
   hwloc_read_unit32be(cpu, "i-cache-line-size", &i_cache_line_size,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
   hwloc_read_unit32be(cpu, "i-cache-size", &i_cache_size,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
   hwloc_read_unit32be(cpu, "i-cache-sets", &i_cache_sets,
-      topology->backend_params.linuxfs.root_fd);
+      data->root_fd);
 
   if (!unified)
     try__add_cache_from_device_tree_cpu(topology, level, HWLOC_OBJ_CACHE_INSTRUCTION,
@@ -2407,12 +2386,13 @@
  * which provide NUMA nodes information without any details
  */
 static void
-look_powerpc_device_tree(struct hwloc_topology *topology)
+look_powerpc_device_tree(struct hwloc_topology *topology,
+			 struct hwloc_linux_backend_data_s *data)
 {
   device_tree_cpus_t cpus;
   const char ofroot[] = "/proc/device-tree/cpus";
   unsigned int i;
-  int root_fd = topology->backend_params.linuxfs.root_fd;
+  int root_fd = data->root_fd;
   DIR *dt = hwloc_opendir(ofroot, root_fd);
   struct dirent *dirent;
 
@@ -2490,7 +2470,7 @@
         hwloc_insert_object_by_cpuset(topology, core);
 
         /* Add L1 cache */
-        try_add_cache_from_device_tree_cpu(topology, cpu, 1, cpuset);
+        try_add_cache_from_device_tree_cpu(topology, data, cpu, 1, cpuset);
 
         hwloc_bitmap_free(cpuset);
       }
@@ -2541,7 +2521,7 @@
       }
       snprintf(cpu, len, "%s/%s", ofroot, cpus.p[i].name);
 
-      try_add_cache_from_device_tree_cpu(topology, cpu, level, cpuset);
+      try_add_cache_from_device_tree_cpu(topology, data, cpu, level, cpuset);
       free(cpu);
     }
     hwloc_bitmap_free(cpuset);
@@ -2557,7 +2537,9 @@
 
 /* Look at Linux' /sys/devices/system/cpu/cpu%d/topology/ */
 static int
-look_sysfscpu(struct hwloc_topology *topology, const char *path,
+look_sysfscpu(struct hwloc_topology *topology,
+	      struct hwloc_linux_backend_data_s *data,
+	      const char *path,
 	      struct hwloc_linux_cpuinfo_proc * cpuinfo_Lprocs, unsigned cpuinfo_numprocs)
 {
   hwloc_bitmap_t cpuset; /* Set of cpus for which we have topology information */
@@ -2569,7 +2551,7 @@
   unsigned caches_added;
 
   /* fill the cpuset of interesting cpus */
-  dir = hwloc_opendir(path, topology->backend_params.linuxfs.root_fd);
+  dir = hwloc_opendir(path, data->root_fd);
   if (!dir)
     return -1;
   else {
@@ -2589,7 +2571,7 @@
 
       /* check whether this processor is online */
       sprintf(str, "%s/cpu%lu/online", path, cpu);
-      fd = hwloc_fopen(str, "r", topology->backend_params.linuxfs.root_fd);
+      fd = hwloc_fopen(str, "r", data->root_fd);
       if (fd) {
 	if (fgets(online, sizeof(online), fd)) {
 	  fclose(fd);
@@ -2606,7 +2588,7 @@
 
       /* check whether the kernel exports topology information for this cpu */
       sprintf(str, "%s/cpu%lu/topology", path, cpu);
-      if (hwloc_access(str, X_OK, topology->backend_params.linuxfs.root_fd) < 0 && errno == ENOENT) {
+      if (hwloc_access(str, X_OK, data->root_fd) < 0 && errno == ENOENT) {
 	hwloc_debug("os proc %lu has no accessible %s/cpu%lu/topology\n",
 		   cpu, path, cpu);
 	continue;
@@ -2632,10 +2614,10 @@
       /* look at the socket */
       mysocketid = 0; /* shut-up the compiler */
       sprintf(str, "%s/cpu%d/topology/physical_package_id", path, i);
-      hwloc_parse_sysfs_unsigned(str, &mysocketid, topology->backend_params.linuxfs.root_fd);
+      hwloc_parse_sysfs_unsigned(str, &mysocketid, data->root_fd);
 
       sprintf(str, "%s/cpu%d/topology/core_siblings", path, i);
-      socketset = hwloc_parse_cpumap(str, topology->backend_params.linuxfs.root_fd);
+      socketset = hwloc_parse_cpumap(str, data->root_fd);
       if (socketset && hwloc_bitmap_first(socketset) == i) {
         /* first cpu in this socket, add the socket */
         sock = hwloc_alloc_setup_object(HWLOC_OBJ_SOCKET, mysocketid);
@@ -2652,8 +2634,6 @@
 	      hwloc_obj_add_info(sock, "CPUModel", cpuinfo_Lprocs[j].cpumodel);
 	    }
 	}
-	if (topology->backend_params.linuxfs.utsname.machine[0] != '\0')
-	  hwloc_obj_add_info(sock, "CPUType", topology->backend_params.linuxfs.utsname.machine);
         socketset = NULL; /* don't free it */
       }
       hwloc_bitmap_free(socketset);
@@ -2661,10 +2641,10 @@
       /* look at the core */
       mycoreid = 0; /* shut-up the compiler */
       sprintf(str, "%s/cpu%d/topology/core_id", path, i);
-      hwloc_parse_sysfs_unsigned(str, &mycoreid, topology->backend_params.linuxfs.root_fd);
+      hwloc_parse_sysfs_unsigned(str, &mycoreid, data->root_fd);
 
       sprintf(str, "%s/cpu%d/topology/thread_siblings", path, i);
-      coreset = hwloc_parse_cpumap(str, topology->backend_params.linuxfs.root_fd);
+      coreset = hwloc_parse_cpumap(str, data->root_fd);
       savedcoreset = coreset; /* store it for later work-arounds */
 
       if (coreset && hwloc_bitmap_weight(coreset) > 1) {
@@ -2675,7 +2655,7 @@
 	siblingid = hwloc_bitmap_first(set);
 	siblingcoreid = mycoreid;
 	sprintf(str, "%s/cpu%d/topology/core_id", path, siblingid);
-	hwloc_parse_sysfs_unsigned(str, &siblingcoreid, topology->backend_params.linuxfs.root_fd);
+	hwloc_parse_sysfs_unsigned(str, &siblingcoreid, data->root_fd);
 	threadwithcoreid = (siblingcoreid != mycoreid);
 	hwloc_bitmap_free(set);
       }
@@ -2700,10 +2680,10 @@
       /* look at the books */
       mybookid = 0; /* shut-up the compiler */
       sprintf(str, "%s/cpu%d/topology/book_id", path, i);
-      if (hwloc_parse_sysfs_unsigned(str, &mybookid, topology->backend_params.linuxfs.root_fd) == 0) {
+      if (hwloc_parse_sysfs_unsigned(str, &mybookid, data->root_fd) == 0) {
 
         sprintf(str, "%s/cpu%d/topology/book_siblings", path, i);
-        bookset = hwloc_parse_cpumap(str, topology->backend_params.linuxfs.root_fd);
+        bookset = hwloc_parse_cpumap(str, data->root_fd);
         if (bookset && hwloc_bitmap_first(bookset) == i) {
           book = hwloc_alloc_setup_object(HWLOC_OBJ_GROUP, mybookid);
           book->cpuset = bookset;
@@ -2740,7 +2720,7 @@
 
 	/* get the cache level depth */
 	sprintf(mappath, "%s/cpu%d/cache/index%d/level", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2,sizeof(str2), fd))
 	    depth = strtoul(str2, NULL, 10)-1;
@@ -2752,7 +2732,7 @@
 
 	/* cache type */
 	sprintf(mappath, "%s/cpu%d/cache/index%d/type", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2, sizeof(str2), fd)) {
 	    fclose(fd);
@@ -2773,7 +2753,7 @@
 
 	/* get the cache size */
 	sprintf(mappath, "%s/cpu%d/cache/index%d/size", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2,sizeof(str2), fd))
 	    kB = atol(str2); /* in kB */
@@ -2782,7 +2762,7 @@
 
 	/* get the line size */
 	sprintf(mappath, "%s/cpu%d/cache/index%d/coherency_line_size", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2,sizeof(str2), fd))
 	    linesize = atol(str2); /* in bytes */
@@ -2794,14 +2774,14 @@
 	 * some archs (ia64, ppc) put 0 there when fully-associative, while others (x86) put something like -1 there.
 	 */
 	sprintf(mappath, "%s/cpu%d/cache/index%d/number_of_sets", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2,sizeof(str2), fd))
 	    sets = atol(str2);
 	  fclose(fd);
 	}
 	sprintf(mappath, "%s/cpu%d/cache/index%d/physical_line_partition", path, i, j);
-	fd = hwloc_fopen(mappath, "r", topology->backend_params.linuxfs.root_fd);
+	fd = hwloc_fopen(mappath, "r", data->root_fd);
 	if (fd) {
 	  if (fgets(str2,sizeof(str2), fd))
 	    lines_per_tag = atol(str2);
@@ -2809,7 +2789,7 @@
 	}
 
 	sprintf(mappath, "%s/cpu%d/cache/index%d/shared_cpu_map", path, i, j);
-	cacheset = hwloc_parse_cpumap(mappath, topology->backend_params.linuxfs.root_fd);
+	cacheset = hwloc_parse_cpumap(mappath, data->root_fd);
         if (cacheset) {
           if (hwloc_bitmap_weight(cacheset) < 1) {
             /* mask is wrong (useful for many itaniums) */
@@ -2849,7 +2829,7 @@
   hwloc_bitmap_foreach_end();
 
   if (0 == caches_added)
-    look_powerpc_device_tree(topology);
+    look_powerpc_device_tree(topology, data);
 
   hwloc_bitmap_free(cpuset);
 
@@ -2904,7 +2884,8 @@
 }
 
 static int
-hwloc_linux_parse_cpuinfo(struct hwloc_topology *topology, const char *path,
+hwloc_linux_parse_cpuinfo(struct hwloc_linux_backend_data_s *data,
+			  const char *path,
 			  struct hwloc_linux_cpuinfo_proc ** Lprocs_p)
 {
   FILE *fd;
@@ -2916,7 +2897,7 @@
   unsigned numprocs = 0;
   char *global_cpumodel = NULL;
 
-  if (!(fd=hwloc_fopen(path,"r", topology->backend_params.linuxfs.root_fd)))
+  if (!(fd=hwloc_fopen(path,"r", data->root_fd)))
     {
       hwloc_debug("could not open %s\n", path);
       return -1;
@@ -3026,8 +3007,9 @@
 }
 
 static int
-look_cpuinfo(struct hwloc_topology *topology, const char *path,
-	     hwloc_bitmap_t online_cpuset)
+look_cpuinfo(struct hwloc_topology *topology,
+	     struct hwloc_linux_backend_data_s *data,
+	     const char *path, hwloc_bitmap_t online_cpuset)
 {
   struct hwloc_linux_cpuinfo_proc * Lprocs = NULL;
   /* P for physical/OS index, L for logical (e.g. in we order we get them, not in the final hwloc logical order) */
@@ -3045,7 +3027,7 @@
   hwloc_bitmap_t cpuset;
 
   /* parse the entire cpuinfo first, fill the Lprocs array and numprocs */
-  _numprocs = hwloc_linux_parse_cpuinfo(topology, path, &Lprocs);
+  _numprocs = hwloc_linux_parse_cpuinfo(data, path, &Lprocs);
   if (_numprocs <= 0)
     return -1;
   numprocs = _numprocs;
@@ -3125,8 +3107,6 @@
 	/* FIXME add to name as well? */
         hwloc_obj_add_info(obj, "CPUModel", cpumodel);
       }
-      if (topology->backend_params.linuxfs.utsname.machine[0] != '\0')
-	hwloc_obj_add_info(obj, "CPUType", topology->backend_params.linuxfs.utsname.machine);
       hwloc_debug_1arg_bitmap("Socket %d has cpuset %s\n", i, obj->cpuset);
       hwloc_insert_object_by_cpuset(topology, obj);
     }
@@ -3177,12 +3157,13 @@
 
   hwloc_linux_free_cpuinfo(Lprocs, numprocs);
 
-  look_powerpc_device_tree(topology);
+  look_powerpc_device_tree(topology, data);
   return 0;
 }
 
 static void
-hwloc__get_dmi_one_info(struct hwloc_topology *topology, hwloc_obj_t obj, const char *sysfs_name, const char *hwloc_name)
+hwloc__get_dmi_one_info(struct hwloc_linux_backend_data_s *data,
+			hwloc_obj_t obj, const char *sysfs_name, const char *hwloc_name)
 {
   char sysfs_path[128];
   char dmi_line[64];
@@ -3192,7 +3173,7 @@
   snprintf(sysfs_path, sizeof(sysfs_path), "/sys/class/dmi/id/%s", sysfs_name);
 
   dmi_line[0] = '\0';
-  fd = hwloc_fopen(sysfs_path, "r", topology->backend_params.linuxfs.root_fd);
+  fd = hwloc_fopen(sysfs_path, "r", data->root_fd);
   if (fd) {
     tmp = fgets(dmi_line, sizeof(dmi_line), fd);
     fclose (fd);
@@ -3207,26 +3188,26 @@
 }
 
 static void
-hwloc__get_dmi_info(struct hwloc_topology *topology, hwloc_obj_t obj)
+hwloc__get_dmi_info(struct hwloc_linux_backend_data_s *data, hwloc_obj_t obj)
 {
-  hwloc__get_dmi_one_info(topology, obj, "product_name", "DMIProductName");
-  hwloc__get_dmi_one_info(topology, obj, "product_version", "DMIProductVersion");
-  hwloc__get_dmi_one_info(topology, obj, "product_serial", "DMIProductSerial");
-  hwloc__get_dmi_one_info(topology, obj, "product_uuid", "DMIProductUUID");
-  hwloc__get_dmi_one_info(topology, obj, "board_vendor", "DMIBoardVendor");
-  hwloc__get_dmi_one_info(topology, obj, "board_name", "DMIBoardName");
-  hwloc__get_dmi_one_info(topology, obj, "board_version", "DMIBoardVersion");
-  hwloc__get_dmi_one_info(topology, obj, "board_serial", "DMIBoardSerial");
-  hwloc__get_dmi_one_info(topology, obj, "board_asset_tag", "DMIBoardAssetTag");
-  hwloc__get_dmi_one_info(topology, obj, "chassis_vendor", "DMIChassisVendor");
-  hwloc__get_dmi_one_info(topology, obj, "chassis_type", "DMIChassisType");
-  hwloc__get_dmi_one_info(topology, obj, "chassis_version", "DMIChassisVersion");
-  hwloc__get_dmi_one_info(topology, obj, "chassis_serial", "DMIChassisSerial");
-  hwloc__get_dmi_one_info(topology, obj, "chassis_asset_tag", "DMIChassisAssetTag");
-  hwloc__get_dmi_one_info(topology, obj, "bios_vendor", "DMIBIOSVendor");
-  hwloc__get_dmi_one_info(topology, obj, "bios_version", "DMIBIOSVersion");
-  hwloc__get_dmi_one_info(topology, obj, "bios_date", "DMIBIOSDate");
-  hwloc__get_dmi_one_info(topology, obj, "sys_vendor", "DMISysVendor");
+  hwloc__get_dmi_one_info(data, obj, "product_name", "DMIProductName");
+  hwloc__get_dmi_one_info(data, obj, "product_version", "DMIProductVersion");
+  hwloc__get_dmi_one_info(data, obj, "product_serial", "DMIProductSerial");
+  hwloc__get_dmi_one_info(data, obj, "product_uuid", "DMIProductUUID");
+  hwloc__get_dmi_one_info(data, obj, "board_vendor", "DMIBoardVendor");
+  hwloc__get_dmi_one_info(data, obj, "board_name", "DMIBoardName");
+  hwloc__get_dmi_one_info(data, obj, "board_version", "DMIBoardVersion");
+  hwloc__get_dmi_one_info(data, obj, "board_serial", "DMIBoardSerial");
+  hwloc__get_dmi_one_info(data, obj, "board_asset_tag", "DMIBoardAssetTag");
+  hwloc__get_dmi_one_info(data, obj, "chassis_vendor", "DMIChassisVendor");
+  hwloc__get_dmi_one_info(data, obj, "chassis_type", "DMIChassisType");
+  hwloc__get_dmi_one_info(data, obj, "chassis_version", "DMIChassisVersion");
+  hwloc__get_dmi_one_info(data, obj, "chassis_serial", "DMIChassisSerial");
+  hwloc__get_dmi_one_info(data, obj, "chassis_asset_tag", "DMIChassisAssetTag");
+  hwloc__get_dmi_one_info(data, obj, "bios_vendor", "DMIBIOSVendor");
+  hwloc__get_dmi_one_info(data, obj, "bios_version", "DMIBIOSVersion");
+  hwloc__get_dmi_one_info(data, obj, "bios_date", "DMIBIOSDate");
+  hwloc__get_dmi_one_info(data, obj, "sys_vendor", "DMISysVendor");
 }
 
 static void
@@ -3240,31 +3221,35 @@
     hwloc_setup_pu_level(topology, 1);
 }
 
-void
-hwloc_look_linuxfs(struct hwloc_topology *topology)
+static int
+hwloc_look_linuxfs(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
+  struct hwloc_linux_backend_data_s *data = backend->private_data;
   DIR *nodes_dir;
   unsigned nbnodes;
   char *cpuset_mntpnt, *cgroup_mntpnt, *cpuset_name = NULL;
   int err;
 
-  memset(&topology->backend_params.linuxfs.utsname, 0, sizeof(topology->backend_params.linuxfs.utsname));
-  if (topology->is_thissystem)
-    uname(&topology->backend_params.linuxfs.utsname);
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
 
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
   /* Gather the list of admin-disabled cpus and mems */
-  hwloc_find_linux_cpuset_mntpnt(&cgroup_mntpnt, &cpuset_mntpnt, topology->backend_params.linuxfs.root_fd);
+  hwloc_find_linux_cpuset_mntpnt(&cgroup_mntpnt, &cpuset_mntpnt, data->root_fd);
   if (cgroup_mntpnt || cpuset_mntpnt) {
-    cpuset_name = hwloc_read_linux_cpuset_name(topology->backend_params.linuxfs.root_fd, topology->pid);
+    cpuset_name = hwloc_read_linux_cpuset_name(data->root_fd, topology->pid);
     if (cpuset_name) {
-      hwloc_admin_disable_set_from_cpuset(topology, cgroup_mntpnt, cpuset_mntpnt, cpuset_name, "cpus", topology->levels[0][0]->allowed_cpuset);
-      hwloc_admin_disable_set_from_cpuset(topology, cgroup_mntpnt, cpuset_mntpnt, cpuset_name, "mems", topology->levels[0][0]->allowed_nodeset);
+      hwloc_admin_disable_set_from_cpuset(data, cgroup_mntpnt, cpuset_mntpnt, cpuset_name, "cpus", topology->levels[0][0]->allowed_cpuset);
+      hwloc_admin_disable_set_from_cpuset(data, cgroup_mntpnt, cpuset_mntpnt, cpuset_name, "mems", topology->levels[0][0]->allowed_nodeset);
     }
     free(cgroup_mntpnt);
     free(cpuset_mntpnt);
   }
 
-  nodes_dir = hwloc_opendir("/proc/nodes", topology->backend_params.linuxfs.root_fd);
+  nodes_dir = hwloc_opendir("/proc/nodes", data->root_fd);
   if (nodes_dir) {
     /* Kerrighed */
     struct dirent *dirent;
@@ -3286,7 +3271,7 @@
       machine_online_set = hwloc_bitmap_alloc();
       node = strtoul(dirent->d_name+4, NULL, 0);
       snprintf(path, sizeof(path), "/proc/nodes/node%lu/cpuinfo", node);
-      err = look_cpuinfo(topology, path, machine_online_set);
+      err = look_cpuinfo(topology, data, path, machine_online_set);
       if (err < 0)
         continue;
       hwloc_bitmap_or(topology->levels[0][0]->online_cpuset, topology->levels[0][0]->online_cpuset, machine_online_set);
@@ -3297,20 +3282,20 @@
       hwloc_insert_object_by_cpuset(topology, machine);
 
       /* Get the machine memory attributes */
-      hwloc_get_kerrighed_node_meminfo_info(topology, node, &machine->memory);
+      hwloc_get_kerrighed_node_meminfo_info(topology, data, node, &machine->memory);
 
       /* Gather DMI info */
       /* FIXME: get the right DMI info of each machine */
-      hwloc__get_dmi_info(topology, machine);
+      hwloc__get_dmi_info(data, machine);
     }
     closedir(nodes_dir);
   } else {
     /* Get the machine memory attributes */
-    hwloc_get_procfs_meminfo_info(topology, &topology->levels[0][0]->memory);
+    hwloc_get_procfs_meminfo_info(topology, data, &topology->levels[0][0]->memory);
 
     /* Gather NUMA information. Must be after hwloc_get_procfs_meminfo_info so that the hugepage size is known */
-    if (look_sysfsnode(topology, "/sys/bus/node/devices", &nbnodes) < 0)
-      look_sysfsnode(topology, "/sys/devices/system/node", &nbnodes);
+    if (look_sysfsnode(topology, data, "/sys/bus/node/devices", &nbnodes) < 0)
+      look_sysfsnode(topology, data, "/sys/devices/system/node", &nbnodes);
 
     /* if we found some numa nodes, the machine object has no local memory */
     if (nbnodes) {
@@ -3323,23 +3308,23 @@
 
     /* Gather the list of cpus now */
     if (getenv("HWLOC_LINUX_USE_CPUINFO")
-	|| (hwloc_access("/sys/devices/system/cpu/cpu0/topology/core_siblings", R_OK, topology->backend_params.linuxfs.root_fd) < 0
-	    && hwloc_access("/sys/devices/system/cpu/cpu0/topology/thread_siblings", R_OK, topology->backend_params.linuxfs.root_fd) < 0
-	    && hwloc_access("/sys/bus/cpu/devices/cpu0/topology/thread_siblings", R_OK, topology->backend_params.linuxfs.root_fd) < 0
-	    && hwloc_access("/sys/bus/cpu/devices/cpu0/topology/core_siblings", R_OK, topology->backend_params.linuxfs.root_fd) < 0)) {
+	|| (hwloc_access("/sys/devices/system/cpu/cpu0/topology/core_siblings", R_OK, data->root_fd) < 0
+	    && hwloc_access("/sys/devices/system/cpu/cpu0/topology/thread_siblings", R_OK, data->root_fd) < 0
+	    && hwloc_access("/sys/bus/cpu/devices/cpu0/topology/thread_siblings", R_OK, data->root_fd) < 0
+	    && hwloc_access("/sys/bus/cpu/devices/cpu0/topology/core_siblings", R_OK, data->root_fd) < 0)) {
 	/* revert to reading cpuinfo only if /sys/.../topology unavailable (before 2.6.16)
 	 * or not containing anything interesting */
-      err = look_cpuinfo(topology, "/proc/cpuinfo", topology->levels[0][0]->online_cpuset);
+      err = look_cpuinfo(topology, data, "/proc/cpuinfo", topology->levels[0][0]->online_cpuset);
       if (err < 0)
 	hwloc_linux_fallback_pu_level(topology);
 
     } else {
       struct hwloc_linux_cpuinfo_proc * Lprocs = NULL;
-      int numprocs = hwloc_linux_parse_cpuinfo(topology, "/proc/cpuinfo", &Lprocs);
+      int numprocs = hwloc_linux_parse_cpuinfo(data, "/proc/cpuinfo", &Lprocs);
       if (numprocs <= 0)
 	Lprocs = NULL;
-      if (look_sysfscpu(topology, "/sys/bus/cpu/devices", Lprocs, numprocs) < 0)
-        if (look_sysfscpu(topology, "/sys/devices/system/cpu", Lprocs, numprocs) < 0)
+      if (look_sysfscpu(topology, data, "/sys/bus/cpu/devices", Lprocs, numprocs) < 0)
+        if (look_sysfscpu(topology, data, "/sys/devices/system/cpu", Lprocs, numprocs) < 0)
 	  /* sysfs but we failed to read cpu topology, fallback */
 	  hwloc_linux_fallback_pu_level(topology);
       if (Lprocs)
@@ -3347,7 +3332,7 @@
     }
 
     /* Gather DMI info */
-    hwloc__get_dmi_info(topology, topology->levels[0][0]);
+    hwloc__get_dmi_info(data, topology->levels[0][0]);
   }
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "Linux");
@@ -3358,44 +3343,46 @@
 
   /* gather uname info if fsroot wasn't changed */
   if (topology->is_thissystem)
-     /* FIXME: reuse topology->backend_params.linuxfs.utsname */
      hwloc_add_uname_info(topology);
+
+  return 1;
 }
 
 void
-hwloc_set_linuxfs_hooks(struct hwloc_topology *topology)
+hwloc_set_linuxfs_hooks(struct hwloc_binding_hooks *hooks,
+			struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
-  topology->set_thisthread_cpubind = hwloc_linux_set_thisthread_cpubind;
-  topology->get_thisthread_cpubind = hwloc_linux_get_thisthread_cpubind;
-  topology->set_thisproc_cpubind = hwloc_linux_set_thisproc_cpubind;
-  topology->get_thisproc_cpubind = hwloc_linux_get_thisproc_cpubind;
-  topology->set_proc_cpubind = hwloc_linux_set_proc_cpubind;
-  topology->get_proc_cpubind = hwloc_linux_get_proc_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_linux_set_thisthread_cpubind;
+  hooks->get_thisthread_cpubind = hwloc_linux_get_thisthread_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_linux_set_thisproc_cpubind;
+  hooks->get_thisproc_cpubind = hwloc_linux_get_thisproc_cpubind;
+  hooks->set_proc_cpubind = hwloc_linux_set_proc_cpubind;
+  hooks->get_proc_cpubind = hwloc_linux_get_proc_cpubind;
 #if HAVE_DECL_PTHREAD_SETAFFINITY_NP
-  topology->set_thread_cpubind = hwloc_linux_set_thread_cpubind;
+  hooks->set_thread_cpubind = hwloc_linux_set_thread_cpubind;
 #endif /* HAVE_DECL_PTHREAD_SETAFFINITY_NP */
 #if HAVE_DECL_PTHREAD_GETAFFINITY_NP
-  topology->get_thread_cpubind = hwloc_linux_get_thread_cpubind;
+  hooks->get_thread_cpubind = hwloc_linux_get_thread_cpubind;
 #endif /* HAVE_DECL_PTHREAD_GETAFFINITY_NP */
-  topology->get_thisthread_last_cpu_location = hwloc_linux_get_thisthread_last_cpu_location;
-  topology->get_thisproc_last_cpu_location = hwloc_linux_get_thisproc_last_cpu_location;
-  topology->get_proc_last_cpu_location = hwloc_linux_get_proc_last_cpu_location;
+  hooks->get_thisthread_last_cpu_location = hwloc_linux_get_thisthread_last_cpu_location;
+  hooks->get_thisproc_last_cpu_location = hwloc_linux_get_thisproc_last_cpu_location;
+  hooks->get_proc_last_cpu_location = hwloc_linux_get_proc_last_cpu_location;
 #ifdef HWLOC_HAVE_SET_MEMPOLICY
-  topology->set_thisthread_membind = hwloc_linux_set_thisthread_membind;
-  topology->get_thisthread_membind = hwloc_linux_get_thisthread_membind;
-  topology->get_area_membind = hwloc_linux_get_area_membind;
+  hooks->set_thisthread_membind = hwloc_linux_set_thisthread_membind;
+  hooks->get_thisthread_membind = hwloc_linux_get_thisthread_membind;
+  hooks->get_area_membind = hwloc_linux_get_area_membind;
 #endif /* HWLOC_HAVE_SET_MEMPOLICY */
 #ifdef HWLOC_HAVE_MBIND
-  topology->set_area_membind = hwloc_linux_set_area_membind;
-  topology->alloc_membind = hwloc_linux_alloc_membind;
-  topology->alloc = hwloc_alloc_mmap;
-  topology->free_membind = hwloc_free_mmap;
-  topology->support.membind->firsttouch_membind = 1;
-  topology->support.membind->bind_membind = 1;
-  topology->support.membind->interleave_membind = 1;
+  hooks->set_area_membind = hwloc_linux_set_area_membind;
+  hooks->alloc_membind = hwloc_linux_alloc_membind;
+  hooks->alloc = hwloc_alloc_mmap;
+  hooks->free_membind = hwloc_free_mmap;
+  support->membind->firsttouch_membind = 1;
+  support->membind->bind_membind = 1;
+  support->membind->interleave_membind = 1;
 #endif /* HWLOC_HAVE_MBIND */
 #if (defined HWLOC_HAVE_MIGRATE_PAGES) || ((defined HWLOC_HAVE_MBIND) && (defined MPOL_MF_MOVE))
-  topology->support.membind->migrate_membind = 1;
+  support->membind->migrate_membind = 1;
 #endif
 }
 
@@ -3421,7 +3408,7 @@
 typedef void (*hwloc_linux_class_fillinfos_t)(struct hwloc_topology *topology, struct hwloc_obj *osdev, const char *osdevpath);
 
 /* look for objects of the given class below a sysfs directory */
-static void
+static int
 hwloc_linux_class_readdir(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *devicepath,
 			  hwloc_obj_osdev_type_t type, const char *classname,
 			  hwloc_linux_class_fillinfos_t fillinfo)
@@ -3431,6 +3418,7 @@
   DIR *dir;
   struct dirent *dirent;
   hwloc_obj_t obj;
+  int res = 0;
 
   snprintf(path, sizeof(path), "%s/%s", devicepath, classname);
   dir = opendir(path);
@@ -3444,6 +3432,7 @@
 	snprintf(path, sizeof(path), "%s/%s/%s", devicepath, classname, dirent->d_name);
 	fillinfo(topology, obj, path);
       }
+      res++;
     }
     closedir(dir);
   } else {
@@ -3458,10 +3447,13 @@
 	  snprintf(path, sizeof(path), "%s/%s", devicepath, dirent->d_name);
 	  fillinfo(topology, obj, path);
 	}
+	res++;
       }
       closedir(dir);
     }
   }
+
+  return res;
 }
 
 /* class objects that are immediately below pci devices */
@@ -3503,25 +3495,121 @@
     }
   }
 }
+
 static void
+hwloc_linux_infiniband_class_fillinfos(struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *obj, const char *osdevpath)
+{
+  FILE *fd;
+  char path[256];
+  unsigned i,j;
+
+  snprintf(path, sizeof(path), "%s/node_guid", osdevpath);
+  fd = fopen(path, "r");
+  if (fd) {
+    char guidvalue[20];
+    if (fgets(guidvalue, sizeof(guidvalue), fd)) {
+      size_t len;
+      len = strspn(guidvalue, "0123456789abcdefx:");
+      assert(len == 19);
+      guidvalue[len] = '\0';
+      hwloc_obj_add_info(obj, "NodeGUID", guidvalue);
+    }
+    fclose(fd);
+  }
+
+  snprintf(path, sizeof(path), "%s/sys_image_guid", osdevpath);
+  fd = fopen(path, "r");
+  if (fd) {
+    char guidvalue[20];
+    if (fgets(guidvalue, sizeof(guidvalue), fd)) {
+      size_t len;
+      len = strspn(guidvalue, "0123456789abcdefx:");
+      assert(len == 19);
+      guidvalue[len] = '\0';
+      hwloc_obj_add_info(obj, "SysImageGUID", guidvalue);
+    }
+    fclose(fd);
+  }
+
+  for(i=1; ; i++) {
+    snprintf(path, sizeof(path), "%s/ports/%u/lid", osdevpath, i);
+    fd = fopen(path, "r");
+    if (fd) {
+      char lidvalue[11];
+      if (fgets(lidvalue, sizeof(lidvalue), fd)) {
+	char lidname[32];
+	size_t len;
+	len = strspn(lidvalue, "0123456789abcdefx");
+	lidvalue[len] = '\0';
+	snprintf(lidname, sizeof(lidname), "Port%uLID", i);
+	hwloc_obj_add_info(obj, lidname, lidvalue);
+      }
+      fclose(fd);
+    } else {
+      /* no such port */
+      break;
+    }
+
+    snprintf(path, sizeof(path), "%s/ports/%u/lid_mask_count", osdevpath, i);
+    fd = fopen(path, "r");
+    if (fd) {
+      char lidvalue[11];
+      if (fgets(lidvalue, sizeof(lidvalue), fd)) {
+	char lidname[32];
+	size_t len;
+	len = strspn(lidvalue, "0123456789");
+	lidvalue[len] = '\0';
+	snprintf(lidname, sizeof(lidname), "Port%uLMC", i);
+	hwloc_obj_add_info(obj, lidname, lidvalue);
+      }
+      fclose(fd);
+    }
+
+    for(j=0; ; j++) {
+      snprintf(path, sizeof(path), "%s/ports/%u/gids/%u", osdevpath, i, j);
+      fd = fopen(path, "r");
+      if (fd) {
+	char gidvalue[40];
+	if (fgets(gidvalue, sizeof(gidvalue), fd)) {
+	  char gidname[32];
+	  size_t len;
+	  len = strspn(gidvalue, "0123456789abcdefx:");
+	  assert(len == 39);
+	  gidvalue[len] = '\0';
+	  if (strncmp(gidvalue+20, "0000:0000:0000:0000", 19)) {
+	    /* only keep initialized GIDs */
+	    snprintf(gidname, sizeof(gidname), "Port%uGID%u", i, j);
+	    hwloc_obj_add_info(obj, gidname, gidvalue);
+	  }
+	}
+	fclose(fd);
+      } else {
+	/* no such port */
+	break;
+      }
+    }
+  }
+}
+
+static int
 hwloc_linux_lookup_net_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)
 {
-  hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_NETWORK, "net", hwloc_linux_net_class_fillinfos);
+  return hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_NETWORK, "net", hwloc_linux_net_class_fillinfos);
 }
-static void
+static int
 hwloc_linux_lookup_openfabrics_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)
 {
-  hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_OPENFABRICS, "infiniband", NULL);
+  return hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_OPENFABRICS, "infiniband", hwloc_linux_infiniband_class_fillinfos);
 }
-static void
+static int
 hwloc_linux_lookup_dma_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)
 {
-  hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_DMA, "dma", NULL);
+  return hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_DMA, "dma", NULL);
 }
-static void
+static int
 hwloc_linux_lookup_drm_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)
 {
-  hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_GPU, "drm", NULL);
+  return hwloc_linux_class_readdir(topology, pcidev, pcidevpath, HWLOC_OBJ_OSDEV_GPU, "drm", NULL);
 
   /* we could look at the "graphics" class too, but it doesn't help for proprietary drivers either */
 
@@ -3538,22 +3626,26 @@
  * or
  * ide%d/%d.%d/
  * below pci devices */
-static void
+static int
 hwloc_linux_lookup_host_block_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, char *path, size_t pathlen)
 {
   DIR *hostdir, *portdir, *targetdir;
   struct dirent *hostdirent, *portdirent, *targetdirent;
+  size_t hostdlen, portdlen, targetdlen;
   int dummy;
+  int res = 0;
+
   hostdir = opendir(path);
   if (!hostdir)
-    return;
+    return 0;
+
   while ((hostdirent = readdir(hostdir)) != NULL) {
     if (sscanf(hostdirent->d_name, "port-%d:%d", &dummy, &dummy) == 2)
     {
       /* found host%d/port-%d:%d */
       path[pathlen] = '/';
       strcpy(&path[pathlen+1], hostdirent->d_name);
-      pathlen += 1+strlen(hostdirent->d_name);
+      pathlen += hostdlen = 1+strlen(hostdirent->d_name);
       portdir = opendir(path);
       if (!portdir)
 	continue;
@@ -3562,22 +3654,23 @@
 	  /* found host%d/port-%d:%d/end_device-%d:%d */
 	  path[pathlen] = '/';
 	  strcpy(&path[pathlen+1], portdirent->d_name);
-	  pathlen += 1+strlen(portdirent->d_name);
-	  hwloc_linux_lookup_host_block_class(topology, pcidev, path, pathlen);
-	  pathlen -= 1+strlen(portdirent->d_name);
+	  pathlen += portdlen = 1+strlen(portdirent->d_name);
+	  res += hwloc_linux_lookup_host_block_class(topology, pcidev, path, pathlen);
+	  /* restore parent path */
+	  pathlen -= portdlen;
 	  path[pathlen] = '\0';
 	}
       }
       closedir(portdir);
       /* restore parent path */
-      pathlen -= 1+strlen(hostdirent->d_name);
+      pathlen -= hostdlen;
       path[pathlen] = '\0';
       continue;
     } else if (sscanf(hostdirent->d_name, "target%d:%d:%d", &dummy, &dummy, &dummy) == 3) {
       /* found host%d/target%d:%d:%d */
       path[pathlen] = '/';
       strcpy(&path[pathlen+1], hostdirent->d_name);
-      pathlen += 1+strlen(hostdirent->d_name);
+      pathlen += hostdlen = 1+strlen(hostdirent->d_name);
       targetdir = opendir(path);
       if (!targetdir)
 	continue;
@@ -3587,43 +3680,48 @@
 	/* found host%d/target%d:%d:%d/%d:%d:%d:%d */
 	path[pathlen] = '/';
 	strcpy(&path[pathlen+1], targetdirent->d_name);
-	pathlen += 1+strlen(targetdirent->d_name);
+	pathlen += targetdlen = 1+strlen(targetdirent->d_name);
 	/* lookup block class for real */
-	hwloc_linux_class_readdir(topology, pcidev, path, HWLOC_OBJ_OSDEV_BLOCK, "block", NULL);
+	res += hwloc_linux_class_readdir(topology, pcidev, path, HWLOC_OBJ_OSDEV_BLOCK, "block", NULL);
 	/* restore parent path */
-	pathlen -= 1+strlen(targetdirent->d_name);
+	pathlen -= targetdlen;
 	path[pathlen] = '\0';
       }
       closedir(targetdir);
       /* restore parent path */
-      pathlen -= 1+strlen(hostdirent->d_name);
+      pathlen -= hostdlen;
       path[pathlen] = '\0';
     }
   }
   closedir(hostdir);
+
+  return res;
 }
 
-static void
+static int
 hwloc_linux_lookup_block_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)
 {
   size_t pathlen;
   DIR *devicedir, *hostdir;
   struct dirent *devicedirent, *hostdirent;
+  size_t devicedlen, hostdlen;
   char path[256];
   int dummy;
+  int res = 0;
 
   strcpy(path, pcidevpath);
   pathlen = strlen(path);
 
   devicedir = opendir(pcidevpath);
   if (!devicedir)
-    return;
+    return 0;
+
   while ((devicedirent = readdir(devicedir)) != NULL) {
     if (sscanf(devicedirent->d_name, "ide%d", &dummy) == 1) {
       /* found ide%d */
       path[pathlen] = '/';
       strcpy(&path[pathlen+1], devicedirent->d_name);
-      pathlen += 1+strlen(devicedirent->d_name);
+      pathlen += devicedlen = 1+strlen(devicedirent->d_name);
       hostdir = opendir(path);
       if (!hostdir)
 	continue;
@@ -3632,67 +3730,118 @@
 	  /* found ide%d/%d.%d */
 	  path[pathlen] = '/';
 	  strcpy(&path[pathlen+1], hostdirent->d_name);
-	  pathlen += 1+strlen(hostdirent->d_name);
+	  pathlen += hostdlen = 1+strlen(hostdirent->d_name);
 	  /* lookup block class for real */
-	  hwloc_linux_class_readdir(topology, pcidev, path, HWLOC_OBJ_OSDEV_BLOCK, "block", NULL);
+	  res += hwloc_linux_class_readdir(topology, pcidev, path, HWLOC_OBJ_OSDEV_BLOCK, "block", NULL);
 	  /* restore parent path */
-	  pathlen -= 1+strlen(hostdirent->d_name);
+	  pathlen -= hostdlen;
 	  path[pathlen] = '\0';
 	}
       }
+      closedir(hostdir);
+      /* restore parent path */
+      pathlen -= devicedlen;
+      path[pathlen] = '\0';
     } else if (sscanf(devicedirent->d_name, "host%d", &dummy) == 1) {
       /* found host%d */
       path[pathlen] = '/';
       strcpy(&path[pathlen+1], devicedirent->d_name);
-      pathlen += 1+strlen(devicedirent->d_name);
-      hwloc_linux_lookup_host_block_class(topology, pcidev, path, pathlen);
+      pathlen += devicedlen = 1+strlen(devicedirent->d_name);
+      res += hwloc_linux_lookup_host_block_class(topology, pcidev, path, pathlen);
       /* restore parent path */
-      pathlen -= 1+strlen(devicedirent->d_name);
+      pathlen -= devicedlen;
       path[pathlen] = '\0';
+    } else if (sscanf(devicedirent->d_name, "ata%d", &dummy) == 1) {
+      /* found ata%d */
+      path[pathlen] = '/';
+      strcpy(&path[pathlen+1], devicedirent->d_name);
+      pathlen += devicedlen = 1+strlen(devicedirent->d_name);
+      hostdir = opendir(path);
+      if (!hostdir)
+	continue;
+      while ((hostdirent = readdir(hostdir)) != NULL) {
+	if (sscanf(hostdirent->d_name, "host%d", &dummy) == 1) {
+	  /* found ata%d/host%d */
+	  path[pathlen] = '/';
+	  strcpy(&path[pathlen+1], hostdirent->d_name);
+	  pathlen += hostdlen = 1+strlen(hostdirent->d_name);
+	  /* lookup block class for real */
+          res += hwloc_linux_lookup_host_block_class(topology, pcidev, path, pathlen);
+	  /* restore parent path */
+	  pathlen -= hostdlen;
+	  path[pathlen] = '\0';
+	}
+      }
+      closedir(hostdir);
+      /* restore parent path */
+      pathlen -= devicedlen;
+      path[pathlen] = '\0';
     }
   }
   closedir(devicedir);
+
+  return res;
 }
 
-void
-hwloc_linuxfs_pci_lookup_osdevices(struct hwloc_topology *topology, struct hwloc_obj *pcidev)
+static int
+hwloc_linux_backend_notify_new_object(struct hwloc_backend *backend, struct hwloc_backend *caller __hwloc_attribute_unused,
+				      struct hwloc_obj *obj)
 {
+  struct hwloc_topology *topology = backend->topology;
+  struct hwloc_linux_backend_data_s *data = backend->private_data;
   char pcidevpath[256];
+  int res = 0;
 
+  /* this callback is only used in the libpci backend for now */
+  assert(obj->type == HWLOC_OBJ_PCI_DEVICE);
+
   /* this should not be called if the backend isn't the real OS one */
-  if (topology->backend_params.linuxfs.root_path) {
-    assert(strlen(topology->backend_params.linuxfs.root_path) == 1);
-    assert(topology->backend_params.linuxfs.root_path[0] == '/');
+#ifdef HWLOC_DEBUG
+  assert(!strcmp(backend->component->name, "linux"));
+#endif
+  if (data->root_path) {
+    assert(strlen(data->root_path) == 1);
+    assert(data->root_path[0] == '/');
   }
 
   snprintf(pcidevpath, sizeof(pcidevpath), "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/",
-	   pcidev->attr->pcidev.domain, pcidev->attr->pcidev.bus,
-	   pcidev->attr->pcidev.dev, pcidev->attr->pcidev.func);
+	   obj->attr->pcidev.domain, obj->attr->pcidev.bus,
+	   obj->attr->pcidev.dev, obj->attr->pcidev.func);
 
-  hwloc_linux_lookup_net_class(topology, pcidev, pcidevpath);
-  hwloc_linux_lookup_openfabrics_class(topology, pcidev, pcidevpath);
-  hwloc_linux_lookup_dma_class(topology, pcidev, pcidevpath);
-  hwloc_linux_lookup_drm_class(topology, pcidev, pcidevpath);
-  hwloc_linux_lookup_block_class(topology, pcidev, pcidevpath);
+  res += hwloc_linux_lookup_net_class(topology, obj, pcidevpath);
+  res += hwloc_linux_lookup_openfabrics_class(topology, obj, pcidevpath);
+  res += hwloc_linux_lookup_dma_class(topology, obj, pcidevpath);
+  res += hwloc_linux_lookup_drm_class(topology, obj, pcidevpath);
+  res += hwloc_linux_lookup_block_class(topology, obj, pcidevpath);
+  return res;
 }
 
-int
-hwloc_linuxfs_get_pcidev_cpuset(struct hwloc_topology *topology __hwloc_attribute_unused,
-				struct hwloc_obj *pcidev, hwloc_bitmap_t cpuset)
+static int
+hwloc_linux_backend_get_obj_cpuset(struct hwloc_backend *backend,
+				   struct hwloc_backend *caller __hwloc_attribute_unused,
+				   struct hwloc_obj *obj, hwloc_bitmap_t cpuset)
 {
+  struct hwloc_linux_backend_data_s *data = backend->private_data;
   char path[256];
   FILE *file;
   int err;
 
+  /* this callback is only used in the libpci backend for now */
+  assert(obj->type == HWLOC_OBJ_PCI_DEVICE
+	 || (obj->type == HWLOC_OBJ_BRIDGE && obj->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI));
+
   /* this should not be called if the backend isn't the real OS one */
-  if (topology->backend_params.linuxfs.root_path) {
-    assert(strlen(topology->backend_params.linuxfs.root_path) == 1);
-    assert(topology->backend_params.linuxfs.root_path[0] == '/');
+#ifdef HWLOC_DEBUG
+  assert(!strcmp(backend->component->name, "linux"));
+#endif
+  if (data->root_path) {
+    assert(strlen(data->root_path) == 1);
+    assert(data->root_path[0] == '/');
   }
 
   snprintf(path, sizeof(path), "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/local_cpus",
-	   pcidev->attr->pcidev.domain, pcidev->attr->pcidev.bus,
-	   pcidev->attr->pcidev.dev, pcidev->attr->pcidev.func);
+	   obj->attr->pcidev.domain, obj->attr->pcidev.bus,
+	   obj->attr->pcidev.dev, obj->attr->pcidev.func);
   file = fopen(path, "r"); /* the libpci backend doesn't use sysfs.fsroot */
   if (file) {
     err = hwloc_linux_parse_cpumap_file(file, cpuset);
@@ -3702,3 +3851,90 @@
   }
   return -1;
 }
+
+static void
+hwloc_linux_backend_disable(struct hwloc_backend *backend)
+{
+  struct hwloc_linux_backend_data_s *data = backend->private_data;
+#ifdef HAVE_OPENAT
+  close(data->root_fd);
+  free(data->root_path);
+  data->root_path = NULL;
+#endif
+  free(data);
+}
+
+static struct hwloc_backend *
+hwloc_linux_component_instantiate(struct hwloc_disc_component *component,
+				  const void *_data1,
+				  const void *_data2 __hwloc_attribute_unused,
+				  const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  struct hwloc_linux_backend_data_s *data;
+  const char * fsroot_path = _data1;
+  int root = -1;
+
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    goto out;
+
+  data = malloc(sizeof(*data));
+  if (!data) {
+    errno = ENOMEM;
+    goto out_with_backend;
+  }
+
+  backend->private_data = data;
+  backend->discover = hwloc_look_linuxfs;
+  backend->get_obj_cpuset = hwloc_linux_backend_get_obj_cpuset;
+  backend->notify_new_object = hwloc_linux_backend_notify_new_object;
+  backend->disable = hwloc_linux_backend_disable;
+
+  if (!fsroot_path)
+    fsroot_path = "/";
+
+#ifdef HAVE_OPENAT
+  root = open(fsroot_path, O_RDONLY | O_DIRECTORY);
+  if (root < 0)
+    goto out_with_data;
+
+  if (strcmp(fsroot_path, "/"))
+    backend->is_thissystem = 0;
+
+  data->root_path = strdup(fsroot_path);
+#else
+  if (strcmp(fsroot_path, "/")) {
+    errno = ENOSYS;
+    goto out_with_data;
+  }
+
+  data->root_path = NULL;
+#endif
+  data->root_fd = root;
+
+  return backend;
+
+ out_with_data:
+  free(data);
+ out_with_backend:
+  free(backend);
+ out:
+  return NULL;
+}
+
+static struct hwloc_disc_component hwloc_linux_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "linux",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_linux_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_linux_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_linux_disc_component
+};

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-noos.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-noos.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-noos.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2009 CNRS
+ * Copyright © 2009-2012 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.
+ */
+
+#include <private/autogen/config.h>
+#include <hwloc.h>
+#include <private/private.h>
+
+static int
+hwloc_look_noos(struct hwloc_backend *backend)
+{
+  struct hwloc_topology *topology = backend->topology;
+
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+  hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
+}
+
+static struct hwloc_backend *
+hwloc_noos_component_instantiate(struct hwloc_disc_component *component,
+				 const void *_data1 __hwloc_attribute_unused,
+				 const void *_data2 __hwloc_attribute_unused,
+				 const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_noos;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_noos_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "no_os",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_noos_component_instantiate,
+  40, /* lower than native OS component, higher than globals */
+  NULL
+};
+
+const struct hwloc_component hwloc_noos_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_noos_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-osf.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-osf.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-osf.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -41,7 +41,7 @@
  */
 
 static int
-prepare_radset(hwloc_topology_t topology, radset_t *radset, hwloc_const_bitmap_t hwloc_set)
+prepare_radset(hwloc_topology_t topology __hwloc_attribute_unused, radset_t *radset, hwloc_const_bitmap_t hwloc_set)
 {
   unsigned cpu;
   cpuset_t target_cpuset;
@@ -49,6 +49,7 @@
   radid_t radid;
   int ret = 0;
   int ret_errno = 0;
+  int nbnodes = rad_get_num();
 
   cpusetcreate(&target_cpuset);
   cpuemptyset(target_cpuset);
@@ -58,7 +59,7 @@
 
   cpusetcreate(&cpuset);
   cpusetcreate(&xor_cpuset);
-  for (radid = 0; radid < topology->backend_params.osf.nbnodes; radid++) {
+  for (radid = 0; radid < nbnodes; radid++) {
     cpuemptyset(cpuset);
     if (rad_get_cpus(radid, cpuset)==-1) {
       fprintf(stderr,"rad_get_cpus(%d) failed: %s\n",radid,strerror(errno));
@@ -236,9 +237,10 @@
   return ptr;
 }
 
-void
-hwloc_look_osf(struct hwloc_topology *topology)
+static int
+hwloc_look_osf(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   cpu_cursor_t cursor;
   unsigned nbnodes;
   radid_t radid, radid2;
@@ -248,8 +250,14 @@
   struct hwloc_obj *obj;
   unsigned distance;
 
-  topology->backend_params.osf.nbnodes = nbnodes = rad_get_num();
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
 
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
+  nbnodes = rad_get_num();
+
   cpusetcreate(&cpuset);
   radsetcreate(&radset);
   radsetcreate(&radset2);
@@ -276,11 +284,11 @@
       indexes[radid] = radid;
       nodes[radid] = obj = hwloc_alloc_setup_object(HWLOC_OBJ_NODE, radid);
       obj->cpuset = hwloc_bitmap_alloc();
-      obj->memory.local_memory = rad_get_physmem(radid) * getpagesize();
+      obj->memory.local_memory = rad_get_physmem(radid) * hwloc_getpagesize();
       obj->memory.page_types_len = 2;
       obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types));
       memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types));
-      obj->memory.page_types[0].size = getpagesize();
+      obj->memory.page_types[0].size = hwloc_getpagesize();
 #ifdef HAVE__SC_LARGE_PAGESIZE
       obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE);
 #endif
@@ -327,21 +335,55 @@
   hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "OSF");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_osf_hooks(struct hwloc_topology *topology)
+hwloc_set_osf_hooks(struct hwloc_binding_hooks *hooks,
+		    struct hwloc_topology_support *support)
 {
-  topology->set_thread_cpubind = hwloc_osf_set_thread_cpubind;
-  topology->set_thisthread_cpubind = hwloc_osf_set_thisthread_cpubind;
-  topology->set_proc_cpubind = hwloc_osf_set_proc_cpubind;
-  topology->set_thisproc_cpubind = hwloc_osf_set_thisproc_cpubind;
-  topology->set_area_membind = hwloc_osf_set_area_membind;
-  topology->alloc_membind = hwloc_osf_alloc_membind;
-  topology->alloc = hwloc_alloc_mmap;
-  topology->free_membind = hwloc_free_mmap;
-  topology->support.membind->firsttouch_membind = 1;
-  topology->support.membind->bind_membind = 1;
-  topology->support.membind->interleave_membind = 1;
-  topology->support.membind->replicate_membind = 1;
+  hooks->set_thread_cpubind = hwloc_osf_set_thread_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_osf_set_thisthread_cpubind;
+  hooks->set_proc_cpubind = hwloc_osf_set_proc_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_osf_set_thisproc_cpubind;
+  hooks->set_area_membind = hwloc_osf_set_area_membind;
+  hooks->alloc_membind = hwloc_osf_alloc_membind;
+  hooks->alloc = hwloc_alloc_mmap;
+  hooks->free_membind = hwloc_free_mmap;
+  support->membind->firsttouch_membind = 1;
+  support->membind->bind_membind = 1;
+  support->membind->interleave_membind = 1;
+  support->membind->replicate_membind = 1;
 }
+
+static struct hwloc_backend *
+hwloc_osf_component_instantiate(struct hwloc_disc_component *component,
+				const void *_data1 __hwloc_attribute_unused,
+				const void *_data2 __hwloc_attribute_unused,
+				const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_osf;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_osf_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "osf",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_osf_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_osf_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_osf_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris-chiptype.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris-chiptype.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris-chiptype.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -294,7 +294,13 @@
   picl_shutdown();
 
   if (called_cpu_probe) {
+#if (defined HWLOC_X86_64_ARCH) || (defined HWLOC_X86_32_ARCH)
+      /* PICL returns some corrupted chip_type strings on x86,
+       * and CPUType only used on Sparc anyway, at least for now.
+       * So we just ignore this attribute on x86. */
+#else
       strncpy(chip_type, dss_chip_type, PICL_PROPNAMELEN_MAX);
+#endif
   } else {
       /* no picl information on machine available */
       sysinfo(SI_HW_PROVIDER, chip_type, PICL_PROPNAMELEN_MAX);

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-solaris.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -374,7 +374,7 @@
     obj->memory.page_types_len = 2;
     obj->memory.page_types = malloc(2*sizeof(*obj->memory.page_types));
     memset(obj->memory.page_types, 0, 2*sizeof(*obj->memory.page_types));
-    obj->memory.page_types[0].size = getpagesize();
+    obj->memory.page_types[0].size = hwloc_getpagesize();
 #ifdef HAVE__SC_LARGE_PAGESIZE
     obj->memory.page_types[1].size = sysconf(_SC_LARGE_PAGESIZE);
 #endif
@@ -708,45 +708,89 @@
 }
 #endif /* LIBKSTAT */
 
-void
-hwloc_look_solaris(struct hwloc_topology *topology)
+static int
+hwloc_look_solaris(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   unsigned nbprocs = hwloc_fallback_nbprocessors (topology);
+  int alreadypus = 0;
+
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
 #ifdef HAVE_LIBLGRP
   hwloc_look_lgrp(topology);
 #endif /* HAVE_LIBLGRP */
 #ifdef HAVE_LIBKSTAT
   nbprocs = 0;
-  if (hwloc_look_kstat(topology))
-    return;
+  if (hwloc_look_kstat(topology) > 0)
+    alreadypus = 1;
 #endif /* HAVE_LIBKSTAT */
-  hwloc_setup_pu_level(topology, nbprocs);
+  if (!alreadypus)
+    hwloc_setup_pu_level(topology, nbprocs);
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "Solaris");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_solaris_hooks(struct hwloc_topology *topology)
+hwloc_set_solaris_hooks(struct hwloc_binding_hooks *hooks,
+			struct hwloc_topology_support *support __hwloc_attribute_unused)
 {
-  topology->set_proc_cpubind = hwloc_solaris_set_proc_cpubind;
-  topology->set_thisproc_cpubind = hwloc_solaris_set_thisproc_cpubind;
-  topology->set_thisthread_cpubind = hwloc_solaris_set_thisthread_cpubind;
+  hooks->set_proc_cpubind = hwloc_solaris_set_proc_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_solaris_set_thisproc_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_solaris_set_thisthread_cpubind;
 #ifdef HAVE_LIBLGRP
-  topology->get_proc_cpubind = hwloc_solaris_get_proc_cpubind;
-  topology->get_thisproc_cpubind = hwloc_solaris_get_thisproc_cpubind;
-  topology->get_thisthread_cpubind = hwloc_solaris_get_thisthread_cpubind;
-  topology->set_proc_membind = hwloc_solaris_set_proc_membind;
-  topology->set_thisproc_membind = hwloc_solaris_set_thisproc_membind;
-  topology->set_thisthread_membind = hwloc_solaris_set_thisthread_membind;
-  topology->get_proc_membind = hwloc_solaris_get_proc_membind;
-  topology->get_thisproc_membind = hwloc_solaris_get_thisproc_membind;
-  topology->get_thisthread_membind = hwloc_solaris_get_thisthread_membind;
+  hooks->get_proc_cpubind = hwloc_solaris_get_proc_cpubind;
+  hooks->get_thisproc_cpubind = hwloc_solaris_get_thisproc_cpubind;
+  hooks->get_thisthread_cpubind = hwloc_solaris_get_thisthread_cpubind;
+  hooks->set_proc_membind = hwloc_solaris_set_proc_membind;
+  hooks->set_thisproc_membind = hwloc_solaris_set_thisproc_membind;
+  hooks->set_thisthread_membind = hwloc_solaris_set_thisthread_membind;
+  hooks->get_proc_membind = hwloc_solaris_get_proc_membind;
+  hooks->get_thisproc_membind = hwloc_solaris_get_thisproc_membind;
+  hooks->get_thisthread_membind = hwloc_solaris_get_thisthread_membind;
 #endif /* HAVE_LIBLGRP */
 #ifdef MADV_ACCESS_LWP 
-  topology->set_area_membind = hwloc_solaris_set_area_membind;
-  topology->support.membind->firsttouch_membind = 1;
-  topology->support.membind->bind_membind = 1;
-  topology->support.membind->interleave_membind = 1;
-  topology->support.membind->nexttouch_membind = 1;
+  hooks->set_area_membind = hwloc_solaris_set_area_membind;
+  support->membind->firsttouch_membind = 1;
+  support->membind->bind_membind = 1;
+  support->membind->interleave_membind = 1;
+  support->membind->nexttouch_membind = 1;
 #endif
 }
+
+static struct hwloc_backend *
+hwloc_solaris_component_instantiate(struct hwloc_disc_component *component,
+				    const void *_data1 __hwloc_attribute_unused,
+				    const void *_data2 __hwloc_attribute_unused,
+				    const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_solaris;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_solaris_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "solaris",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_solaris_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_solaris_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_solaris_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-synthetic.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-synthetic.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-synthetic.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -18,11 +18,22 @@
 #include <strings.h>
 #endif
 
-/* Read from DESCRIPTION a series of integers describing a symmetrical
-   topology and update `topology->synthetic_description' accordingly.  On
+struct hwloc_synthetic_backend_data_s {
+  /* synthetic backend parameters */
+  char *string;
+#define HWLOC_SYNTHETIC_MAX_DEPTH 128
+  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 */
+};
+
+/* Read from description a series of integers describing a symmetrical
+   topology and update the hwloc_synthetic_backend_data_s accordingly.  On
    success, return zero.  */
-int
-hwloc_backend_synthetic_init(struct hwloc_topology *topology, const char *description)
+static int
+hwloc_backend_synthetic_init(struct hwloc_synthetic_backend_data_s *data,
+			     const char *description)
 {
   const char *pos, *next_pos;
   unsigned long item, count;
@@ -36,8 +47,6 @@
   if (env)
     verbose = atoi(env);
 
-  assert(topology->backend_type == HWLOC_BACKEND_NONE);
-
   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;
@@ -98,8 +107,8 @@
       return -1;
     }
 
-    topology->backend_params.synthetic.arity[count-1] = (unsigned)item;
-    topology->backend_params.synthetic.type[count] = type;
+    data->arity[count-1] = (unsigned)item;
+    data->type[count] = type;
     count++;
   }
 
@@ -113,13 +122,13 @@
   for(i=count-1; i>0; i--) {
     hwloc_obj_type_t type;
 
-    type = topology->backend_params.synthetic.type[i];
+    type = data->type[i];
 
     if (type == HWLOC_OBJ_TYPE_UNKNOWN) {
       if (i == count-1)
 	type = HWLOC_OBJ_PU;
       else {
-	switch (topology->backend_params.synthetic.type[i+1]) {
+	switch (data->type[i+1]) {
 	case HWLOC_OBJ_PU: type = HWLOC_OBJ_CORE; break;
 	case HWLOC_OBJ_CORE: type = HWLOC_OBJ_CACHE; break;
 	case HWLOC_OBJ_CACHE: type = HWLOC_OBJ_SOCKET; break;
@@ -132,7 +141,7 @@
 	  assert(0);
 	}
       }
-      topology->backend_params.synthetic.type[i] = type;
+      data->type[i] = type;
     }
     switch (type) {
       case HWLOC_OBJ_PU:
@@ -188,9 +197,9 @@
   }
 
   if (nb_machine_levels)
-    topology->backend_params.synthetic.type[0] = HWLOC_OBJ_SYSTEM;
+    data->type[0] = HWLOC_OBJ_SYSTEM;
   else {
-    topology->backend_params.synthetic.type[0] = HWLOC_OBJ_MACHINE;
+    data->type[0] = HWLOC_OBJ_MACHINE;
     nb_machine_levels++;
   }
 
@@ -199,30 +208,20 @@
     cache_depth = 2;
 
   for (i=0; i<count; i++) {
-    hwloc_obj_type_t type = topology->backend_params.synthetic.type[i];
+    hwloc_obj_type_t type = data->type[i];
 
     if (type == HWLOC_OBJ_GROUP)
-      topology->backend_params.synthetic.depth[i] = group_depth--;
+      data->depth[i] = group_depth--;
     else if (type == HWLOC_OBJ_CACHE)
-      topology->backend_params.synthetic.depth[i] = cache_depth--;
+      data->depth[i] = cache_depth--;
   }
 
-  topology->backend_type = HWLOC_BACKEND_SYNTHETIC;
-  topology->backend_params.synthetic.string = strdup(description);
-  topology->backend_params.synthetic.arity[count-1] = 0;
-  topology->is_thissystem = 0;
+  data->string = strdup(description);
+  data->arity[count-1] = 0;
 
   return 0;
 }
 
-void
-hwloc_backend_synthetic_exit(struct hwloc_topology *topology)
-{
-  assert(topology->backend_type == HWLOC_BACKEND_SYNTHETIC);
-  free(topology->backend_params.synthetic.string);
-  topology->backend_type = HWLOC_BACKEND_NONE;
-}
-
 /*
  * Recursively build objects whose cpu start at first_cpu
  * - level gives where to look in the type, arity and id arrays
@@ -233,12 +232,13 @@
  */
 static unsigned
 hwloc__look_synthetic(struct hwloc_topology *topology,
-    int level, unsigned first_cpu,
-    hwloc_bitmap_t parent_cpuset)
+		      struct hwloc_synthetic_backend_data_s *data,
+		      int level, unsigned first_cpu,
+		      hwloc_bitmap_t parent_cpuset)
 {
   hwloc_obj_t obj;
   unsigned i;
-  hwloc_obj_type_t type = topology->backend_params.synthetic.type[level];
+  hwloc_obj_type_t type = data->type[level];
 
   /* pre-hooks */
   switch (type) {
@@ -271,14 +271,14 @@
       break;
   }
 
-  obj = hwloc_alloc_setup_object(type, topology->backend_params.synthetic.id[level]++);
+  obj = hwloc_alloc_setup_object(type, data->id[level]++);
   obj->cpuset = hwloc_bitmap_alloc();
 
-  if (!topology->backend_params.synthetic.arity[level]) {
+  if (!data->arity[level]) {
     hwloc_bitmap_set(obj->cpuset, first_cpu++);
   } else {
-    for (i = 0; i < topology->backend_params.synthetic.arity[level]; i++)
-      first_cpu = hwloc__look_synthetic(topology, level + 1, first_cpu, obj->cpuset);
+    for (i = 0; i < data->arity[level]; i++)
+      first_cpu = hwloc__look_synthetic(topology, data, level + 1, first_cpu, obj->cpuset);
   }
 
   if (type == HWLOC_OBJ_NODE) {
@@ -293,7 +293,7 @@
     case HWLOC_OBJ_MISC:
       break;
     case HWLOC_OBJ_GROUP:
-      obj->attr->group.depth = topology->backend_params.synthetic.depth[level];
+      obj->attr->group.depth = data->depth[level];
       break;
     case HWLOC_OBJ_SYSTEM:
     case HWLOC_OBJ_BRIDGE:
@@ -315,7 +315,7 @@
     case HWLOC_OBJ_SOCKET:
       break;
     case HWLOC_OBJ_CACHE:
-      obj->attr->cache.depth = topology->backend_params.synthetic.depth[level];
+      obj->attr->cache.depth = data->depth[level];
       obj->attr->cache.linesize = 64;
       if (obj->attr->cache.depth == 1) {
 	/* 32Kb in L1d */
@@ -342,29 +342,103 @@
   return first_cpu;
 }
 
-void
-hwloc_look_synthetic(struct hwloc_topology *topology)
+static int
+hwloc_look_synthetic(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
+  struct hwloc_synthetic_backend_data_s *data = backend->private_data;
   hwloc_bitmap_t cpuset = hwloc_bitmap_alloc();
   unsigned first_cpu = 0, i;
 
+  assert(!topology->levels[0][0]->cpuset);
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
   topology->support.discovery->pu = 1;
 
   /* start with id=0 for each level */
-  for (i = 0; topology->backend_params.synthetic.arity[i] > 0; i++)
-    topology->backend_params.synthetic.id[i] = 0;
+  for (i = 0; data->arity[i] > 0; i++)
+    data->id[i] = 0;
   /* ... including the last one */
-  topology->backend_params.synthetic.id[i] = 0;
+  data->id[i] = 0;
 
   /* update first level type according to the synthetic type array */
-  topology->levels[0][0]->type = topology->backend_params.synthetic.type[0];
+  topology->levels[0][0]->type = data->type[0];
 
-  for (i = 0; i < topology->backend_params.synthetic.arity[0]; i++)
-    first_cpu = hwloc__look_synthetic(topology, 1, first_cpu, cpuset);
+  for (i = 0; i < data->arity[0]; i++)
+    first_cpu = hwloc__look_synthetic(topology, data, 1, first_cpu, cpuset);
 
   hwloc_bitmap_free(cpuset);
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "Synthetic");
-  hwloc_obj_add_info(topology->levels[0][0], "SyntheticDescription", topology->backend_params.synthetic.string);
+  hwloc_obj_add_info(topology->levels[0][0], "SyntheticDescription", data->string);
+  return 1;
 }
 
+static void
+hwloc_synthetic_backend_disable(struct hwloc_backend *backend)
+{
+  struct hwloc_synthetic_backend_data_s *data = backend->private_data;
+  free(data->string);
+  free(data);
+}
+
+static struct hwloc_backend *
+hwloc_synthetic_component_instantiate(struct hwloc_disc_component *component,
+				      const void *_data1,
+				      const void *_data2 __hwloc_attribute_unused,
+				      const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  struct hwloc_synthetic_backend_data_s *data;
+  int err;
+
+  if (!_data1) {
+    errno = EINVAL;
+    goto out;
+  }
+
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    goto out;
+
+  data = malloc(sizeof(*data));
+  if (!data) {
+    errno = ENOMEM;
+    goto out_with_backend;
+  }
+
+  err = hwloc_backend_synthetic_init(data, (const char *) _data1);
+  if (err < 0)
+    goto out_with_data;
+
+  backend->private_data = data;
+  backend->discover = hwloc_look_synthetic;
+  backend->disable = hwloc_synthetic_backend_disable;
+  backend->is_thissystem = 0;
+
+  return backend;
+
+ out_with_data:
+  free(data);
+ out_with_backend:
+  free(backend);
+ out:
+  return NULL;
+}
+
+static struct hwloc_disc_component hwloc_synthetic_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  "synthetic",
+  HWLOC_DISC_COMPONENT_TYPE_CPU | HWLOC_DISC_COMPONENT_TYPE_GLOBAL | HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL,
+  hwloc_synthetic_component_instantiate,
+  30,
+  NULL
+};
+
+const struct hwloc_component hwloc_synthetic_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_synthetic_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-windows.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-windows.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-windows.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2012 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -472,9 +472,10 @@
   }
 }
 
-void
-hwloc_look_windows(struct hwloc_topology *topology)
+static int
+hwloc_look_windows(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
   BOOL (WINAPI *GetLogicalProcessorInformationProc)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, PDWORD ReturnLength);
   BOOL (WINAPI *GetLogicalProcessorInformationExProc)(LOGICAL_PROCESSOR_RELATIONSHIP relationship, PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, PDWORD ReturnLength);
   BOOL (WINAPI *GetNumaAvailableMemoryNodeProc)(UCHAR Node, PULONGLONG AvailableBytes);
@@ -485,6 +486,12 @@
 
   HMODULE kernel32;
 
+  if (topology->levels[0][0]->cpuset)
+    /* somebody discovered things */
+    return 0;
+
+  hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+
   GetSystemInfo(&SystemInfo);
 
   kernel32 = LoadLibrary("kernel32.dll");
@@ -508,7 +515,7 @@
 	if (GetLogicalProcessorInformationProc(procInfo, &length))
 	  break;
 	if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
-	  return;
+	  return -1;
 	procInfo = realloc(procInfo, length);
       }
 
@@ -615,7 +622,7 @@
 	if (GetLogicalProcessorInformationExProc(RelationAll, procInfoTotal, &length))
 	  break;
 	if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
-	  return;
+	  return -1;
         procInfoTotal = realloc(procInfoTotal, length);
       }
 
@@ -738,32 +745,66 @@
   hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
 
   hwloc_obj_add_info(topology->levels[0][0], "Backend", "Windows");
+  if (topology->is_thissystem)
+    hwloc_add_uname_info(topology);
+  return 1;
 }
 
 void
-hwloc_set_windows_hooks(struct hwloc_topology *topology)
+hwloc_set_windows_hooks(struct hwloc_binding_hooks *hooks,
+			struct hwloc_topology_support *support)
 {
-  topology->set_proc_cpubind = hwloc_win_set_proc_cpubind;
-  topology->get_proc_cpubind = hwloc_win_get_proc_cpubind;
-  topology->set_thread_cpubind = hwloc_win_set_thread_cpubind;
-  topology->set_thisproc_cpubind = hwloc_win_set_thisproc_cpubind;
-  topology->get_thisproc_cpubind = hwloc_win_get_thisproc_cpubind;
-  topology->set_thisthread_cpubind = hwloc_win_set_thisthread_cpubind;
+  hooks->set_proc_cpubind = hwloc_win_set_proc_cpubind;
+  hooks->get_proc_cpubind = hwloc_win_get_proc_cpubind;
+  hooks->set_thread_cpubind = hwloc_win_set_thread_cpubind;
+  hooks->set_thisproc_cpubind = hwloc_win_set_thisproc_cpubind;
+  hooks->get_thisproc_cpubind = hwloc_win_get_thisproc_cpubind;
+  hooks->set_thisthread_cpubind = hwloc_win_set_thisthread_cpubind;
   /* TODO: get_last_cpu_location: use GetCurrentProcessorNumber */
 
-  topology->set_proc_membind = hwloc_win_set_proc_membind;
-  topology->get_proc_membind = hwloc_win_get_proc_membind;
-  topology->set_thisproc_membind = hwloc_win_set_thisproc_membind;
-  topology->get_thisproc_membind = hwloc_win_get_thisproc_membind;
-  topology->set_thisthread_membind = hwloc_win_set_thisthread_membind;
+  hooks->set_proc_membind = hwloc_win_set_proc_membind;
+  hooks->get_proc_membind = hwloc_win_get_proc_membind;
+  hooks->set_thisproc_membind = hwloc_win_set_thisproc_membind;
+  hooks->get_thisproc_membind = hwloc_win_get_thisproc_membind;
+  hooks->set_thisthread_membind = hwloc_win_set_thisthread_membind;
 
   if (!hwloc_win_get_VirtualAllocExNumaProc()) {
-    topology->alloc_membind = hwloc_win_alloc_membind;
-    topology->alloc = hwloc_win_alloc;
-    topology->free_membind = hwloc_win_free_membind;
-    topology->support.membind->bind_membind = 1;
+    hooks->alloc_membind = hwloc_win_alloc_membind;
+    hooks->alloc = hwloc_win_alloc;
+    hooks->free_membind = hwloc_win_free_membind;
+    support->membind->bind_membind = 1;
   }
 
   if (!hwloc_win_get_QueryWorkingSetExProc())
-    topology->get_area_membind = hwloc_win_get_area_membind;
+    hooks->get_area_membind = hwloc_win_get_area_membind;
 }
+
+static struct hwloc_backend *
+hwloc_windows_component_instantiate(struct hwloc_disc_component *component,
+				    const void *_data1 __hwloc_attribute_unused,
+				    const void *_data2 __hwloc_attribute_unused,
+				    const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->discover = hwloc_look_windows;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_windows_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "windows",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_windows_component_instantiate,
+  50,
+  NULL
+};
+
+const struct hwloc_component hwloc_windows_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_windows_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-x86.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-x86.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-x86.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2012 inria.  All rights reserved.
+ * Copyright © 2010-2012 Inria.  All rights reserved.
  * Copyright © 2010-2012 Université Bordeaux 1
  * Copyright © 2010-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -20,7 +20,6 @@
 #include <private/debug.h>
 #include <private/misc.h>
 
-#if defined(HWLOC_HAVE_CPUID)
 #include <private/cpuid.h>
 
 #define has_topoext(features) ((features)[6] & (1 << 22))
@@ -53,6 +52,7 @@
   unsigned levels;
   unsigned numcaches;
   struct cacheinfo *cache;
+  char cpumodel[3*4*4+1];
 };
 
 enum cpuid_type {
@@ -130,6 +130,21 @@
   infos->threadid = (unsigned) -1;
   hwloc_debug("phys %u thread %u\n", infos->socketid, infos->logprocid);
 
+  if (highest_ext_cpuid >= 0x80000004) {
+    unsigned regs[4] = { 0 };
+    regs[0] = 0x80000002;
+    hwloc_cpuid(&regs[0], &regs[1], &regs[2], &regs[3]);
+    memcpy(infos->cpumodel, regs, 4*4);
+    regs[0] = 0x80000003;
+    hwloc_cpuid(&regs[0], &regs[1], &regs[2], &regs[3]);
+    memcpy(infos->cpumodel + 4*4, regs, 4*4);
+    regs[0] = 0x80000004;
+    hwloc_cpuid(&regs[0], &regs[1], &regs[2], &regs[3]);
+    memcpy(infos->cpumodel + 4*4*2, regs, 4*4);
+    infos->cpumodel[3*4*4] = 0;
+  } else
+    infos->cpumodel[0] = 0;
+
   /* Intel doesn't actually provide 0x80000008 information */
   if (cpuid_type != intel && highest_ext_cpuid >= 0x80000008) {
     unsigned coreidsize;
@@ -338,11 +353,13 @@
     infos->otherids = NULL;
 }
 
-/* Analyse information stored in infos, and build topology levels accordingly */
-static void summarize(hwloc_topology_t topology, struct procinfo *infos, unsigned nbprocs)
+/* Analyse information stored in infos, and build/annotate topology levels accordingly */
+static void summarize(hwloc_topology_t topology, struct procinfo *infos, unsigned nbprocs,
+		      int fulldiscovery)
 {
   hwloc_bitmap_t complete_cpuset = hwloc_bitmap_alloc();
   unsigned i, j, l, level, type;
+  unsigned nbsockets = 0;
   int one = -1;
 
   for (i = 0; i < nbprocs; i++)
@@ -356,8 +373,13 @@
     return;
   }
 
+  /* Ideally, when fulldiscovery=0, we could add any object that doesn't exist yet.
+   * But what if the x86 and the native backends disagree because one is buggy? Which one to trust?
+   * Only annotate existing objects for now.
+   */
+
   /* Look for sockets */
-  {
+  if (fulldiscovery) {
     hwloc_bitmap_t sockets_cpuset = hwloc_bitmap_dup(complete_cpuset);
     hwloc_bitmap_t socket_cpuset;
     hwloc_obj_t socket;
@@ -374,15 +396,74 @@
       }
       socket = hwloc_alloc_setup_object(HWLOC_OBJ_SOCKET, socketid);
       socket->cpuset = socket_cpuset;
+      if (infos[i].cpumodel[0]) {
+        const char *c = infos[i].cpumodel;
+        while (*c == ' ')
+          c++;
+        hwloc_obj_add_info(socket, "CPUModel", c);
+      }
       hwloc_debug_1arg_bitmap("os socket %u has cpuset %s\n",
           socketid, socket_cpuset);
       hwloc_insert_object_by_cpuset(topology, socket);
+      nbsockets++;
     }
     hwloc_bitmap_free(sockets_cpuset);
+
+  } else {
+    /* Annotate sockets previously-existing sockets */
+    hwloc_obj_t socket = NULL;
+    int same = 1;
+    nbsockets = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_SOCKET);
+    /* check whether all sockets have the same info */
+    for(i=1; i<nbprocs; i++) {
+      if (strcmp(infos[i].cpumodel, infos[0].cpumodel)) {
+	same = 0;
+	break;
+      }
+    }
+    /* now iterate over sockets and annotate them */
+    while ((socket = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_SOCKET, socket)) != NULL) {
+      if (socket->os_index == (unsigned) -1) {
+	/* try to fix the socket OS index if unknown.
+	 * FIXME: ideally, we should check all bits in case x86 and the native backend disagree.
+	 */
+	for(i=0; i<nbprocs; i++) {
+	  if (hwloc_bitmap_isset(socket->cpuset, i)) {
+	    socket->os_index = infos[i].socketid;
+	    break;
+	  }
+	}
+      }
+      if (!hwloc_obj_get_info_by_name(socket, "CPUModel")) {
+	/* add a CPUModel info */
+	for(i=0; i<nbprocs; i++)
+	  /* if there's a single socket, it's the one we want.
+	   * if the index is ok, it's the one we want.
+	   * if the index is unknown but all sockets have the same id, that's fine
+	   */
+	  if (nbsockets == 1 || infos[i].socketid == socket->os_index || (same && socket->os_index == (unsigned) -1)) {
+	    if (infos[i].cpumodel[0]) {
+	      const char *c = infos[i].cpumodel;
+	      while (*c == ' ')
+		c++;
+	      hwloc_obj_add_info(socket, "CPUModel", c);
+	    }
+	    break;
+	  }
+      }
+    }
   }
+  /* If there was no socket, annotate the Machine instead */
+  if ((!nbsockets) && infos[0].cpumodel[0]) {
+    const char *c = infos[0].cpumodel;
+    while (*c == ' ')
+      c++;
+    hwloc_obj_add_info(hwloc_get_root_obj(topology), "CPUModel", c);
+  }
 
+
   /* Look for Numa nodes inside sockets */
-  {
+  if (fulldiscovery) {
     hwloc_bitmap_t nodes_cpuset = hwloc_bitmap_dup(complete_cpuset);
     hwloc_bitmap_t node_cpuset;
     hwloc_obj_t node;
@@ -418,7 +499,7 @@
   }
 
   /* Look for Compute units inside sockets */
-  {
+  if (fulldiscovery) {
     hwloc_bitmap_t units_cpuset = hwloc_bitmap_dup(complete_cpuset);
     hwloc_bitmap_t unit_cpuset;
     hwloc_obj_t unit;
@@ -484,7 +565,7 @@
   }
 
   /* Look for cores */
-  {
+  if (fulldiscovery) {
     hwloc_bitmap_t cores_cpuset = hwloc_bitmap_dup(complete_cpuset);
     hwloc_bitmap_t core_cpuset;
     hwloc_obj_t core;
@@ -528,7 +609,7 @@
         level = infos[i].cache[j].level;
 
   /* Look for known types */
-  while (level > 0) {
+  if (fulldiscovery) while (level > 0) {
     for (type = 1; type <= 3; type++) {
       /* Look for caches of that type at level level */
       {
@@ -607,6 +688,28 @@
   hwloc_bitmap_free(complete_cpuset);
 }
 
+#if defined HWLOC_FREEBSD_SYS && defined HAVE_CPUSET_SETID
+#include <sys/param.h>
+#include <sys/cpuset.h>
+typedef cpusetid_t hwloc_x86_os_state_t;
+static void hwloc_x86_os_state_save(hwloc_x86_os_state_t *state)
+{
+  /* temporary make all cpus available during discovery */
+  cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, state);
+  cpuset_setid(CPU_WHICH_PID, -1, 0);
+}
+static void hwloc_x86_os_state_restore(hwloc_x86_os_state_t *state)
+{
+  /* restore initial cpuset */
+  cpuset_setid(CPU_WHICH_PID, -1, *state);
+}
+#else /* !defined HWLOC_FREEBSD_SYS || !defined HAVE_CPUSET_SETID */
+typedef void * hwloc_x86_os_state_t;
+static void hwloc_x86_os_state_save(hwloc_x86_os_state_t *state __hwloc_attribute_unused) { }
+static void hwloc_x86_os_state_restore(hwloc_x86_os_state_t *state __hwloc_attribute_unused) { }
+#endif /* !defined HWLOC_FREEBSD_SYS || !defined HAVE_CPUSET_SETID */
+
+
 #define INTEL_EBX ('G' | ('e'<<8) | ('n'<<16) | ('u'<<24))
 #define INTEL_EDX ('i' | ('n'<<8) | ('e'<<16) | ('I'<<24))
 #define INTEL_ECX ('n' | ('t'<<8) | ('e'<<16) | ('l'<<24))
@@ -614,12 +717,10 @@
 #define AMD_EBX ('A' | ('u'<<8) | ('t'<<16) | ('h'<<24))
 #define AMD_EDX ('e' | ('n'<<8) | ('t'<<16) | ('i'<<24))
 #define AMD_ECX ('c' | ('A'<<8) | ('M'<<16) | ('D'<<24))
-#endif
 
-void hwloc_look_x86(struct hwloc_topology *topology, unsigned nbprocs __hwloc_attribute_unused)
+static
+int hwloc_look_x86(struct hwloc_topology *topology, unsigned nbprocs, int fulldiscovery)
 {
-    /* This function must always be here, but it's ok if it's empty. */
-#if defined(HWLOC_HAVE_CPUID)
   unsigned eax, ebx, ecx = 0, edx;
   hwloc_bitmap_t orig_cpuset;
   unsigned i;
@@ -629,14 +730,25 @@
   unsigned features[10] = { 0 };
   struct procinfo *infos = NULL;
   enum cpuid_type cpuid_type = unknown;
+  hwloc_x86_os_state_t os_state;
+  struct hwloc_binding_hooks hooks;
+  struct hwloc_topology_support support;
+  struct hwloc_topology_membind_support memsupport __hwloc_attribute_unused;
+  int ret = -1;
 
+  memset(&hooks, 0, sizeof(hooks));
+  support.membind = &memsupport;
+  hwloc_set_native_binding_hooks(&hooks, &support);
+  if (!(hooks.get_thisproc_cpubind && hooks.set_thisproc_cpubind)
+   && !(hooks.get_thisthread_cpubind && hooks.set_thisthread_cpubind))
+    goto out;
+
   if (!hwloc_have_cpuid())
-    return;
+    goto out;
 
   infos = malloc(sizeof(struct procinfo) * nbprocs);
-  if (NULL == infos) {
-      return;
-  }
+  if (NULL == infos)
+    goto out;
 
   eax = 0x00;
   hwloc_cpuid(&eax, &ebx, &ecx, &edx);
@@ -648,7 +760,7 @@
 
   hwloc_debug("highest cpuid %x, cpuid type %u\n", highest_cpuid, cpuid_type);
   if (highest_cpuid < 0x01) {
-      goto free;
+      goto out_with_infos;
   }
 
   eax = 0x01;
@@ -675,49 +787,133 @@
     features[6] = ecx;
   }
 
+  hwloc_x86_os_state_save(&os_state);
+
   orig_cpuset = hwloc_bitmap_alloc();
 
-  if (topology->get_thisthread_cpubind && topology->set_thisthread_cpubind) {
-    if (!topology->get_thisthread_cpubind(topology, orig_cpuset, HWLOC_CPUBIND_STRICT)) {
+  if (hooks.get_thisthread_cpubind && hooks.set_thisthread_cpubind) {
+    if (!hooks.get_thisthread_cpubind(topology, orig_cpuset, HWLOC_CPUBIND_STRICT)) {
       hwloc_bitmap_t cpuset = hwloc_bitmap_alloc();
       for (i = 0; i < nbprocs; i++) {
         hwloc_bitmap_only(cpuset, i);
-        if (topology->set_thisthread_cpubind(topology, cpuset, HWLOC_CPUBIND_STRICT))
+        hwloc_debug("binding to CPU%d\n", i);
+        if (hooks.set_thisthread_cpubind(topology, cpuset, HWLOC_CPUBIND_STRICT)) {
+          hwloc_debug("could not bind to CPU%d: %s\n", i, strerror(errno));
           continue;
+        }
         look_proc(&infos[i], highest_cpuid, highest_ext_cpuid, features, cpuid_type);
       }
       hwloc_bitmap_free(cpuset);
-      topology->set_thisthread_cpubind(topology, orig_cpuset, 0);
+      hooks.set_thisthread_cpubind(topology, orig_cpuset, 0);
       hwloc_bitmap_free(orig_cpuset);
-      summarize(topology, infos, nbprocs);
-      goto free;
+      summarize(topology, infos, nbprocs, fulldiscovery);
+      ret = fulldiscovery; /* success, but objects added only if fulldiscovery */
+      goto out_with_os_state;
     }
   }
-  if (topology->get_thisproc_cpubind && topology->set_thisproc_cpubind) {
-    if (!topology->get_thisproc_cpubind(topology, orig_cpuset, HWLOC_CPUBIND_STRICT)) {
+  if (hooks.get_thisproc_cpubind && hooks.set_thisproc_cpubind) {
+    if (!hooks.get_thisproc_cpubind(topology, orig_cpuset, HWLOC_CPUBIND_STRICT)) {
       hwloc_bitmap_t cpuset = hwloc_bitmap_alloc();
       for (i = 0; i < nbprocs; i++) {
         hwloc_bitmap_only(cpuset, i);
-        if (topology->set_thisproc_cpubind(topology, cpuset, HWLOC_CPUBIND_STRICT))
+        hwloc_debug("binding to CPU%d\n", i);
+        if (hooks.set_thisproc_cpubind(topology, cpuset, HWLOC_CPUBIND_STRICT)) {
+          hwloc_debug("could not bind to CPU%d: %s\n", i, strerror(errno));
           continue;
+        }
         look_proc(&infos[i], highest_cpuid, highest_ext_cpuid, features, cpuid_type);
       }
       hwloc_bitmap_free(cpuset);
-      topology->set_thisproc_cpubind(topology, orig_cpuset, 0);
+      hooks.set_thisproc_cpubind(topology, orig_cpuset, 0);
       hwloc_bitmap_free(orig_cpuset);
-      summarize(topology, infos, nbprocs);
-      goto free;
+      summarize(topology, infos, nbprocs, fulldiscovery);
+      ret = fulldiscovery; /* success, but objects added only if fulldiscovery */
+      goto out_with_os_state;
     }
   }
   hwloc_bitmap_free(orig_cpuset);
-#endif
 
-  hwloc_obj_add_info(topology->levels[0][0], "Backend", "x86");
+out_with_os_state:
+  hwloc_x86_os_state_restore(&os_state);
 
-#if defined(HWLOC_HAVE_CPUID)
- free:
+out_with_infos:
   if (NULL != infos) {
       free(infos);
   }
-#endif
+
+out:
+  return ret;
 }
+
+static int
+hwloc_x86_discover(struct hwloc_backend *backend)
+{
+  struct hwloc_topology *topology = backend->topology;
+  unsigned nbprocs = hwloc_fallback_nbprocessors(topology);
+  int alreadypus = 0;
+  int ret;
+
+  if (!topology->is_thissystem) {
+    hwloc_debug("%s", "\nno x86 detection (not thissystem)\n");
+    return 0;
+  }
+
+  if (topology->levels[0][0]->cpuset) {
+    /* somebody else discovered things */
+    if (topology->nb_levels == 2 && topology->level_nbobjects[1] == nbprocs) {
+      /* only PUs were discovered, as much as we would, complete the topology with everything else */
+      alreadypus = 1;
+      goto fulldiscovery;
+    }
+
+    /* several object types were added, we can't easily complete, just annotate a bit */
+    ret = hwloc_look_x86(topology, nbprocs, 0);
+    if (ret)
+      hwloc_obj_add_info(topology->levels[0][0], "Backend", "x86");
+    return 0;
+  } else {
+    /* topology is empty, initialize it */
+    hwloc_alloc_obj_cpusets(topology->levels[0][0]);
+  }
+
+fulldiscovery:
+  hwloc_look_x86(topology, nbprocs, 1);
+  /* if failed, just continue and create PUs */
+
+  if (!alreadypus)
+    hwloc_setup_pu_level(topology, nbprocs);
+
+  hwloc_obj_add_info(topology->levels[0][0], "Backend", "x86");
+  return 1;
+}
+
+static struct hwloc_backend *
+hwloc_x86_component_instantiate(struct hwloc_disc_component *component,
+				const void *_data1 __hwloc_attribute_unused,
+				const void *_data2 __hwloc_attribute_unused,
+				const void *_data3 __hwloc_attribute_unused)
+{
+  struct hwloc_backend *backend;
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    return NULL;
+  backend->flags = HWLOC_BACKEND_FLAG_NEED_LEVELS;
+  backend->discover = hwloc_x86_discover;
+  return backend;
+}
+
+static struct hwloc_disc_component hwloc_x86_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_CPU,
+  "x86",
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  hwloc_x86_component_instantiate,
+  45, /* between native and no_os */
+  NULL
+};
+
+const struct hwloc_component hwloc_x86_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_x86_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-libxml.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-libxml.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-libxml.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -89,6 +89,8 @@
   childstate->find_child = state->find_child;
   childstate->close_tag = state->close_tag;
   childstate->close_child = state->close_child;
+  childstate->get_content = state->get_content;
+  childstate->close_content = state->close_content;
   if (!lstate->child)
     return 0;
   child = lstate->child->next;
@@ -124,16 +126,43 @@
 }
 
 static int
-hwloc_libxml_look(struct hwloc_topology *topology,
-		  struct hwloc__xml_import_state_s *state)
+hwloc__libxml_import_get_content(hwloc__xml_import_state_t state,
+				 char **beginp, size_t expected_length)
 {
   hwloc__libxml_import_state_data_t lstate = (void*) state->data;
+  xmlNode *child;
+  size_t length;
+
+  child = lstate->node->children;
+  if (!child)
+    return 0;
+  if (child->type != XML_TEXT_NODE)
+    return 0;
+
+  length = strlen((char *) child->content);
+  if (length != expected_length)
+    return -1;
+  *beginp = (char *) child->content;
+  return 1;
+}
+
+static void
+hwloc__libxml_import_close_content(hwloc__xml_import_state_t state __hwloc_attribute_unused)
+{
+  /* nothing to do */
+}
+
+static int
+hwloc_libxml_look_init(struct hwloc_xml_backend_data_s *bdata,
+		       struct hwloc__xml_import_state_s *state)
+{
+  hwloc__libxml_import_state_data_t lstate = (void*) state->data;
   xmlNode* root_node;
   xmlDtd *dtd;
 
   assert(sizeof(*lstate) <= sizeof(state->data));
 
-  dtd = xmlGetIntSubset((xmlDoc*) topology->backend_params.xml.data);
+  dtd = xmlGetIntSubset((xmlDoc*) bdata->data);
   if (!dtd) {
     if (hwloc__xml_verbose())
       fprintf(stderr, "Loading XML topology without DTD\n");
@@ -143,7 +172,7 @@
 	      (char *) dtd->SystemID, "hwloc.dtd");
   }
 
-  root_node = xmlDocGetRootElement((xmlDoc*) topology->backend_params.xml.data);
+  root_node = xmlDocGetRootElement((xmlDoc*) bdata->data);
 
   if (strcmp((const char *) root_node->name, "topology") && strcmp((const char *) root_node->name, "root")) {
     /* root node should be in "topology" class (or "root" if importing from < 1.0) */
@@ -156,6 +185,8 @@
   state->find_child = hwloc__libxml_import_find_child;
   state->close_tag = hwloc__libxml_import_close_tag;
   state->close_child = hwloc__libxml_import_close_child;
+  state->get_content = hwloc__libxml_import_get_content;
+  state->close_content = hwloc__libxml_import_close_content;
   state->parent = NULL;
   lstate->node = root_node;
   lstate->child = root_node->children;
@@ -171,13 +202,14 @@
  ********************/
 
 static void
-hwloc_libxml_backend_exit(struct hwloc_topology *topology)
+hwloc_libxml_backend_exit(struct hwloc_xml_backend_data_s *bdata)
 {
-  xmlFreeDoc((xmlDoc*)topology->backend_params.xml.data);
+  xmlFreeDoc((xmlDoc*)bdata->data);
 }
 
-int
-hwloc_libxml_backend_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int xmlbuflen)
+static int
+hwloc_libxml_backend_init(struct hwloc_xml_backend_data_s *bdata,
+			  const char *xmlpath, const char *xmlbuffer, int xmlbuflen)
 {
   xmlDoc *doc = NULL;
 
@@ -198,10 +230,10 @@
     return -1;
   }
 
-  topology->backend_params.xml.look = hwloc_libxml_look;
-  topology->backend_params.xml.look_failed = NULL;
-  topology->backend_params.xml.backend_exit = hwloc_libxml_backend_exit;
-  topology->backend_params.xml.data = doc;
+  bdata->look_init = hwloc_libxml_look_init;
+  bdata->look_failed = NULL;
+  bdata->backend_exit = hwloc_libxml_backend_exit;
+  bdata->data = doc;
   return 0;
 }
 
@@ -209,45 +241,57 @@
  * Export routines *
  *******************/
 
-typedef struct hwloc__libxml_export_output_data_s {
+typedef struct hwloc__libxml_export_state_data_s {
   xmlNodePtr current_node; /* current node to output */
-} * hwloc__libxml_export_output_data_t;
+} * hwloc__libxml_export_state_data_t;
 
 static void
-hwloc__libxml_export_new_child(hwloc__xml_export_output_t output, const char *name)
+hwloc__libxml_export_new_child(hwloc__xml_export_state_t parentstate,
+			       hwloc__xml_export_state_t state,
+			       const char *name)
 {
-  hwloc__libxml_export_output_data_t ldata = output->data;
-  ldata->current_node = xmlNewChild(ldata->current_node, NULL, BAD_CAST name, NULL);
+  hwloc__libxml_export_state_data_t lpdata = (void *) parentstate->data;
+  hwloc__libxml_export_state_data_t ldata = (void *) state->data;
+
+  state->parent = parentstate;
+  state->new_child = parentstate->new_child;
+  state->new_prop = parentstate->new_prop;
+  state->add_content = parentstate->add_content;
+  state->end_object = parentstate->end_object;
+
+  ldata->current_node = xmlNewChild(lpdata->current_node, NULL, BAD_CAST name, NULL);
 }
 
 static void
-hwloc__libxml_export_new_prop(hwloc__xml_export_output_t output, const char *name, const char *value)
+hwloc__libxml_export_new_prop(hwloc__xml_export_state_t state, const char *name, const char *value)
 {
-  hwloc__libxml_export_output_data_t ldata = output->data;
+  hwloc__libxml_export_state_data_t ldata = (void *) state->data;
   xmlNewProp(ldata->current_node, BAD_CAST name, BAD_CAST value);
 }
 
 static void
-hwloc__libxml_export_end_props(hwloc__xml_export_output_t output __hwloc_attribute_unused, unsigned nr_children __hwloc_attribute_unused)
+hwloc__libxml_export_end_object(hwloc__xml_export_state_t state __hwloc_attribute_unused, const char *name __hwloc_attribute_unused)
 {
   /* nothing to do */
 }
 
 static void
-hwloc__libxml_export_end_child(hwloc__xml_export_output_t output, const char *name __hwloc_attribute_unused, unsigned nr_children __hwloc_attribute_unused)
+hwloc__libxml_export_add_content(hwloc__xml_export_state_t state, const char *buffer, size_t length)
 {
-  hwloc__libxml_export_output_data_t ldata = output->data;
-  ldata->current_node = ldata->current_node->parent;
+  hwloc__libxml_export_state_data_t ldata = (void *) state->data;
+  xmlNodeAddContentLen(ldata->current_node, BAD_CAST buffer, length);
 }
 
 static xmlDocPtr
 hwloc__libxml2_prepare_export(hwloc_topology_t topology)
 {
-  struct hwloc__xml_export_output_s output;
-  struct hwloc__libxml_export_output_data_s data;
+  struct hwloc__xml_export_state_s state;
+  hwloc__libxml_export_state_data_t data = (void *) state.data;
   xmlDocPtr doc = NULL;       /* document pointer */
   xmlNodePtr root_node = NULL; /* root pointer */
 
+  assert(sizeof(*data) <= sizeof(state.data));
+
   LIBXML_TEST_VERSION;
   hwloc_libxml2_disable_stderrwarnings();
 
@@ -259,18 +303,19 @@
   /* Creates a DTD declaration. Isn't mandatory. */
   (void) xmlCreateIntSubset(doc, BAD_CAST "topology", NULL, BAD_CAST "hwloc.dtd");
 
-  output.new_child = hwloc__libxml_export_new_child;
-  output.end_child = hwloc__libxml_export_end_child;
-  output.new_prop = hwloc__libxml_export_new_prop;
-  output.end_props = hwloc__libxml_export_end_props;
-  output.data = &data;
-  data.current_node = root_node;
-  hwloc__xml_export_object (&output, topology, hwloc_get_root_obj(topology));
+  state.new_child = hwloc__libxml_export_new_child;
+  state.new_prop = hwloc__libxml_export_new_prop;
+  state.add_content = hwloc__libxml_export_add_content;
+  state.end_object = hwloc__libxml_export_end_object;
 
+  data->current_node = root_node;
+
+  hwloc__xml_export_object (&state, topology, hwloc_get_root_obj(topology));
+
   return doc;
 }
 
-int
+static int
 hwloc_libxml_export_file(hwloc_topology_t topology, const char *filename)
 {
   xmlDocPtr doc;
@@ -291,7 +336,7 @@
   return 0;
 }
 
-int
+static int
 hwloc_libxml_export_buffer(hwloc_topology_t topology, char **xmlbuffer, int *buflen)
 {
   xmlDocPtr doc = hwloc__libxml2_prepare_export(topology);
@@ -300,8 +345,31 @@
   return 0;
 }
 
-void
+static void
 hwloc_libxml_free_buffer(void *xmlbuffer)
 {
   xmlFree(BAD_CAST xmlbuffer);
 }
+
+/*************
+ * Callbacks *
+ *************/
+
+static struct hwloc_xml_callbacks hwloc_xml_libxml_callbacks = {
+  hwloc_libxml_backend_init,
+  hwloc_libxml_export_file,
+  hwloc_libxml_export_buffer,
+  hwloc_libxml_free_buffer
+};
+
+static struct hwloc_xml_component hwloc_libxml_xml_component = {
+  NULL,
+  &hwloc_xml_libxml_callbacks
+};
+
+const struct hwloc_component hwloc_xml_libxml_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_XML,
+  0,
+  &hwloc_libxml_xml_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-nolibxml.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-nolibxml.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml-nolibxml.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -109,6 +109,8 @@
   childstate->find_child = state->find_child;
   childstate->close_tag = state->close_tag;
   childstate->close_child = state->close_child;
+  childstate->get_content = state->get_content;
+  childstate->close_content = state->close_content;
 
   /* auto-closed tags have no children */
   if (nstate->closed)
@@ -194,12 +196,47 @@
 }
 
 static int
-hwloc_nolibxml_look(struct hwloc_topology *topology,
-		    struct hwloc__xml_import_state_s *state)
+hwloc__nolibxml_import_get_content(hwloc__xml_import_state_t state,
+				   char **beginp, size_t expected_length)
 {
   hwloc__nolibxml_import_state_data_t nstate = (void*) state->data;
-  char *buffer = topology->backend_params.xml.data;
+  char *buffer = nstate->tagbuffer;
+  size_t length;
+  char *end;
 
+  /* auto-closed tags have no content */
+  if (nstate->closed)
+    return 0;
+
+  /* find the next tag, where the content ends */
+  end = strchr(buffer, '<');
+  if (!end)
+    return -1;
+
+  length = (size_t) (end-buffer);
+  if (length != expected_length)
+    return -1;
+  nstate->tagbuffer = end;
+  *end = '\0'; /* mark as 0-terminated for now */
+  *beginp = buffer;
+  return 1;
+}
+
+static void
+hwloc__nolibxml_import_close_content(hwloc__xml_import_state_t state)
+{
+  /* put back the '<' that we overwrote to 0-terminate the content */
+  hwloc__nolibxml_import_state_data_t nstate = (void*) state->data;
+  *nstate->tagbuffer = '<';
+}
+
+static int
+hwloc_nolibxml_look_init(struct hwloc_xml_backend_data_s *bdata,
+			 struct hwloc__xml_import_state_s *state)
+{
+  hwloc__nolibxml_import_state_data_t nstate = (void*) state->data;
+  char *buffer = bdata->data;
+
   assert(sizeof(*nstate) <= sizeof(state->data));
 
   /* skip headers */
@@ -218,6 +255,8 @@
   state->find_child = hwloc__nolibxml_import_find_child;
   state->close_tag = hwloc__nolibxml_import_close_tag;
   state->close_child = hwloc__nolibxml_import_close_child;
+  state->get_content = hwloc__nolibxml_import_get_content;
+  state->close_content = hwloc__nolibxml_import_close_content;
   state->parent = NULL;
   nstate->closed = 0;
   nstate->tagbuffer = buffer+10;
@@ -230,7 +269,7 @@
 }
 
 static void
-hwloc_nolibxml_look_failed(struct hwloc_topology *topology __hwloc_attribute_unused)
+hwloc_nolibxml_look_failed(struct hwloc_xml_backend_data_s *bdata __hwloc_attribute_unused)
 {
   /* not only when verbose */
   fprintf(stderr, "Failed to parse XML input with the minimalistic parser. If it was not\n"
@@ -242,17 +281,18 @@
  ********************/
 
 static void
-hwloc_nolibxml_backend_exit(struct hwloc_topology *topology)
+hwloc_nolibxml_backend_exit(struct hwloc_xml_backend_data_s *bdata)
 {
-  free(topology->backend_params.xml.data);
+  free(bdata->data);
 }
 
-int
-hwloc_nolibxml_backend_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int xmlbuflen)
+static int
+hwloc_nolibxml_backend_init(struct hwloc_xml_backend_data_s *bdata,
+			    const char *xmlpath, const char *xmlbuffer, int xmlbuflen)
 {
   if (xmlbuffer) {
-    topology->backend_params.xml.data = malloc(xmlbuflen);
-    memcpy(topology->backend_params.xml.data, xmlbuffer, xmlbuflen);
+    bdata->data = malloc(xmlbuflen);
+    memcpy(bdata->data, xmlbuffer, xmlbuflen);
   } else {
     FILE * file;
     size_t buflen = 4096, offset, readlen;
@@ -283,13 +323,13 @@
 
     fclose(file);
 
-    topology->backend_params.xml.data = buffer;
+    bdata->data = buffer;
     /* buflen = offset+1; */
   }
 
-  topology->backend_params.xml.look = hwloc_nolibxml_look;
-  topology->backend_params.xml.look_failed = hwloc_nolibxml_look_failed;
-  topology->backend_params.xml.backend_exit = hwloc_nolibxml_backend_exit;
+  bdata->look_init = hwloc_nolibxml_look_init;
+  bdata->look_failed = hwloc_nolibxml_look_failed;
+  bdata->backend_exit = hwloc_nolibxml_backend_exit;
   return 0;
 }
 
@@ -297,17 +337,17 @@
  * Export routines *
  *******************/
 
-typedef struct hwloc__nolibxml_export_output_data_s {
-  struct hwloc__xml_export_output_s generic;
-
+typedef struct hwloc__nolibxml_export_state_data_s {
   char *buffer; /* (moving) buffer where to write */
   size_t written; /* how many bytes were written (or would have be written if not truncated) */
   size_t remaining; /* how many bytes are still available in the buffer */
   unsigned indent; /* indentation level for the next line */
-} * hwloc__nolibxml_export_output_data_t;
+  unsigned nr_children;
+  unsigned has_content;
+} * hwloc__nolibxml_export_state_data_t;
 
 static void
-hwloc__nolibxml_export_update_buffer(hwloc__nolibxml_export_output_data_t ndata, int res)
+hwloc__nolibxml_export_update_buffer(hwloc__nolibxml_export_state_data_t ndata, int res)
 {
   if (res >= 0) {
     ndata->written += res;
@@ -362,18 +402,43 @@
 }
 
 static void
-hwloc__nolibxml_export_new_child(hwloc__xml_export_output_t output, const char *name)
+hwloc__nolibxml_export_new_child(hwloc__xml_export_state_t parentstate,
+				 hwloc__xml_export_state_t state,
+				 const char *name)
 {
-  hwloc__nolibxml_export_output_data_t ndata = output->data;
-  int res = hwloc_snprintf(ndata->buffer, ndata->remaining, "%*s<%s", ndata->indent, "", name);
+  hwloc__nolibxml_export_state_data_t npdata = (void *) parentstate->data;
+  hwloc__nolibxml_export_state_data_t ndata = (void *) state->data;
+  int res;
+
+  assert(!npdata->has_content);
+  if (!npdata->nr_children) {
+    res = hwloc_snprintf(npdata->buffer, npdata->remaining, ">\n");
+    hwloc__nolibxml_export_update_buffer(npdata, res);
+  }
+  npdata->nr_children++;
+
+  state->parent = parentstate;
+  state->new_child = parentstate->new_child;
+  state->new_prop = parentstate->new_prop;
+  state->add_content = parentstate->add_content;
+  state->end_object = parentstate->end_object;
+
+  ndata->buffer = npdata->buffer;
+  ndata->written = npdata->written;
+  ndata->remaining = npdata->remaining;
+  ndata->indent = npdata->indent + 2;
+
+  ndata->nr_children = 0;
+  ndata->has_content = 0;
+
+  res = hwloc_snprintf(ndata->buffer, ndata->remaining, "%*s<%s", npdata->indent, "", name);
   hwloc__nolibxml_export_update_buffer(ndata, res);
-  ndata->indent += 2;
 }
 
 static void
-hwloc__nolibxml_export_new_prop(hwloc__xml_export_output_t output, const char *name, const char *value)
+hwloc__nolibxml_export_new_prop(hwloc__xml_export_state_t state, const char *name, const char *value)
 {
-  hwloc__nolibxml_export_output_data_t ndata = output->data;
+  hwloc__nolibxml_export_state_data_t ndata = (void *) state->data;
   char *escaped = hwloc__nolibxml_export_escape_string(value);
   int res = hwloc_snprintf(ndata->buffer, ndata->remaining, " %s=\"%s\"", name, escaped ? (const char *) escaped : value);
   hwloc__nolibxml_export_update_buffer(ndata, res);
@@ -381,56 +446,78 @@
 }
 
 static void
-hwloc__nolibxml_export_end_props(hwloc__xml_export_output_t output, unsigned nr_children)
+hwloc__nolibxml_export_end_object(hwloc__xml_export_state_t state, const char *name)
 {
-  hwloc__nolibxml_export_output_data_t ndata = output->data;
-  int res = hwloc_snprintf(ndata->buffer, ndata->remaining, nr_children ? ">\n" : "/>\n");
+  hwloc__nolibxml_export_state_data_t ndata = (void *) state->data;
+  hwloc__nolibxml_export_state_data_t npdata = (void *) state->parent->data;
+  int res;
+
+  assert (!(ndata->has_content && ndata->nr_children));
+  if (ndata->has_content) {
+    res = hwloc_snprintf(ndata->buffer, ndata->remaining, "</%s>\n", name);
+  } else if (ndata->nr_children) {
+    res = hwloc_snprintf(ndata->buffer, ndata->remaining, "%*s</%s>\n", npdata->indent, "", name);
+  } else {
+    res = hwloc_snprintf(ndata->buffer, ndata->remaining, "/>\n");
+  }
   hwloc__nolibxml_export_update_buffer(ndata, res);
+
+  npdata->buffer = ndata->buffer;
+  npdata->written = ndata->written;
+  npdata->remaining = ndata->remaining;
 }
 
 static void
-hwloc__nolibxml_export_end_child(hwloc__xml_export_output_t output, const char *name, unsigned nr_children)
+hwloc__nolibxml_export_add_content(hwloc__xml_export_state_t state, const char *buffer, size_t length)
 {
-  hwloc__nolibxml_export_output_data_t ndata = output->data;
+  hwloc__nolibxml_export_state_data_t ndata = (void *) state->data;
   int res;
-  ndata->indent -= 2;
-  if (nr_children) {
-    res = hwloc_snprintf(ndata->buffer, ndata->remaining, "%*s</%s>\n", ndata->indent, "", name);
+
+  assert(!ndata->nr_children);
+  if (!ndata->has_content) {
+    res = hwloc_snprintf(ndata->buffer, ndata->remaining, ">");
     hwloc__nolibxml_export_update_buffer(ndata, res);
   }
+  ndata->has_content = 1;
+
+  res = hwloc_snprintf(ndata->buffer, ndata->remaining, buffer, length);
+  hwloc__nolibxml_export_update_buffer(ndata, res);
 }
 
 static size_t
 hwloc___nolibxml_prepare_export(hwloc_topology_t topology, char *xmlbuffer, int buflen)
 {
-  struct hwloc__xml_export_output_s output;
-  struct hwloc__nolibxml_export_output_data_s ndata;
+  struct hwloc__xml_export_state_s state, childstate;
+  hwloc__nolibxml_export_state_data_t ndata = (void *) &state.data;
   int res;
 
-  output.new_child = hwloc__nolibxml_export_new_child;
-  output.end_child = hwloc__nolibxml_export_end_child;
-  output.new_prop = hwloc__nolibxml_export_new_prop;
-  output.end_props = hwloc__nolibxml_export_end_props;
-  output.data = &ndata;
+  assert(sizeof(*ndata) <= sizeof(state.data));
 
-  ndata.indent = 0;
-  ndata.written = 0;
-  ndata.buffer = xmlbuffer;
-  ndata.remaining = buflen;
+  state.new_child = hwloc__nolibxml_export_new_child;
+  state.new_prop = hwloc__nolibxml_export_new_prop;
+  state.add_content = hwloc__nolibxml_export_add_content;
+  state.end_object = hwloc__nolibxml_export_end_object;
 
-  res = hwloc_snprintf(ndata.buffer, ndata.remaining,
+  ndata->indent = 0;
+  ndata->written = 0;
+  ndata->buffer = xmlbuffer;
+  ndata->remaining = buflen;
+
+  ndata->nr_children = 1; /* don't close a non-existing previous tag when opening the topology tag */
+  ndata->has_content = 0;
+
+  res = hwloc_snprintf(ndata->buffer, ndata->remaining,
 		 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 		 "<!DOCTYPE topology SYSTEM \"hwloc.dtd\">\n");
-  hwloc__nolibxml_export_update_buffer(&ndata, res);
-  hwloc__nolibxml_export_new_child(&output, "topology");
-  hwloc__nolibxml_export_end_props(&output, 1);
-  hwloc__xml_export_object (&output, topology, hwloc_get_root_obj(topology));
-  hwloc__nolibxml_export_end_child(&output, "topology", 1);
+  hwloc__nolibxml_export_update_buffer(ndata, res);
+  hwloc__nolibxml_export_new_child(&state, &childstate, "topology");
+  hwloc__xml_export_object (&childstate, topology, hwloc_get_root_obj(topology));
+  hwloc__nolibxml_export_end_object(&childstate, "topology");
 
-  return ndata.written+1;
+  return ndata->written+1;
 }
 
-int
+static int
 hwloc_nolibxml_export_buffer(hwloc_topology_t topology, char **bufferp, int *buflenp)
 {
   char *buffer;
@@ -450,7 +537,7 @@
   return 0;
 }
 
-int
+static int
 hwloc_nolibxml_export_file(hwloc_topology_t topology, const char *filename)
 {
   FILE *file;
@@ -472,16 +559,46 @@
     }
   }
 
-  fwrite(buffer, bufferlen-1 /* don't write the ending \0 */, 1, file);
+  ret = fwrite(buffer, 1, bufferlen-1 /* don't write the ending \0 */, file);
+  if (ret == bufferlen-1) {
+    ret = 0;
+  } else {
+    errno = ferror(file);
+    ret = -1;
+  }
+
   free(buffer);
 
   if (file != stdout)
     fclose(file);
-  return 0;
+  return ret;
 }
 
-void
+static void
 hwloc_nolibxml_free_buffer(void *xmlbuffer)
 {
   free(xmlbuffer);
 }
+
+/*************
+ * Callbacks *
+ *************/
+
+static struct hwloc_xml_callbacks hwloc_xml_nolibxml_callbacks = {
+  hwloc_nolibxml_backend_init,
+  hwloc_nolibxml_export_file,
+  hwloc_nolibxml_export_buffer,
+  hwloc_nolibxml_free_buffer
+};
+
+static struct hwloc_xml_component hwloc_nolibxml_xml_component = {
+  &hwloc_xml_nolibxml_callbacks,
+  NULL
+};
+
+const struct hwloc_component hwloc_xml_nolibxml_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_XML,
+  0,
+  &hwloc_nolibxml_xml_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology-xml.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2009-2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -27,42 +27,31 @@
   return verbose;
 }
 
-/***********************************
- ******** Backend Init/Exit ********
- ***********************************/
+/*********************************
+ ********* XML callbacks *********
+ *********************************/
 
-/* this can be the first XML call */
-int
-hwloc_backend_xml_init(struct hwloc_topology *topology, const char *xmlpath, const char *xmlbuffer, int xmlbuflen)
+/* set when registering nolibxml and libxml components.
+ * modifications protected by the components mutex.
+ * read by the common XML code in topology-xml.c to jump to the right XML backend.
+ */
+static struct hwloc_xml_callbacks *hwloc_nolibxml_callbacks = NULL, *hwloc_libxml_callbacks = NULL;
+
+void
+hwloc_xml_callbacks_register(struct hwloc_xml_component *comp)
 {
-  int ret;
-#ifdef HWLOC_HAVE_LIBXML2
-  char *env = getenv("HWLOC_NO_LIBXML_IMPORT");
-  if (!env || !atoi(env)) {
-    ret = hwloc_libxml_backend_init(topology, xmlpath, xmlbuffer, xmlbuflen);
-  } else
-#endif /* HWLOC_HAVE_LIBXML2 */
-  {
-    ret = hwloc_nolibxml_backend_init(topology, xmlpath, xmlbuffer, xmlbuflen);
-  }
-  if (ret < 0)
-    return ret;
-
-  topology->is_thissystem = 0;
-  assert(topology->backend_type == HWLOC_BACKEND_NONE);
-  topology->backend_type = HWLOC_BACKEND_XML;
-
-  return 0;
+  if (!hwloc_nolibxml_callbacks)
+    hwloc_nolibxml_callbacks = comp->nolibxml_callbacks;
+  if (!hwloc_libxml_callbacks)
+    hwloc_libxml_callbacks = comp->libxml_callbacks;
 }
 
-/* this canNOT be the first XML call */
 void
-hwloc_backend_xml_exit(struct hwloc_topology *topology)
+hwloc_xml_callbacks_reset(void)
 {
-  assert(topology->backend_type == HWLOC_BACKEND_XML);
-  topology->backend_params.xml.backend_exit(topology);
-  topology->backend_type = HWLOC_BACKEND_NONE;
-}
+  hwloc_nolibxml_callbacks = NULL;
+  hwloc_libxml_callbacks = NULL;
+}			       
 
 /************************************************
  ********* XML import (common routines) *********
@@ -218,7 +207,7 @@
     switch (obj->type) {
     case HWLOC_OBJ_PCI_DEVICE:
     case HWLOC_OBJ_BRIDGE: {
-      obj->attr->pcidev.linkspeed = atof(value);
+      obj->attr->pcidev.linkspeed = (float) atof(value);
       break;
     }
     default:
@@ -424,7 +413,8 @@
 }
 
 static int
-hwloc__xml_import_distances(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj,
+hwloc__xml_import_distances(struct hwloc_xml_backend_data_s *data,
+			    hwloc_obj_t obj,
 			    hwloc__xml_import_state_t state)
 {
   unsigned long reldepth = 0, nbobjs = 0;
@@ -492,11 +482,11 @@
 
     distances->distances.latency_max = latmax;
 
-    if (topology->backend_params.xml.last_distances)
-      topology->backend_params.xml.last_distances->next = distances;
+    if (data->last_distances)
+      data->last_distances->next = distances;
     else
-      topology->backend_params.xml.first_distances = distances;
-    distances->prev = topology->backend_params.xml.last_distances;
+      data->first_distances = distances;
+    distances->prev = data->last_distances;
     distances->next = NULL;
   }
 
@@ -504,7 +494,63 @@
 }
 
 static int
-hwloc__xml_import_object(hwloc_topology_t topology, hwloc_obj_t obj,
+hwloc__xml_import_userdata(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_obj_t obj,
+			   hwloc__xml_import_state_t state)
+{
+  size_t length = 0;
+  int encoded = 0;
+  char *name = NULL; /* optional */
+
+  while (1) {
+    char *attrname, *attrvalue;
+    if (state->next_attr(state, &attrname, &attrvalue) < 0)
+      break;
+    if (!strcmp(attrname, "length"))
+      length = strtoul(attrvalue, NULL, 10);
+    else if (!strcmp(attrname, "encoding"))
+      encoded = !strcmp(attrvalue, "base64");
+    else if (!strcmp(attrname, "name"))
+      name = attrvalue;
+    else
+      return -1;
+  }
+
+  if (length && topology->userdata_import_cb) {
+    int ret;
+
+    if (encoded) {
+      char *encoded_buffer;
+      size_t encoded_length = 4*((length+2)/3);
+      ret = state->get_content(state, &encoded_buffer, encoded_length);
+      if (ret < 0)
+        return -1;
+      if (ret) {
+	char *decoded_buffer = malloc(length+1);
+	if (!decoded_buffer)
+	  return -1;
+	assert(encoded_buffer[encoded_length] == 0);
+	ret = hwloc_decode_from_base64(encoded_buffer, decoded_buffer, length+1);
+	if (ret != (int) length)
+	  return -1;
+	topology->userdata_import_cb(topology, obj, name, decoded_buffer, length);
+	free(decoded_buffer);
+      }
+    } else {
+      char *buffer;
+      ret = state->get_content(state, &buffer, length);
+      if (ret < 0)
+        return -1;
+      topology->userdata_import_cb(topology, obj, name, buffer, length);
+    }
+    state->close_content(state);
+  }
+  return state->close_tag(state);
+}
+
+static int
+hwloc__xml_import_object(hwloc_topology_t topology,
+			 struct hwloc_xml_backend_data_s *data,
+			 hwloc_obj_t obj,
 			 hwloc__xml_import_state_t state)
 {
   /* process attributes */
@@ -539,13 +585,15 @@
     if (!strcmp(tag, "object")) {
       hwloc_obj_t childobj = hwloc_alloc_setup_object(HWLOC_OBJ_TYPE_MAX, -1);
       hwloc_insert_object_by_parent(topology, obj, childobj);
-      ret = hwloc__xml_import_object(topology, childobj, &childstate);
+      ret = hwloc__xml_import_object(topology, data, childobj, &childstate);
     } else if (!strcmp(tag, "page_type")) {
       ret = hwloc__xml_import_pagetype(topology, obj, &childstate);
     } else if (!strcmp(tag, "info")) {
       ret = hwloc__xml_import_info(topology, obj, &childstate);
     } else if (!strcmp(tag, "distances")) {
-      ret = hwloc__xml_import_distances(topology, obj, &childstate);
+      ret = hwloc__xml_import_distances(data, obj, &childstate);
+    } else if (!strcmp(tag, "userdata")) {
+      ret = hwloc__xml_import_userdata(topology, obj, &childstate);
     } else
       ret = -1;
 
@@ -563,9 +611,10 @@
  ***********************************/
 
 static void
-hwloc_xml__handle_distances(struct hwloc_topology *topology)
+hwloc_xml__handle_distances(struct hwloc_topology *topology,
+			    struct hwloc_xml_backend_data_s *data)
 {
-  struct hwloc_xml_imported_distances_s *xmldist, *next = topology->backend_params.xml.first_distances;
+  struct hwloc_xml_imported_distances_s *xmldist, *next = data->first_distances;
 
   if (!next)
     return;
@@ -606,19 +655,23 @@
 }
 
 /* this canNOT be the first XML call */
-int
-hwloc_look_xml(struct hwloc_topology *topology)
+static int
+hwloc_look_xml(struct hwloc_backend *backend)
 {
+  struct hwloc_topology *topology = backend->topology;
+  struct hwloc_xml_backend_data_s *data = backend->private_data;
   struct hwloc__xml_import_state_s state, childstate;
   char *tag;
   hwloc_localeswitch_declare;
   int ret;
 
+  assert(!topology->levels[0][0]->cpuset);
+
   hwloc_localeswitch_init();
 
-  topology->backend_params.xml.first_distances = topology->backend_params.xml.last_distances = NULL;
+  data->first_distances = data->last_distances = NULL;
 
-  ret = topology->backend_params.xml.look(topology, &state);
+  ret = data->look_init(data, &state);
   if (ret < 0)
     goto failed;
 
@@ -626,7 +679,7 @@
   ret = state.find_child(&state, &childstate, &tag);
   if (ret < 0 || !ret || strcmp(tag, "object"))
     goto failed;
-  ret = hwloc__xml_import_object(topology, topology->levels[0][0], &childstate);
+  ret = hwloc__xml_import_object(topology, data, topology->levels[0][0], &childstate);
   if (ret < 0)
     goto failed;
   state.close_child(&childstate);
@@ -638,16 +691,16 @@
   /* we could add "BackendSource=XML" to notify that XML was used between the actual backend and here */
 
   /* if we added some distances, we must check them, and make them groupable */
-  hwloc_xml__handle_distances(topology);
-  topology->backend_params.xml.first_distances = topology->backend_params.xml.last_distances = NULL;
+  hwloc_xml__handle_distances(topology, data);
+  data->first_distances = data->last_distances = NULL;
   topology->support.discovery->pu = 1;
 
   hwloc_localeswitch_fini();
-  return 0;
+  return 1;
 
  failed:
-  if (topology->backend_params.xml.look_failed)
-    topology->backend_params.xml.look_failed(topology);
+  if (data->look_failed)
+    data->look_failed(data);
   hwloc_localeswitch_fini();
   return -1;
 }
@@ -656,6 +709,18 @@
  ********* XML export (common routines) *********
  ************************************************/
 
+#define HWLOC_XML_CHAR_VALID(c) (((c) >= 32 && (c) <= 126) || (c) == '\t' || (c) == '\n' || (c) == '\r')
+
+static int
+hwloc__xml_export_check_buffer(const char *buf, size_t length)
+{
+  unsigned i;
+  for(i=0; i<length; i++)
+    if (!HWLOC_XML_CHAR_VALID(buf[i]))
+      return -1;
+  return 0;
+}
+
 /* strdup and remove ugly chars from random string */
 static char*
 hwloc__xml_export_safestrdup(const char *old)
@@ -664,7 +729,7 @@
   char *dst = new;
   const char *src = old;
   while (*src) {
-    if ((*src >= 32 && *src <= 126) || *src == '\t' || *src == '\n' || *src == '\r')
+    if (HWLOC_XML_CHAR_VALID(*src))
       *(dst++) = *src;
     src++;
   }
@@ -673,93 +738,94 @@
 }
 
 void
-hwloc__xml_export_object (hwloc__xml_export_output_t output, hwloc_topology_t topology, hwloc_obj_t obj)
+hwloc__xml_export_object (hwloc__xml_export_state_t parentstate, hwloc_topology_t topology, hwloc_obj_t obj)
 {
+  struct hwloc__xml_export_state_s state;
   char *cpuset = NULL;
   char tmp[255];
-  unsigned nr_children = obj->memory.page_types_len + obj->infos_count + obj->distances_count + obj->arity;
   unsigned i;
 
-  output->new_child(output, "object");
-  output->new_prop(output, "type", hwloc_obj_type_string(obj->type));
+  parentstate->new_child(parentstate, &state, "object");
+
+  state.new_prop(&state, "type", hwloc_obj_type_string(obj->type));
   if (obj->os_level != -1) {
     sprintf(tmp, "%d", obj->os_level);
-    output->new_prop(output, "os_level", tmp);
+    state.new_prop(&state, "os_level", tmp);
   }
   if (obj->os_index != (unsigned) -1) {
     sprintf(tmp, "%u", obj->os_index);
-    output->new_prop(output, "os_index", tmp);
+    state.new_prop(&state, "os_index", tmp);
   }
   if (obj->cpuset) {
     hwloc_bitmap_asprintf(&cpuset, obj->cpuset);
-    output->new_prop(output, "cpuset", cpuset);
+    state.new_prop(&state, "cpuset", cpuset);
     free(cpuset);
   }
   if (obj->complete_cpuset) {
     hwloc_bitmap_asprintf(&cpuset, obj->complete_cpuset);
-    output->new_prop(output, "complete_cpuset", cpuset);
+    state.new_prop(&state, "complete_cpuset", cpuset);
     free(cpuset);
   }
   if (obj->online_cpuset) {
     hwloc_bitmap_asprintf(&cpuset, obj->online_cpuset);
-    output->new_prop(output, "online_cpuset", cpuset);
+    state.new_prop(&state, "online_cpuset", cpuset);
     free(cpuset);
   }
   if (obj->allowed_cpuset) {
     hwloc_bitmap_asprintf(&cpuset, obj->allowed_cpuset);
-    output->new_prop(output, "allowed_cpuset", cpuset);
+    state.new_prop(&state, "allowed_cpuset", cpuset);
     free(cpuset);
   }
   if (obj->nodeset && !hwloc_bitmap_isfull(obj->nodeset)) {
     hwloc_bitmap_asprintf(&cpuset, obj->nodeset);
-    output->new_prop(output, "nodeset", cpuset);
+    state.new_prop(&state, "nodeset", cpuset);
     free(cpuset);
   }
   if (obj->complete_nodeset && !hwloc_bitmap_isfull(obj->complete_nodeset)) {
     hwloc_bitmap_asprintf(&cpuset, obj->complete_nodeset);
-    output->new_prop(output, "complete_nodeset", cpuset);
+    state.new_prop(&state, "complete_nodeset", cpuset);
     free(cpuset);
   }
   if (obj->allowed_nodeset && !hwloc_bitmap_isfull(obj->allowed_nodeset)) {
     hwloc_bitmap_asprintf(&cpuset, obj->allowed_nodeset);
-    output->new_prop(output, "allowed_nodeset", cpuset);
+    state.new_prop(&state, "allowed_nodeset", cpuset);
     free(cpuset);
   }
 
   if (obj->name) {
     char *name = hwloc__xml_export_safestrdup(obj->name);
-    output->new_prop(output, "name", name);
+    state.new_prop(&state, "name", name);
     free(name);
   }
 
   switch (obj->type) {
   case HWLOC_OBJ_CACHE:
     sprintf(tmp, "%llu", (unsigned long long) obj->attr->cache.size);
-    output->new_prop(output, "cache_size", tmp);
+    state.new_prop(&state, "cache_size", tmp);
     sprintf(tmp, "%u", obj->attr->cache.depth);
-    output->new_prop(output, "depth", tmp);
+    state.new_prop(&state, "depth", tmp);
     sprintf(tmp, "%u", (unsigned) obj->attr->cache.linesize);
-    output->new_prop(output, "cache_linesize", tmp);
+    state.new_prop(&state, "cache_linesize", tmp);
     sprintf(tmp, "%d", (unsigned) obj->attr->cache.associativity);
-    output->new_prop(output, "cache_associativity", tmp);
+    state.new_prop(&state, "cache_associativity", tmp);
     sprintf(tmp, "%d", (unsigned) obj->attr->cache.type);
-    output->new_prop(output, "cache_type", tmp);
+    state.new_prop(&state, "cache_type", tmp);
     break;
   case HWLOC_OBJ_GROUP:
     sprintf(tmp, "%u", obj->attr->group.depth);
-    output->new_prop(output, "depth", tmp);
+    state.new_prop(&state, "depth", tmp);
     break;
   case HWLOC_OBJ_BRIDGE:
     sprintf(tmp, "%u-%u", obj->attr->bridge.upstream_type, obj->attr->bridge.downstream_type);
-    output->new_prop(output, "bridge_type", tmp);
+    state.new_prop(&state, "bridge_type", tmp);
     sprintf(tmp, "%u", obj->attr->bridge.depth);
-    output->new_prop(output, "depth", tmp);
+    state.new_prop(&state, "depth", tmp);
     if (obj->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI) {
       sprintf(tmp, "%04x:[%02x-%02x]",
 	      (unsigned) obj->attr->bridge.downstream.pci.domain,
 	      (unsigned) obj->attr->bridge.downstream.pci.secondary_bus,
 	      (unsigned) obj->attr->bridge.downstream.pci.subordinate_bus);
-      output->new_prop(output, "bridge_pci", tmp);
+      state.new_prop(&state, "bridge_pci", tmp);
     }
     if (obj->attr->bridge.upstream_type != HWLOC_OBJ_BRIDGE_PCI)
       break;
@@ -770,19 +836,19 @@
 	    (unsigned) obj->attr->pcidev.bus,
 	    (unsigned) obj->attr->pcidev.dev,
 	    (unsigned) obj->attr->pcidev.func);
-    output->new_prop(output, "pci_busid", tmp);
+    state.new_prop(&state, "pci_busid", tmp);
     sprintf(tmp, "%04x [%04x:%04x] [%04x:%04x] %02x",
 	    (unsigned) obj->attr->pcidev.class_id,
 	    (unsigned) obj->attr->pcidev.vendor_id, (unsigned) obj->attr->pcidev.device_id,
 	    (unsigned) obj->attr->pcidev.subvendor_id, (unsigned) obj->attr->pcidev.subdevice_id,
 	    (unsigned) obj->attr->pcidev.revision);
-    output->new_prop(output, "pci_type", tmp);
+    state.new_prop(&state, "pci_type", tmp);
     sprintf(tmp, "%f", obj->attr->pcidev.linkspeed);
-    output->new_prop(output, "pci_link_speed", tmp);
+    state.new_prop(&state, "pci_link_speed", tmp);
     break;
   case HWLOC_OBJ_OS_DEVICE:
     sprintf(tmp, "%u", obj->attr->osdev.type);
-    output->new_prop(output, "osdev_type", tmp);
+    state.new_prop(&state, "osdev_type", tmp);
     break;
   default:
     break;
@@ -790,29 +856,27 @@
 
   if (obj->memory.local_memory) {
     sprintf(tmp, "%llu", (unsigned long long) obj->memory.local_memory);
-    output->new_prop(output, "local_memory", tmp);
+    state.new_prop(&state, "local_memory", tmp);
   }
 
-  output->end_props(output, nr_children);
-
   for(i=0; i<obj->memory.page_types_len; i++) {
-    output->new_child(output, "page_type");
+    struct hwloc__xml_export_state_s childstate;
+    state.new_child(&state, &childstate, "page_type");
     sprintf(tmp, "%llu", (unsigned long long) obj->memory.page_types[i].size);
-    output->new_prop(output, "size", tmp);
+    childstate.new_prop(&childstate, "size", tmp);
     sprintf(tmp, "%llu", (unsigned long long) obj->memory.page_types[i].count);
-    output->new_prop(output, "count", tmp);
-    output->end_props(output, 0);
-    output->end_child(output, "page_type", 0);
+    childstate.new_prop(&childstate, "count", tmp);
+    childstate.end_object(&childstate, "page_type");
   }
 
   for(i=0; i<obj->infos_count; i++) {
     char *name = hwloc__xml_export_safestrdup(obj->infos[i].name);
     char *value = hwloc__xml_export_safestrdup(obj->infos[i].value);
-    output->new_child(output, "info");
-    output->new_prop(output, "name", name);
-    output->new_prop(output, "value", value);
-    output->end_props(output, 0);
-    output->end_child(output, "info", 0);
+    struct hwloc__xml_export_state_s childstate;
+    state.new_child(&state, &childstate, "info");
+    childstate.new_prop(&childstate, "name", name);
+    childstate.new_prop(&childstate, "value", value);
+    childstate.end_object(&childstate, "info");
     free(name);
     free(value);
   }
@@ -820,31 +884,34 @@
   for(i=0; i<obj->distances_count; i++) {
     unsigned nbobjs = obj->distances[i]->nbobjs;
     unsigned j;
-    output->new_child(output, "distances");
+    struct hwloc__xml_export_state_s childstate;
+    state.new_child(&state, &childstate, "distances");
     sprintf(tmp, "%u", nbobjs);
-    output->new_prop(output, "nbobjs", tmp);
+    childstate.new_prop(&childstate, "nbobjs", tmp);
     sprintf(tmp, "%u", obj->distances[i]->relative_depth);
-    output->new_prop(output, "relative_depth", tmp);
+    childstate.new_prop(&childstate, "relative_depth", tmp);
     sprintf(tmp, "%f", obj->distances[i]->latency_base);
-    output->new_prop(output, "latency_base", tmp);
-    output->end_props(output, nbobjs*nbobjs);
+    childstate.new_prop(&childstate, "latency_base", tmp);
     for(j=0; j<nbobjs*nbobjs; j++) {
-      output->new_child(output, "latency");
+      struct hwloc__xml_export_state_s greatchildstate;
+      childstate.new_child(&childstate, &greatchildstate, "latency");
       sprintf(tmp, "%f", obj->distances[i]->latency[j]);
-      output->new_prop(output, "value", tmp);
-      output->end_props(output, 0);
-      output->end_child(output, "latency", 0);
+      greatchildstate.new_prop(&greatchildstate, "value", tmp);
+      greatchildstate.end_object(&greatchildstate, "latency");
     }
-    output->end_child(output, "distances", nbobjs*nbobjs);
+    childstate.end_object(&childstate, "distances");
   }
 
+  if (obj->userdata && topology->userdata_export_cb)
+    topology->userdata_export_cb((void*) &state, topology, obj);
+
   if (obj->arity) {
     unsigned x;
     for (x=0; x<obj->arity; x++)
-      hwloc__xml_export_object (output, topology, obj->children[x]);
+      hwloc__xml_export_object (&state, topology, obj->children[x]);
   }
 
-  output->end_child(output, "object", nr_children);
+  state.end_object(&state, "object");
 }
 
 /**********************************
@@ -855,22 +922,23 @@
 int hwloc_topology_export_xml(hwloc_topology_t topology, const char *filename)
 {
   hwloc_localeswitch_declare;
+  char *env;
+  int force_nolibxml;
   int ret;
-#ifdef HWLOC_HAVE_LIBXML2
-  char *env;
-#endif
 
+  if (!hwloc_libxml_callbacks && !hwloc_nolibxml_callbacks) {
+    errno = ENOSYS;
+    return -1;
+  }
+
   hwloc_localeswitch_init();
 
-#ifdef HWLOC_HAVE_LIBXML2
   env = getenv("HWLOC_NO_LIBXML_EXPORT");
-  if (!env || !atoi(env)) {
-    ret = hwloc_libxml_export_file(topology, filename);
-  } else
-#endif
-  {
-    ret = hwloc_nolibxml_export_file(topology, filename);
-  }
+  force_nolibxml = (env && atoi(env));
+  if (!hwloc_libxml_callbacks || (hwloc_nolibxml_callbacks && force_nolibxml))
+    ret = hwloc_nolibxml_callbacks->export_file(topology, filename);
+  else
+    ret = hwloc_libxml_callbacks->export_file(topology, filename);
 
   hwloc_localeswitch_fini();
   return ret;
@@ -880,22 +948,23 @@
 int hwloc_topology_export_xmlbuffer(hwloc_topology_t topology, char **xmlbuffer, int *buflen)
 {
   hwloc_localeswitch_declare;
+  char *env;
+  int force_nolibxml;
   int ret;
-#ifdef HWLOC_HAVE_LIBXML2
-  char *env;
-#endif
 
+  if (!hwloc_libxml_callbacks && !hwloc_nolibxml_callbacks) {
+    errno = ENOSYS;
+    return -1;
+  }
+
   hwloc_localeswitch_init();
 
-#ifdef HWLOC_HAVE_LIBXML2
   env = getenv("HWLOC_NO_LIBXML_EXPORT");
-  if (!env || !atoi(env)) {
-    ret = hwloc_libxml_export_buffer(topology, xmlbuffer, buflen);
-  } else
-#endif
-  {
-    ret = hwloc_nolibxml_export_buffer(topology, xmlbuffer, buflen);
-  }
+  force_nolibxml = (env && atoi(env));
+  if (!hwloc_libxml_callbacks || (hwloc_nolibxml_callbacks && force_nolibxml))
+    ret = hwloc_nolibxml_callbacks->export_buffer(topology, xmlbuffer, buflen);
+  else
+    ret = hwloc_libxml_callbacks->export_buffer(topology, xmlbuffer, buflen);
 
   hwloc_localeswitch_fini();
   return ret;
@@ -903,13 +972,184 @@
 
 void hwloc_free_xmlbuffer(hwloc_topology_t topology __hwloc_attribute_unused, char *xmlbuffer)
 {
-#ifdef HWLOC_HAVE_LIBXML2
-  char *env = getenv("HWLOC_NO_LIBXML_EXPORT");
-  if (!env || !atoi(env)) {
-    hwloc_libxml_free_buffer(xmlbuffer);
-  } else
-#endif
-  {
-    hwloc_nolibxml_free_buffer(xmlbuffer);
+  char *env;
+  int force_nolibxml;
+
+  if (!hwloc_libxml_callbacks && !hwloc_nolibxml_callbacks) {
+    errno = ENOSYS;
+    return ;
   }
+
+  env = getenv("HWLOC_NO_LIBXML_EXPORT");
+  force_nolibxml = (env && atoi(env));
+  if (!hwloc_libxml_callbacks || (hwloc_nolibxml_callbacks && force_nolibxml))
+    hwloc_nolibxml_callbacks->free_buffer(xmlbuffer);
+  else
+    hwloc_libxml_callbacks->free_buffer(xmlbuffer);
 }
+
+void
+hwloc_topology_set_userdata_export_callback(hwloc_topology_t topology,
+					    void (*export)(void *reserved, struct hwloc_topology *topology, struct hwloc_obj *obj))
+{
+  topology->userdata_export_cb = export;
+}
+
+static void
+hwloc__export_obj_userdata(hwloc__xml_export_state_t parentstate, int encoded,
+			   const char *name, size_t length, const void *buffer, size_t encoded_length)
+{
+  struct hwloc__xml_export_state_s state;
+  char tmp[255];
+  parentstate->new_child(parentstate, &state, "userdata");
+  if (name)
+    state.new_prop(&state, "name", name);
+  sprintf(tmp, "%lu", (unsigned long) length);
+  state.new_prop(&state, "length", tmp);
+  if (encoded)
+    state.new_prop(&state, "encoding", "base64");
+  state.add_content(&state, buffer, encoded ? encoded_length : length);
+  state.end_object(&state, "userdata");
+}
+
+int
+hwloc_export_obj_userdata(void *reserved,
+			  struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *obj __hwloc_attribute_unused,
+			  const char *name, const void *buffer, size_t length)
+{
+  hwloc__xml_export_state_t state = reserved;
+
+  if ((name && hwloc__xml_export_check_buffer(name, strlen(name)) < 0)
+      || hwloc__xml_export_check_buffer(buffer, length) < 0) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  hwloc__export_obj_userdata(state, 0, name, length, buffer, length);
+  return 0;
+}
+
+int
+hwloc_export_obj_userdata_base64(void *reserved,
+				 struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *obj __hwloc_attribute_unused,
+				 const char *name, const void *buffer, size_t length)
+{
+  hwloc__xml_export_state_t state = reserved;
+  size_t encoded_length;
+  char *encoded_buffer;
+  int ret;
+
+  if (name && hwloc__xml_export_check_buffer(name, strlen(name)) < 0) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  encoded_length = 4*((length+2)/3);
+  encoded_buffer = malloc(encoded_length+1);
+  if (!encoded_buffer) {
+    errno = ENOMEM;
+    return -1;
+  }
+
+  ret = hwloc_encode_to_base64(buffer, length, encoded_buffer, encoded_length+1);
+  assert(ret == (int) encoded_length);
+
+  hwloc__export_obj_userdata(state, 1, name, length, encoded_buffer, encoded_length);
+
+  free(encoded_buffer);
+  return 0;
+}
+
+void
+hwloc_topology_set_userdata_import_callback(hwloc_topology_t topology,
+					    void (*import)(struct hwloc_topology *topology, struct hwloc_obj *obj, const char *name, const void *buffer, size_t length))
+{
+  topology->userdata_import_cb = import;
+}
+
+/***************************************
+ ************ XML component ************
+ ***************************************/
+
+static void
+hwloc_xml_backend_disable(struct hwloc_backend *backend)
+{
+  struct hwloc_xml_backend_data_s *data = backend->private_data;
+  data->backend_exit(data);
+  free(data);
+}
+
+static struct hwloc_backend *
+hwloc_xml_component_instantiate(struct hwloc_disc_component *component,
+				const void *_data1,
+				const void *_data2,
+				const void *_data3)
+{
+  struct hwloc_xml_backend_data_s *data;
+  struct hwloc_backend *backend;
+  char *env;
+  int force_nolibxml;
+  const char * xmlpath = (const char *) _data1;
+  const char * xmlbuffer = (const char *) _data2;
+  int xmlbuflen = (int)(uintptr_t) _data3;
+  int err;
+
+  if (!hwloc_libxml_callbacks && !hwloc_nolibxml_callbacks) {
+    errno = ENOSYS;
+    goto out;
+  }
+
+  if (!xmlpath && !xmlbuffer) {
+    errno = EINVAL;
+    goto out;
+  }
+
+  backend = hwloc_backend_alloc(component);
+  if (!backend)
+    goto out;
+
+  data = malloc(sizeof(*data));
+  if (!data) {
+    errno = ENOMEM;
+    goto out_with_backend;
+  }
+
+  backend->private_data = data;
+  backend->discover = hwloc_look_xml;
+  backend->disable = hwloc_xml_backend_disable;
+  backend->is_thissystem = 0;
+
+  env = getenv("HWLOC_NO_LIBXML_IMPORT");
+  force_nolibxml = (env && atoi(env));
+  if (!hwloc_libxml_callbacks || (hwloc_nolibxml_callbacks && force_nolibxml))
+    err = hwloc_nolibxml_callbacks->backend_init(data, xmlpath, xmlbuffer, xmlbuflen);
+  else
+    err = hwloc_libxml_callbacks->backend_init(data, xmlpath, xmlbuffer, xmlbuflen);
+  if (err < 0)
+    goto out_with_data;
+
+  return backend;
+
+ out_with_data:
+  free(data);
+ out_with_backend:
+  free(backend);
+ out:
+  return NULL;
+}
+
+static struct hwloc_disc_component hwloc_xml_disc_component = {
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  "xml",
+  HWLOC_DISC_COMPONENT_TYPE_CPU | HWLOC_DISC_COMPONENT_TYPE_GLOBAL | HWLOC_DISC_COMPONENT_TYPE_ADDITIONAL,
+  hwloc_xml_component_instantiate,
+  30,
+  NULL
+};
+
+const struct hwloc_component hwloc_xml_component = {
+  HWLOC_COMPONENT_ABI,
+  HWLOC_COMPONENT_TYPE_DISC,
+  0,
+  &hwloc_xml_disc_component
+};

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/src/topology.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -84,12 +84,6 @@
     }
 }
 
-static void
-hwloc_topology_clear (struct hwloc_topology *topology);
-static void
-hwloc_topology_setup_defaults(struct hwloc_topology *topology);
-
-
 #if defined(HAVE_SYSCTLBYNAME)
 int hwloc_get_sysctlbyname(const char *name, int64_t *ret)
 {
@@ -301,7 +295,7 @@
   free(obj);
 }
 
-static void
+void
 hwloc__duplicate_objects(struct hwloc_topology *newtopology,
 			 struct hwloc_obj *newparent,
 			 struct hwloc_obj *src)
@@ -387,7 +381,7 @@
    *** CHECKING ITS CORRECTNESS!
    *************************************************************
    */
-static unsigned obj_type_order[] = {
+static const unsigned obj_type_order[] = {
     /* first entry is HWLOC_OBJ_SYSTEM */  0,
     /* next entry is HWLOC_OBJ_MACHINE */  1,
     /* next entry is HWLOC_OBJ_NODE */     3,
@@ -417,6 +411,33 @@
   HWLOC_OBJ_MISC,
 };
 
+/* priority to be used when merging identical parent/children object
+ * (in merge_useless_child), keep the highest priority one.
+ *
+ * Always keep Machine/PU/PCIDev/OSDev
+ * then System/Node
+ * then Core
+ * then Socket
+ * then Cache
+ * then always drop Group/Misc/Bridge.
+ *
+ * Some type won't actually ever be involved in such merging.
+ */
+static const int obj_type_priority[] = {
+  /* first entry is HWLOC_OBJ_SYSTEM */     80,
+  /* next entry is HWLOC_OBJ_MACHINE */     100,
+  /* next entry is HWLOC_OBJ_NODE */        80,
+  /* next entry is HWLOC_OBJ_SOCKET */      40,
+  /* next entry is HWLOC_OBJ_CACHE */       20,
+  /* next entry is HWLOC_OBJ_CORE */        60,
+  /* next entry is HWLOC_OBJ_PU */          100,
+  /* next entry is HWLOC_OBJ_GROUP */       0,
+  /* next entry is HWLOC_OBJ_MISC */        0,
+  /* next entry is HWLOC_OBJ_BRIDGE */      0,
+  /* next entry is HWLOC_OBJ_PCI_DEVICE */  100,
+  /* next entry is HWLOC_OBJ_OS_DEVICE */   100
+};
+
 static unsigned __hwloc_attribute_const
 hwloc_get_type_order(hwloc_obj_type_t type)
 {
@@ -933,22 +954,6 @@
   return obj;
 }
 
-hwloc_obj_t
-hwloc_custom_insert_group_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, int groupdepth)
-{
-  hwloc_obj_t obj = hwloc_alloc_setup_object(HWLOC_OBJ_GROUP, -1);
-  obj->attr->group.depth = groupdepth;
-
-  if (topology->backend_type != HWLOC_BACKEND_CUSTOM || topology->is_loaded) {
-    errno = EINVAL;
-    return NULL;
-  }
-
-  hwloc_insert_object_by_parent(topology, parent, obj);
-
-  return obj;
-}
-
 /* Traverse children of a parent in a safe way: reread the next pointer as
  * appropriate to prevent crash on child deletion:  */
 #define for_each_child_safe(child, parent, pchild) \
@@ -965,6 +970,10 @@
 {
   hwloc_obj_t child, *temp;
 
+  /* make sure we don't have remaining stale pointers from a previous load */
+  obj->next_cousin = NULL;
+  obj->prev_cousin = NULL;
+
   if (obj->type == HWLOC_OBJ_BRIDGE) {
     obj->depth = HWLOC_TYPE_DEPTH_BRIDGE;
     /* Insert in the main bridge list */
@@ -1506,6 +1515,7 @@
 merge_useless_child(hwloc_topology_t topology, hwloc_obj_t *pparent)
 {
   hwloc_obj_t parent = *pparent, child, *pchild;
+  int replacechild = 0, replaceparent = 0;
 
   for_each_child_safe(child, parent, pchild)
     merge_useless_child(topology, pchild);
@@ -1515,16 +1525,37 @@
     /* There are no or several children, it's useful to keep them.  */
     return;
 
-  /* TODO: have a preference order?  */
-  if (topology->ignored_types[parent->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE) {
+  /* Check whether parent and/or child can be replaced */
+  if (topology->ignored_types[parent->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE)
     /* Parent can be ignored in favor of the child.  */
+    replaceparent = 1;
+  if (topology->ignored_types[child->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE)
+    /* Child can be ignored in favor of the parent.  */    
+    replacechild = 1;
+
+  /* Decide which one to actually replace */
+  if (replaceparent && replacechild) {
+    /* If both may be replaced, look at obj_type_priority */
+    if (obj_type_priority[parent->type] > obj_type_priority[child->type])
+      replaceparent = 0;
+    else
+      replacechild = 0;
+  }
+
+  if (replaceparent) {
+    /* Replace parent with child */
     hwloc_debug("%s", "\nIgnoring parent ");
     print_object(topology, 0, parent);
+    if (parent == topology->levels[0][0]) {
+      child->parent = NULL;
+      child->depth = 0;
+    }
     *pparent = child;
     child->next_sibling = parent->next_sibling;
     hwloc_free_unlinked_object(parent);
-  } else if (topology->ignored_types[child->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE) {
-    /* Child can be ignored in favor of the parent.  */
+
+  } else if (replacechild) {
+    /* Replace child with parent */
     hwloc_debug("%s", "\nIgnoring child ");
     print_object(topology, 0, child);
     parent->first_child = child->first_child;
@@ -1532,6 +1563,18 @@
   }
 }
 
+static void
+hwloc_drop_all_io(hwloc_topology_t topology, hwloc_obj_t root)
+{
+  hwloc_obj_t child, *pchild;
+  for_each_child_safe(child, root, pchild) {
+    if (hwloc_obj_type_is_io(child->type))
+      unlink_and_free_object_and_children(pchild);
+    else
+      hwloc_drop_all_io(topology, child);
+  }
+}
+
 /*
  * If IO_DEVICES and WHOLE_IO are not set, we drop everything.
  * If WHOLE_IO is not set, we drop non-interesting devices,
@@ -1546,9 +1589,7 @@
 
   if (!(topology->flags & (HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO))) {
     /* drop all I/O children */
-    for_each_child_safe(child, root, pchild)
-      if (hwloc_obj_type_is_io(child->type))
-	unlink_and_free_object_and_children(pchild);
+    hwloc_drop_all_io(topology, root);
     return;
   }
 
@@ -1894,18 +1935,14 @@
   objs = malloc(n_objs * sizeof(objs[0]));
   if (!objs) {
     errno = ENOMEM;
-    hwloc_topology_clear(topology);
     return -1;
   }
   memcpy(objs, topology->levels[0][0]->children, n_objs*sizeof(objs[0]));
 
   /* Filter-out interesting objects */
   err = hwloc_level_filter_objects(topology, &objs, &n_objs);
-  if (err < 0) {
-    errno = ENOMEM;
-    hwloc_topology_clear(topology);
+  if (err < 0)
     return -1;
-  }
 
   /* Keep building levels while there are objects left in OBJS.  */
   while (n_objs) {
@@ -1992,11 +2029,9 @@
 
     /* Switch to new_objs, after filtering-out interesting objects */
     err = hwloc_level_filter_objects(topology, &new_objs, &n_new_objs);
-    if (err < 0) {
-      errno = ENOMEM;
-      hwloc_topology_clear(topology);
+    if (err < 0)
       return -1;
-    }
+
     objs = new_objs;
     n_objs = n_new_objs;
   }
@@ -2014,114 +2049,8 @@
   return 0;
 }
 
-/*
- * Empty binding hooks always returning success
- */
-
-static int dontset_return_complete_cpuset(hwloc_topology_t topology, hwloc_cpuset_t set)
+void hwloc_alloc_obj_cpusets(hwloc_obj_t obj)
 {
-  hwloc_const_cpuset_t cpuset = hwloc_topology_get_complete_cpuset(topology);
-  if (cpuset) {
-    hwloc_bitmap_copy(set, hwloc_topology_get_complete_cpuset(topology));
-    return 0;
-  } else
-    return -1;
-}
-
-static int dontset_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_thisthread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_cpuset(topology, set);
-}
-static int dontset_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_thisproc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_cpuset(topology, set);
-}
-static int dontset_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_proc_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_cpuset(topology, cpuset);
-}
-#ifdef hwloc_thread_t
-static int dontset_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_thread_cpubind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_thread_t tid __hwloc_attribute_unused, hwloc_bitmap_t cpuset, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_cpuset(topology, cpuset);
-}
-#endif
-
-static int dontset_return_complete_nodeset(hwloc_topology_t topology, hwloc_nodeset_t set, hwloc_membind_policy_t *policy)
-{
-  hwloc_const_nodeset_t nodeset = hwloc_topology_get_complete_nodeset(topology);
-  if (nodeset) {
-    hwloc_bitmap_copy(set, hwloc_topology_get_complete_nodeset(topology));
-    *policy = HWLOC_MEMBIND_DEFAULT;
-    return 0;
-  } else
-    return -1;
-}
-
-static int dontset_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_thisproc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_thisthread_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_proc_membind(hwloc_topology_t topology __hwloc_attribute_unused, hwloc_pid_t pid __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static int dontset_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return 0;
-}
-static int dontget_area_membind(hwloc_topology_t topology __hwloc_attribute_unused, const void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_bitmap_t set, hwloc_membind_policy_t * policy, int flags __hwloc_attribute_unused)
-{
-  return dontset_return_complete_nodeset(topology, set, policy);
-}
-
-static void * dontalloc_membind(hwloc_topology_t topology __hwloc_attribute_unused, size_t size __hwloc_attribute_unused, hwloc_const_bitmap_t set __hwloc_attribute_unused, hwloc_membind_policy_t policy __hwloc_attribute_unused, int flags __hwloc_attribute_unused)
-{
-  return malloc(size);
-}
-static int dontfree_membind(hwloc_topology_t topology __hwloc_attribute_unused, void *addr __hwloc_attribute_unused, size_t size __hwloc_attribute_unused)
-{
-  free(addr);
-  return 0;
-}
-
-static void alloc_cpusets(hwloc_obj_t obj)
-{
   obj->cpuset = hwloc_bitmap_alloc_full();
   obj->complete_cpuset = hwloc_bitmap_alloc();
   obj->online_cpuset = hwloc_bitmap_alloc_full();
@@ -2131,26 +2060,15 @@
   obj->allowed_nodeset = hwloc_bitmap_alloc_full();
 }
 
-static void hwloc_topology_setup_defaults(struct hwloc_topology *topology);
-
 /* Main discovery loop */
 static int
 hwloc_discover(struct hwloc_topology *topology)
 {
-  int gotsomeio = 1;
+  struct hwloc_backend *backend;
+  int gotsomeio = 0;
+  unsigned discoveries = 0;
+  unsigned need_reconnect = 0;
 
-  if (topology->backend_type == HWLOC_BACKEND_SYNTHETIC) {
-    alloc_cpusets(topology->levels[0][0]);
-    hwloc_look_synthetic(topology);
-  } else if (topology->backend_type == HWLOC_BACKEND_CUSTOM) {
-    /* nothing to do, just connect levels below */
-  } else if (topology->backend_type == HWLOC_BACKEND_XML) {
-    if (hwloc_look_xml(topology) < 0) {
-      hwloc_topology_clear(topology);
-      return -1;
-    }
-  } else {
-
   /* Raw detection, from coarser levels to finer levels for more efficiency.  */
 
   /* hwloc_look_* functions should use hwloc_obj_add to add objects initialized
@@ -2193,71 +2111,51 @@
    * Here, we only allocate cpusets for the root object.
    */
 
-    alloc_cpusets(topology->levels[0][0]);
-
   /* Each OS type should also fill the bind functions pointers, at least the
    * set_cpubind one
    */
 
-#    ifdef HWLOC_LINUX_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_linuxfs(topology);
-#    endif /* HWLOC_LINUX_SYS */
+  /*
+   * Discover CPUs first
+   */
+  backend = topology->backends;
+  while (NULL != backend) {
+    int err;
+    if (backend->component->type != HWLOC_DISC_COMPONENT_TYPE_CPU
+	&& backend->component->type != HWLOC_DISC_COMPONENT_TYPE_GLOBAL)
+      /* not yet */
+      goto next_cpubackend;
+    if (!backend->discover)
+      goto next_cpubackend;
 
-#    ifdef HWLOC_AIX_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_aix(topology);
-#    endif /* HWLOC_AIX_SYS */
+    if (need_reconnect && (backend->flags & HWLOC_BACKEND_FLAG_NEED_LEVELS)) {
+      hwloc_connect_children(topology->levels[0][0]);
+      if (hwloc_connect_levels(topology) < 0)
+	return -1;
+      need_reconnect = 0;
+    }
 
-#    ifdef HWLOC_OSF_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_osf(topology);
-#    endif /* HWLOC_OSF_SYS */
+    err = backend->discover(backend);
+    if (err >= 0) {
+      if (backend->component->type == HWLOC_DISC_COMPONENT_TYPE_GLOBAL)
+        gotsomeio += err;
+      discoveries++;
+      if (err > 0)
+	need_reconnect++;
+    }
+    print_objects(topology, 0, topology->levels[0][0]);
 
-#    ifdef HWLOC_SOLARIS_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_solaris(topology);
-#    endif /* HWLOC_SOLARIS_SYS */
+next_cpubackend:
+    backend = backend->next;
+  }
 
-#    ifdef HWLOC_WIN_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_windows(topology);
-#    endif /* HWLOC_WIN_SYS */
-
-#    ifdef HWLOC_DARWIN_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_darwin(topology);
-#    endif /* HWLOC_DARWIN_SYS */
-
-#    ifdef HWLOC_FREEBSD_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_freebsd(topology);
-#    endif /* HWLOC_FREEBSD_SYS */
-
-#    ifdef HWLOC_HPUX_SYS
-#      define HAVE_OS_SUPPORT
-    hwloc_look_hpux(topology);
-#    endif /* HWLOC_HPUX_SYS */
-
-#    ifndef HAVE_OS_SUPPORT
-    hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
-#    endif /* Unsupported OS */
-
-
-#    ifndef HWLOC_LINUX_SYS
-    if (topology->is_thissystem) {
-      /* gather uname info, except for Linux, which does it internally depending on load options */
-      hwloc_add_uname_info(topology);
-    }
-#    endif
+  if (!discoveries) {
+    hwloc_debug("%s", "No CPU backend enabled\n");
+    errno = EINVAL;
+    return -1;
   }
 
   /*
-   * Now that backends have detected objects, sort them and establish pointers.
-   */
-  print_objects(topology, 0, topology->levels[0][0]);
-
-  /*
    * Group levels by distances
    */
   hwloc_distances_finalize_os(topology);
@@ -2324,6 +2222,8 @@
 
   hwloc_connect_children(topology->levels[0][0]);
 
+  need_reconnect = 0;
+
   print_objects(topology, 0, topology->levels[0][0]);
 
   /* Explore the resulting topology level by level.  */
@@ -2336,46 +2236,55 @@
   propagate_total_memory(topology->levels[0][0]);
 
   /*
-   * Additional detection, using hwloc_insert_object to add a few objects here
-   * and there.
+   * Discovery with additional backends
    */
+  backend = topology->backends;
+  while (NULL != backend) {
+    int err;
+    if (backend->component->type == HWLOC_DISC_COMPONENT_TYPE_CPU
+	|| backend->component->type == HWLOC_DISC_COMPONENT_TYPE_GLOBAL)
+      /* already done above */
+      goto next_noncpubackend;
+    if (!backend->discover)
+      goto next_noncpubackend;
 
-  /* I/O devices */
+    if (need_reconnect && (backend->flags & HWLOC_BACKEND_FLAG_NEED_LEVELS)) {
+      hwloc_connect_children(topology->levels[0][0]);
+      if (hwloc_connect_levels(topology) < 0)
+	return -1;
+      need_reconnect = 0;
+    }
 
-  /* see if the backend already imported some I/O devices */
-  if (topology->backend_type == HWLOC_BACKEND_XML
-      || topology->backend_type == HWLOC_BACKEND_SYNTHETIC
-      || topology->backend_type == HWLOC_BACKEND_CUSTOM)
-    gotsomeio = 1;
-  /* import from libpci if needed */
-  if (topology->flags & (HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO)
-      && (topology->backend_type == HWLOC_BACKEND_NONE
-#ifdef HWLOC_LINUX_SYS
-	  || topology->backend_type == HWLOC_BACKEND_LINUXFS
-#endif
-	  )) {
-    hwloc_debug("%s", "\nLooking for PCI devices\n");
-#ifdef HWLOC_HAVE_LIBPCI
-    if (topology->is_thissystem) {
-      hwloc_look_libpci(topology);
-      print_objects(topology, 0, topology->levels[0][0]);
-      gotsomeio = 1;
-    } else
-#endif
-    {
-      hwloc_debug("%s", "\nno PCI detection\n");
+    err = backend->discover(backend);
+    if (err >= 0) {
+      gotsomeio += err;
+      if (err > 0)
+	need_reconnect++;
     }
+    print_objects(topology, 0, topology->levels[0][0]);
+
+next_noncpubackend:
+    backend = backend->next;
   }
+
   /* if we got anything, filter interesting objects and update the tree */
   if (gotsomeio) {
     hwloc_drop_useless_io(topology, topology->levels[0][0]);
     hwloc_debug("%s", "\nNow reconnecting\n");
     hwloc_connect_children(topology->levels[0][0]);
-    hwloc_connect_levels(topology);
+    if (hwloc_connect_levels(topology) < 0)
+      return -1;
+    need_reconnect = 0;
     print_objects(topology, 0, topology->levels[0][0]);
     hwloc_propagate_bridge_depth(topology, topology->levels[0][0], 0);
   }
 
+  if (need_reconnect) {
+    hwloc_connect_children(topology->levels[0][0]);
+    if (hwloc_connect_levels(topology) < 0)
+      return -1;
+  }
+
   /*
    * Now that objects are numbered, take distance matrices from backends and put them in the main topology.
    *
@@ -2387,141 +2296,24 @@
   hwloc_distances_finalize_logical(topology);
 
   /*
-   * Now set binding hooks.
-   * If the represented system is actually not this system, use dummy binding
-   * hooks.
+   * Now set binding hooks according to topology->is_thissystem
+   * what the native OS backend offers.
    */
+  hwloc_set_binding_hooks(topology);
 
-  if (topology->flags & HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM)
-    topology->is_thissystem = 1;
-
-  if (topology->is_thissystem) {
-#    ifdef HWLOC_LINUX_SYS
-    hwloc_set_linuxfs_hooks(topology);
-#    endif /* HWLOC_LINUX_SYS */
-
-#    ifdef HWLOC_AIX_SYS
-    hwloc_set_aix_hooks(topology);
-#    endif /* HWLOC_AIX_SYS */
-
-#    ifdef HWLOC_OSF_SYS
-    hwloc_set_osf_hooks(topology);
-#    endif /* HWLOC_OSF_SYS */
-
-#    ifdef HWLOC_SOLARIS_SYS
-    hwloc_set_solaris_hooks(topology);
-#    endif /* HWLOC_SOLARIS_SYS */
-
-#    ifdef HWLOC_WIN_SYS
-    hwloc_set_windows_hooks(topology);
-#    endif /* HWLOC_WIN_SYS */
-
-#    ifdef HWLOC_DARWIN_SYS
-    hwloc_set_darwin_hooks(topology);
-#    endif /* HWLOC_DARWIN_SYS */
-
-#    ifdef HWLOC_FREEBSD_SYS
-    hwloc_set_freebsd_hooks(topology);
-#    endif /* HWLOC_FREEBSD_SYS */
-
-#    ifdef HWLOC_HPUX_SYS
-    hwloc_set_hpux_hooks(topology);
-#    endif /* HWLOC_HPUX_SYS */
-  } else {
-    topology->set_thisproc_cpubind = dontset_thisproc_cpubind;
-    topology->get_thisproc_cpubind = dontget_thisproc_cpubind;
-    topology->set_thisthread_cpubind = dontset_thisthread_cpubind;
-    topology->get_thisthread_cpubind = dontget_thisthread_cpubind;
-    topology->set_proc_cpubind = dontset_proc_cpubind;
-    topology->get_proc_cpubind = dontget_proc_cpubind;
-#ifdef hwloc_thread_t
-    topology->set_thread_cpubind = dontset_thread_cpubind;
-    topology->get_thread_cpubind = dontget_thread_cpubind;
-#endif
-    topology->get_thisproc_last_cpu_location = dontget_thisproc_cpubind; /* cpubind instead of last_cpu_location is ok */
-    topology->get_thisthread_last_cpu_location = dontget_thisthread_cpubind; /* cpubind instead of last_cpu_location is ok */
-    topology->get_proc_last_cpu_location = dontget_proc_cpubind; /* cpubind instead of last_cpu_location is ok */
-    /* TODO: get_thread_last_cpu_location */
-    topology->set_thisproc_membind = dontset_thisproc_membind;
-    topology->get_thisproc_membind = dontget_thisproc_membind;
-    topology->set_thisthread_membind = dontset_thisthread_membind;
-    topology->get_thisthread_membind = dontget_thisthread_membind;
-    topology->set_proc_membind = dontset_proc_membind;
-    topology->get_proc_membind = dontget_proc_membind;
-    topology->set_area_membind = dontset_area_membind;
-    topology->get_area_membind = dontget_area_membind;
-    topology->alloc_membind = dontalloc_membind;
-    topology->free_membind = dontfree_membind;
-  }
-
-  /* if not is_thissystem, set_cpubind is fake
-   * and get_cpubind returns the whole system cpuset,
-   * so don't report that set/get_cpubind as supported
-   */
-  if (topology->is_thissystem) {
-#define DO(which,kind) \
-    if (topology->kind) \
-      topology->support.which##bind->kind = 1;
-    DO(cpu,set_thisproc_cpubind);
-    DO(cpu,get_thisproc_cpubind);
-    DO(cpu,set_proc_cpubind);
-    DO(cpu,get_proc_cpubind);
-    DO(cpu,set_thisthread_cpubind);
-    DO(cpu,get_thisthread_cpubind);
-#ifdef hwloc_thread_t
-    DO(cpu,set_thread_cpubind);
-    DO(cpu,get_thread_cpubind);
-#endif
-    DO(cpu,get_thisproc_last_cpu_location);
-    DO(cpu,get_proc_last_cpu_location);
-    DO(cpu,get_thisthread_last_cpu_location);
-    DO(mem,set_thisproc_membind);
-    DO(mem,get_thisproc_membind);
-    DO(mem,set_thisthread_membind);
-    DO(mem,get_thisthread_membind);
-    DO(mem,set_proc_membind);
-    DO(mem,get_proc_membind);
-    DO(mem,set_area_membind);
-    DO(mem,get_area_membind);
-    DO(mem,alloc_membind);
-  }
-
   return 0;
 }
 
 /* To be before discovery is actually launched,
  * Resets everything in case a previous load initialized some stuff.
  */
-static void
+void
 hwloc_topology_setup_defaults(struct hwloc_topology *topology)
 {
   struct hwloc_obj *root_obj;
 
   /* reset support */
-  topology->set_thisproc_cpubind = NULL;
-  topology->get_thisproc_cpubind = NULL;
-  topology->set_thisthread_cpubind = NULL;
-  topology->get_thisthread_cpubind = NULL;
-  topology->set_proc_cpubind = NULL;
-  topology->get_proc_cpubind = NULL;
-#ifdef hwloc_thread_t
-  topology->set_thread_cpubind = NULL;
-  topology->get_thread_cpubind = NULL;
-#endif
-  topology->get_thisproc_last_cpu_location = NULL;
-  topology->get_proc_last_cpu_location = NULL;
-  topology->get_thisthread_last_cpu_location = NULL;
-  topology->set_thisproc_membind = NULL;
-  topology->get_thisproc_membind = NULL;
-  topology->set_thisthread_membind = NULL;
-  topology->get_thisthread_membind = NULL;
-  topology->set_proc_membind = NULL;
-  topology->get_proc_membind = NULL;
-  topology->set_area_membind = NULL;
-  topology->get_area_membind = NULL;
-  topology->alloc = NULL;
-  topology->alloc_membind = NULL;
-  topology->free_membind = NULL;
+  memset(&topology->binding_hooks, 0, sizeof(topology->binding_hooks));
   memset(topology->support.discovery, 0, sizeof(*topology->support.discovery));
   memset(topology->support.cpubind, 0, sizeof(*topology->support.cpubind));
   memset(topology->support.membind, 0, sizeof(*topology->support.membind));
@@ -2561,11 +2353,12 @@
   if(!topology)
     return -1;
 
+  hwloc_components_init(topology);
+
   /* Setup topology context */
   topology->is_loaded = 0;
   topology->flags = 0;
   topology->is_thissystem = 1;
-  topology->backend_type = HWLOC_BACKEND_NONE; /* backend not specified by default */
   topology->pid = 0;
 
   topology->support.discovery = malloc(sizeof(*topology->support.discovery));
@@ -2579,6 +2372,9 @@
 
   hwloc_distances_init(topology);
 
+  topology->userdata_export_cb = NULL;
+  topology->userdata_import_cb = NULL;
+
   /* Make the topology look like something coherent but empty */
   hwloc_topology_setup_defaults(topology);
 
@@ -2600,131 +2396,55 @@
 #endif /* HWLOC_LINUX_SYS */
 }
 
-static int
-hwloc_backend_custom_init(struct hwloc_topology *topology)
-{
-  assert(topology->backend_type == HWLOC_BACKEND_NONE);
-
-  topology->levels[0][0]->type = HWLOC_OBJ_SYSTEM;
-  topology->is_thissystem = 0;
-  topology->backend_type = HWLOC_BACKEND_CUSTOM;
-  return 0;
-}
-
 int
-hwloc_custom_insert_topology(struct hwloc_topology *newtopology,
-			     struct hwloc_obj *newparent,
-			     struct hwloc_topology *oldtopology,
-			     struct hwloc_obj *oldroot)
+hwloc_topology_set_fsroot(struct hwloc_topology *topology, const char *fsroot_path)
 {
-  if (newtopology->backend_type != HWLOC_BACKEND_CUSTOM || newtopology->is_loaded || !oldtopology->is_loaded) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  hwloc__duplicate_objects(newtopology, newparent, oldroot ? oldroot : oldtopology->levels[0][0]);
-  return 0;
+  return hwloc_disc_component_force_enable(topology,
+					   0 /* api */,
+					   HWLOC_DISC_COMPONENT_TYPE_CPU, "linux",
+					   fsroot_path, NULL, NULL);
 }
 
-static void
-hwloc_backend_custom_exit(struct hwloc_topology *topology)
-{
-  assert(topology->backend_type == HWLOC_BACKEND_CUSTOM);
-
-  hwloc_topology_clear(topology);
-  hwloc_topology_setup_defaults(topology);
-
-  topology->backend_type = HWLOC_BACKEND_NONE;
-}
-
-static void
-hwloc_backend_exit(struct hwloc_topology *topology)
-{
-  switch (topology->backend_type) {
-#ifdef HWLOC_LINUX_SYS
-  case HWLOC_BACKEND_LINUXFS:
-    hwloc_backend_linuxfs_exit(topology);
-    break;
-#endif
-  case HWLOC_BACKEND_XML:
-    hwloc_backend_xml_exit(topology);
-    break;
-  case HWLOC_BACKEND_SYNTHETIC:
-    hwloc_backend_synthetic_exit(topology);
-    break;
-  case HWLOC_BACKEND_CUSTOM:
-    hwloc_backend_custom_exit(topology);
-    break;
-  default:
-    break;
-  }
-
-  assert(topology->backend_type == HWLOC_BACKEND_NONE);
-
-  if (topology->is_loaded) {
-    hwloc_topology_clear(topology);
-    hwloc_distances_destroy(topology);
-    hwloc_topology_setup_defaults(topology);
-    topology->is_loaded = 0;
-  }
-}
-
 int
-hwloc_topology_set_fsroot(struct hwloc_topology *topology, const char *fsroot_path __hwloc_attribute_unused)
+hwloc_topology_set_synthetic(struct hwloc_topology *topology, const char *description)
 {
-  /* cleanup existing backend */
-  hwloc_backend_exit(topology);
-
-#ifdef HWLOC_LINUX_SYS
-  if (hwloc_backend_linuxfs_init(topology, fsroot_path) < 0)
-    return -1;
-  return 0;
-#else /* HWLOC_LINUX_SYS */
-  errno = ENOSYS;
-  return -1;
-#endif /* HWLOC_LINUX_SYS */
+  return hwloc_disc_component_force_enable(topology,
+					   0 /* api */,
+					   -1, "synthetic",
+					   description, NULL, NULL);
 }
 
 int
-hwloc_topology_set_synthetic(struct hwloc_topology *topology, const char *description)
+hwloc_topology_set_xml(struct hwloc_topology *topology,
+		       const char *xmlpath)
 {
-  /* cleanup existing backend */
-  hwloc_backend_exit(topology);
-
-  return hwloc_backend_synthetic_init(topology, description);
+  return hwloc_disc_component_force_enable(topology,
+					   0 /* api */,
+					   -1, "xml",
+					   xmlpath, NULL, NULL);
 }
 
 int
-hwloc_topology_set_xml(struct hwloc_topology *topology __hwloc_attribute_unused,
-                       const char *xmlpath __hwloc_attribute_unused)
+hwloc_topology_set_xmlbuffer(struct hwloc_topology *topology,
+                             const char *xmlbuffer,
+                             int size)
 {
-  /* cleanup existing backend */
-  hwloc_backend_exit(topology);
-
-  return hwloc_backend_xml_init(topology, xmlpath, NULL, 0);
+  return hwloc_disc_component_force_enable(topology,
+					   0 /* api */,
+					   -1, "xml", NULL,
+					   xmlbuffer, (void*) (uintptr_t) size);
 }
 
 int
 hwloc_topology_set_custom(struct hwloc_topology *topology)
 {
-  /* cleanup existing backend */
-  hwloc_backend_exit(topology);
-
-  return hwloc_backend_custom_init(topology);
+  return hwloc_disc_component_force_enable(topology,
+					   0 /* api */,
+					   -1, "custom",
+					   NULL, NULL, NULL);
 }
 
 int
-hwloc_topology_set_xmlbuffer(struct hwloc_topology *topology __hwloc_attribute_unused,
-                             const char *xmlbuffer __hwloc_attribute_unused,
-                             int size __hwloc_attribute_unused)
-{
-  /* cleanup existing backend */
-  hwloc_backend_exit(topology);
-
-  return hwloc_backend_xml_init(topology, NULL, xmlbuffer, size);
-}
-
-int
 hwloc_topology_set_flags (struct hwloc_topology *topology, unsigned long flags)
 {
   topology->flags = flags;
@@ -2802,11 +2522,10 @@
   hwloc_free_unlinked_object (root);
 }
 
-static void
+void
 hwloc_topology_clear (struct hwloc_topology *topology)
 {
   unsigned l;
-  hwloc_distances_clear(topology);
   hwloc_topology_clear_tree (topology, topology->levels[0][0]);
   for (l=0; l<topology->nb_levels; l++) {
     free(topology->levels[l]);
@@ -2820,9 +2539,12 @@
 void
 hwloc_topology_destroy (struct hwloc_topology *topology)
 {
-  hwloc_backend_exit(topology);
+  hwloc_backends_disable_all(topology); /* calls distances_clear(), so must stay before distances_destroy() */
+  hwloc_components_destroy_all(topology);
+
   hwloc_topology_clear(topology);
   hwloc_distances_destroy(topology);
+
   free(topology->support.discovery);
   free(topology->support.cpubind);
   free(topology->support.membind);
@@ -2832,60 +2554,57 @@
 int
 hwloc_topology_load (struct hwloc_topology *topology)
 {
-  char *local_env;
   int err;
 
   if (topology->is_loaded) {
     hwloc_topology_clear(topology);
+    hwloc_distances_clear(topology);
     hwloc_topology_setup_defaults(topology);
+    topology->is_thissystem = 1;
     topology->is_loaded = 0;
   }
 
   /* enforce backend anyway if a FORCE variable was given */
-#ifdef HWLOC_LINUX_SYS
   {
     char *fsroot_path_env = getenv("HWLOC_FORCE_FSROOT");
-    if (fsroot_path_env) {
-      hwloc_backend_exit(topology);
-      hwloc_backend_linuxfs_init(topology, fsroot_path_env);
-    }
+    if (fsroot_path_env)
+      hwloc_disc_component_force_enable(topology,
+					1 /* env force */,
+					HWLOC_DISC_COMPONENT_TYPE_CPU, "linux",
+					fsroot_path_env, NULL, NULL);
   }
-#endif
   {
     char *xmlpath_env = getenv("HWLOC_FORCE_XMLFILE");
-    if (xmlpath_env) {
-      hwloc_backend_exit(topology);
-      hwloc_backend_xml_init(topology, xmlpath_env, NULL, 0);
-    }
+    if (xmlpath_env)
+      hwloc_disc_component_force_enable(topology,
+					1 /* env force */,
+					-1, "xml",
+					xmlpath_env, NULL, NULL);
   }
 
   /* only apply non-FORCE variables if we have not changed the backend yet */
-#ifdef HWLOC_LINUX_SYS
-  if (topology->backend_type == HWLOC_BACKEND_NONE) {
+  if (!topology->backends) {
     char *fsroot_path_env = getenv("HWLOC_FSROOT");
     if (fsroot_path_env)
-      hwloc_backend_linuxfs_init(topology, fsroot_path_env);
+      hwloc_disc_component_force_enable(topology,
+					1 /* env force */,
+					HWLOC_DISC_COMPONENT_TYPE_CPU, "linux",
+					fsroot_path_env, NULL, NULL);
   }
-#endif
-  if (topology->backend_type == HWLOC_BACKEND_NONE) {
+  if (!topology->backends) {
     char *xmlpath_env = getenv("HWLOC_XMLFILE");
     if (xmlpath_env)
-      hwloc_backend_xml_init(topology, xmlpath_env, NULL, 0);
+      hwloc_disc_component_force_enable(topology,
+					1 /* env force */,
+					-1, "xml",
+					xmlpath_env, NULL, NULL);
   }
 
-  /* always apply non-FORCE THISSYSTEM since it was explicitly designed to override setups from other backends */
-  local_env = getenv("HWLOC_THISSYSTEM");
-  if (local_env)
-    topology->is_thissystem = atoi(local_env);
+  /* instantiate all possible other backends now */
+  hwloc_disc_components_enable_others(topology);
+  /* now that backends are enabled, update the thissystem flag */
+  hwloc_backends_is_thissystem(topology);
 
-  /* if we haven't chosen the backend, set the OS-specific one if needed */
-  if (topology->backend_type == HWLOC_BACKEND_NONE) {
-#ifdef HWLOC_LINUX_SYS
-    if (hwloc_backend_linuxfs_init(topology, "/") < 0)
-      return -1;
-#endif
-  }
-
   /* get distance matrix from the environment are store them (as indexes) in the topology.
    * indexes will be converted into objects later once the tree will be filled
    */
@@ -2894,13 +2613,8 @@
   /* actual topology discovery */
   err = hwloc_discover(topology);
   if (err < 0)
-    return err;
+    goto out;
 
-  /* enforce THISSYSTEM if given in a FORCE variable */
-  local_env = getenv("HWLOC_FORCE_THISSYSTEM");
-  if (local_env)
-    topology->is_thissystem = atoi(local_env);
-
 #ifndef HWLOC_DEBUG
   if (getenv("HWLOC_DEBUG_CHECK"))
 #endif
@@ -2908,6 +2622,13 @@
 
   topology->is_loaded = 1;
   return 0;
+
+ out:
+  hwloc_topology_clear(topology);
+  hwloc_distances_destroy(topology);
+  hwloc_topology_setup_defaults(topology);
+  hwloc_backends_disable_all(topology);
+  return -1;
 }
 
 int
@@ -2917,7 +2638,7 @@
 
   /* make sure we'll keep something in the topology */
   if (!hwloc_bitmap_intersects(cpuset, topology->levels[0][0]->cpuset)) {
-    errno = EINVAL;
+    errno = EINVAL; /* easy failure, just don't touch the topology */
     return -1;
   }
 
@@ -2934,12 +2655,21 @@
   hwloc_bitmap_free(droppednodeset);
 
   hwloc_connect_children(topology->levels[0][0]);
-  hwloc_connect_levels(topology);
+  if (hwloc_connect_levels(topology) < 0)
+    goto out;
+
   propagate_total_memory(topology->levels[0][0]);
   hwloc_distances_restrict(topology, flags);
   hwloc_distances_finalize_os(topology);
   hwloc_distances_finalize_logical(topology);
   return 0;
+
+ out:
+  /* unrecoverable failure, re-init the topology */
+   hwloc_topology_clear(topology);
+   hwloc_distances_destroy(topology);
+   hwloc_topology_setup_defaults(topology);
+   return -1;
 }
 
 int
@@ -3009,6 +2739,7 @@
 
   /* checks for all children */
   for(j=1; j<parent->arity; j++) {
+    assert(parent->children[j]->parent == parent);
     assert(parent->children[j]->sibling_rank == j);
     assert(parent->children[j-1]->next_sibling == parent->children[j]);
     assert(parent->children[j]->prev_sibling == parent->children[j-1]);
@@ -3061,6 +2792,7 @@
   assert(hwloc_get_nbobjs_by_depth(topology, 0) == 1);
   obj = hwloc_get_root_obj(topology);
   assert(obj);
+  assert(!obj->parent);
 
   depth = hwloc_topology_get_depth(topology);
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,4 +1,4 @@
-# Copyright © 2009-2011 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009-2012 Université Bordeaux 1
 # Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 # See COPYING in top-level directory.
@@ -16,8 +16,10 @@
 
 LDADD =
 
-if HWLOC_BUILD_TESTS
-check_PROGRAMS = hwloc_bitmap \
+TESTS_ENVIRONMENT = $(builddir)/wrapper.sh
+
+check_PROGRAMS = hwloc_list_components \
+	hwloc_bitmap \
 	hwloc_bitmap_string \
 	hwloc_get_closest_objs \
 	hwloc_get_obj_covering_cpuset \
@@ -36,6 +38,7 @@
 	hwloc_synthetic \
 	hwloc_custom \
 	hwloc_backends \
+	hwloc_pci_backend \
 	hwloc_is_thissystem \
 	hwloc_distances \
 	hwloc_groups \
@@ -94,8 +97,6 @@
 hwloc_bind_LDADD += -lpthread
 endif
 
-endif HWLOC_BUILD_TESTS
-
 # ship the embedded test code but don't actually let automake ever
 # look at it because we have another configure stuff in there
 EXTRA_DIST = 	embedded/autogen.sh \

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_backends.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_backends.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_backends.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2011 inria.  All rights reserved.
+ * Copyright © 2012 Inria.  All rights reserved.
  * See COPYING in top-level directory.
  */
 
@@ -24,10 +24,12 @@
   char xmlfile[] = "hwloc_backends.tmpxml.XXXXXX";
   int xmlbufok = 0, xmlfileok = 0;
   hwloc_obj_t sw;
+  int err;
 
   printf("trying to export topology to XML buffer and file for later...\n");
   hwloc_topology_init(&topology1);
   hwloc_topology_load(topology1);
+  assert(hwloc_topology_is_thissystem(topology1));
   if (hwloc_topology_export_xmlbuffer(topology1, &xmlbuf, &xmlbuflen) < 0)
     printf("XML buffer export failed (%s), ignoring\n", strerror(errno));
   else
@@ -49,35 +51,53 @@
     printf("switching to xmlbuffer...\n");
     assert(!hwloc_topology_set_xmlbuffer(topology2, xmlbuf, xmlbuflen));
   }
+  printf("switching to custom...\n");
+  hwloc_topology_set_custom(topology2);
   printf("switching to synthetic...\n");
   hwloc_topology_set_synthetic(topology2, "machine:2 node:3 cache:2 pu:4");
-  printf("switching to custom...\n");
-  hwloc_topology_set_custom(topology2);
-  printf("switching sysfs fsroot...\n");
+  printf("switching sysfs fsroot to // ...\n");
+  hwloc_topology_set_fsroot(topology2, "//"); /* valid path that won't be recognized as '/' */
+  printf("switching sysfs fsroot to / ...\n");
   hwloc_topology_set_fsroot(topology2, "/");
 
   if (xmlfileok) {
     printf("switching to xml and loading...\n");
     assert(!hwloc_topology_set_xml(topology2, xmlfile));
     hwloc_topology_load(topology2);
+    hwloc_topology_check(topology2);
+    assert(!hwloc_topology_is_thissystem(topology2));
   }
   if (xmlbufok) {
     printf("switching to xmlbuffer and loading...\n");
     assert(!hwloc_topology_set_xmlbuffer(topology2, xmlbuf, xmlbuflen));
     hwloc_topology_load(topology2);
+    hwloc_topology_check(topology2);
+    assert(!hwloc_topology_is_thissystem(topology2));
   }
-  printf("switching to synthetic and loading...\n");
-  hwloc_topology_set_synthetic(topology2, "machine:2 node:3 cache:2 pu:4");
-  hwloc_topology_load(topology2);
   printf("switching to custom and loading...\n");
   hwloc_topology_set_custom(topology2);
   sw = hwloc_custom_insert_group_object_by_parent(topology2, hwloc_get_root_obj(topology2), 0);
   assert(sw);
   hwloc_custom_insert_topology(topology2, sw, topology1, NULL);
   hwloc_topology_load(topology2);
-  printf("switching sysfs fsroot and loading...\n");
-  hwloc_topology_set_fsroot(topology2, "/");
+  hwloc_topology_check(topology2);
+  assert(!hwloc_topology_is_thissystem(topology2));
+  /* don't try fsroot here because it fails on !linux, we would revert back to custom, which requires some insert to make the topology valid */
+  printf("switching to synthetic and loading...\n");
+  hwloc_topology_set_synthetic(topology2, "machine:2 node:3 cache:2 pu:4");
   hwloc_topology_load(topology2);
+  hwloc_topology_check(topology2);
+  assert(!hwloc_topology_is_thissystem(topology2));
+  printf("switching sysfs fsroot to // and loading...\n");
+  hwloc_topology_set_fsroot(topology2, "//"); /* valid path that won't be recognized as '/' */
+  hwloc_topology_load(topology2);
+  hwloc_topology_check(topology2);
+  assert(!hwloc_topology_is_thissystem(topology2)); /* earlier fsroot worked, or we're still synthetic */
+  printf("switching sysfs fsroot to / and loading...\n");
+  err = hwloc_topology_set_fsroot(topology2, "/");
+  hwloc_topology_load(topology2);
+  hwloc_topology_check(topology2);
+  assert(hwloc_topology_is_thissystem(topology2) == !err); /* on Linux, '/' is recognized as thissystem. on !Linux, set_fsroot() failed and we went back to synthetic */
 
   printf("switching to synthetic...\n");
   hwloc_topology_set_synthetic(topology2, "machine:2 node:3 cache:2 pu:4");

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_custom.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_custom.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_custom.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -14,12 +14,21 @@
 {
   hwloc_topology_t local, global;
   hwloc_obj_t sw1, sw2, sw11, sw12, sw21, sw22, root;
+  int err;
 
   printf("Loading the local topology...\n");
   hwloc_topology_init(&local);
   hwloc_topology_set_synthetic(local, "n:2 s:2 ca:1 core:2 ca:2 pu:2");
   hwloc_topology_load(local);
 
+  printf("Try to create an empty custom topology...\n");
+  hwloc_topology_init(&global);
+  hwloc_topology_set_custom(global);
+  err = hwloc_topology_load(global);
+  assert(err == -1);
+  assert(errno == EINVAL);
+  hwloc_topology_destroy(global);
+
   printf("Creating a custom topology...\n");
   hwloc_topology_init(&global);
   hwloc_topology_set_custom(global);

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_list_components.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_list_components.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_list_components.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#include <hwloc.h>
+
+#include <stdlib.h>
+
+int main(void)
+{
+  hwloc_topology_t topology;
+
+  putenv("HWLOC_COMPONENTS_VERBOSE=1");
+
+  hwloc_topology_init(&topology);
+  /* no load, to avoid spurious "enable" messages */
+  hwloc_topology_destroy(topology);
+  return 0;
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_object_userdata.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_object_userdata.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_object_userdata.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2009 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -9,11 +9,16 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <string.h>
 #include <assert.h>
 
 /* check that object userdata is properly initialized */
 
+#define RANDOMSTRINGLENGTH 128
+#define RANDOMSTRINGTESTS 9
+static char *randomstring;
+
 static void check(hwloc_topology_t topology)
 {
   unsigned depth;
@@ -27,10 +32,75 @@
   }
 }
 
+static void export_cb(void *reserved, hwloc_topology_t topo, hwloc_obj_t obj)
+{
+  char tmp[17];
+  int err;
+  unsigned i;
+
+  sprintf(tmp, "%016llx", (unsigned long long) (uintptr_t) obj->userdata);
+  err = hwloc_export_obj_userdata(reserved, topo, obj, "MyName", tmp, 16);
+  assert(err >= 0);
+
+  for(i=0; i<RANDOMSTRINGTESTS; i++) {
+    sprintf(tmp, "Encoded%d", i);
+    err = hwloc_export_obj_userdata_base64(reserved, topo, obj, tmp, randomstring+(i+1)/2, RANDOMSTRINGLENGTH-i);
+    assert(err >= 0);
+  }
+}
+
+static void import_cb(hwloc_topology_t topo __hwloc_attribute_unused, hwloc_obj_t obj, const char *name, const void *buffer, size_t length)
+{
+  int err;
+  char tmp[17];
+  uint64_t val;
+
+  if (!strcmp("MyName", name)) {
+    assert(length == 16);
+    memcpy(tmp, buffer, 16);
+    tmp[16] = '\0';
+    
+    val = strtoull(buffer, NULL, 0);
+
+    switch (val) {
+    case 0x1:
+      assert(obj->type == HWLOC_OBJ_MACHINE);
+      obj->userdata = (void *)(uintptr_t) 0x4;
+      break;
+    case 0x2:
+      assert(obj->type == HWLOC_OBJ_CACHE);
+      obj->userdata = (void *)(uintptr_t) 0x5;
+      break;
+    case 0x3:
+      assert(obj->type == HWLOC_OBJ_PU);
+      obj->userdata = (void *)(uintptr_t) 0x6;
+      break;
+    default:
+      assert(0);
+    }
+
+  } else if (!strncmp("Encoded", name, 7)) {
+    unsigned i = atoi(name+7);
+    assert(i >= 0);
+    assert(i <= RANDOMSTRINGTESTS-1);
+    assert(RANDOMSTRINGLENGTH-i == (unsigned) length);
+    err = memcmp(buffer, randomstring+(i+1)/2, length);
+    assert(!err);
+    
+  } else
+    assert(0);
+}
+
 int main(void)
 {
-  hwloc_topology_t topology;
+  hwloc_topology_t topology, reimport;
+  hwloc_obj_t obj1, obj2, obj3;
+  char *xmlbuf;
+  int xmlbuflen;
 
+  randomstring = malloc(RANDOMSTRINGLENGTH);
+  /* keep it uninitialized, we want binary data */
+
   /* check the real topology */
   hwloc_topology_init(&topology);
   hwloc_topology_load(topology);
@@ -42,7 +112,48 @@
   hwloc_topology_set_synthetic(topology, "6 5 4 3 2");
   hwloc_topology_load(topology);
   check(topology);
+
+  /* now place some userdata and see if importing/exporting works well */
+  obj1 = hwloc_get_root_obj(topology);
+  assert(obj1);
+  obj1->userdata = (void *)(uintptr_t) 0x1;
+  obj2 = hwloc_get_obj_by_depth(topology, 3, 13);
+  assert(obj2);
+  obj2->userdata = (void *)(uintptr_t) 0x2;
+  obj3 = hwloc_get_obj_by_depth(topology, 5, 2*3*4*5*6-1);
+  assert(obj3);
+  obj3->userdata = (void *)(uintptr_t) 0x3;
+
+  /* export/import without callback, we get nothing */
+  hwloc_topology_export_xmlbuffer(topology, &xmlbuf, &xmlbuflen);
+
+  hwloc_topology_init(&reimport);
+  hwloc_topology_set_xmlbuffer(reimport, xmlbuf, xmlbuflen);
+  hwloc_topology_load(reimport);
+  check(reimport); /* there should be no userdata */
+  hwloc_topology_destroy(reimport);
+
+  /* export/import with callback, we should get three userdata */
+  hwloc_topology_set_userdata_export_callback(topology, export_cb);
+  hwloc_topology_export_xmlbuffer(topology, &xmlbuf, &xmlbuflen);
+
+  hwloc_topology_init(&reimport);
+  hwloc_topology_set_userdata_import_callback(reimport, import_cb);
+  hwloc_topology_set_xmlbuffer(reimport, xmlbuf, xmlbuflen);
+  hwloc_topology_load(reimport);
+  obj1 = hwloc_get_root_obj(reimport);
+  assert(obj1);
+  assert(obj1->userdata == (void *)(uintptr_t) 0x4);
+  obj2 = hwloc_get_obj_by_depth(reimport, 3, 13);
+  assert(obj2);
+  assert(obj2->userdata == (void *)(uintptr_t) 0x5);
+  obj3 = hwloc_get_obj_by_depth(reimport, 5, 2*3*4*5*6-1);
+  assert(obj3);
+  assert(obj3->userdata == (void *)(uintptr_t) 0x6);
+  hwloc_topology_destroy(reimport);
+
   hwloc_topology_destroy(topology);
 
+  free(randomstring);
   return 0;
 }

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_pci_backend.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_pci_backend.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/hwloc_pci_backend.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2011-2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#include <hwloc.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+/* check whether the PCI backend behaves as expected wrt to thissystem, XML, flags, ... */
+
+static int get_nb_pcidev(unsigned long flags, int thissystem,
+			 const char *xmlbuf, int xmlbuflen)
+{
+  int nb;
+  hwloc_topology_t topology;
+
+  if (thissystem)
+    putenv("HWLOC_THISSYSTEM=1");
+  else
+    putenv("HWLOC_THISSYSTEM=0");
+  hwloc_topology_init(&topology);
+  hwloc_topology_set_flags(topology, flags);
+  if (xmlbuf)
+    hwloc_topology_set_xmlbuffer(topology, xmlbuf, xmlbuflen);
+  hwloc_topology_load(topology);
+
+  nb = hwloc_get_nbobjs_by_depth(topology, HWLOC_TYPE_DEPTH_PCI_DEVICE);
+
+  hwloc_topology_destroy(topology);
+
+  return nb;
+}
+
+int main(void)
+{
+  hwloc_topology_t topology;
+  char *xmlbuf;
+  int xmlbuflen;
+  int nb, nbnormal, nbwhole;
+
+  hwloc_topology_init(&topology);
+  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO);
+  hwloc_topology_load(topology);
+  if (hwloc_topology_export_xmlbuffer(topology, &xmlbuf, &xmlbuflen) < 0)
+    printf("XML buffer export failed (%s), ignoring\n", strerror(errno));
+
+  /* with HWLOC_THISSYSTEM=1 */
+  nb = get_nb_pcidev(0, 1, NULL, 0);
+  assert(!nb);
+  nbnormal = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES, 1, NULL, 0);
+  assert(nbnormal >= 0); /* may get more objects */
+  nbwhole = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO, 1, NULL, 0);
+  assert(nbwhole >= nbnormal); /* will get at least as much objects */
+
+  /* with HWLOC_THISSYSTEM=0, won't get any object */
+  nb = get_nb_pcidev(0, 0, NULL, 0);
+  assert(!nb);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES, 0, NULL, 0);
+  assert(!nb);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO, 0, NULL, 0);
+  assert(!nb);
+
+  /* XML with with HWLOC_THISSYSTEM=1, should get as many object as a native load */
+  nb = get_nb_pcidev(0, 1, xmlbuf, xmlbuflen);
+  assert(!nb);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES, 1, xmlbuf, xmlbuflen);
+  assert(nb == nbnormal);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO, 1, xmlbuf, xmlbuflen);
+  assert(nb == nbwhole);
+
+  /* XML with with HWLOC_THISSYSTEM=0,  should get as many object as a native load */
+  nb = get_nb_pcidev(0, 0, xmlbuf, xmlbuflen);
+  assert(!nb);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES, 0, xmlbuf, xmlbuflen);
+  assert(nb == nbnormal);
+  nb = get_nb_pcidev(HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO, 0, xmlbuf, xmlbuflen);
+  assert(nb == nbwhole);
+
+  hwloc_free_xmlbuffer(topology, xmlbuf);
+  hwloc_topology_destroy(topology);
+
+  return 0;
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-4n4c-cgroup-distance-merge.output
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-4n4c-cgroup-distance-merge.output	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-4n4c-cgroup-distance-merge.output	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,21 +1,21 @@
-Group0 (total=16777216KB)
-  L3Cache L#0 (size=2048KB linesize=64 ways=32)
+Machine (P#0 total=16777216KB DMIProductName=H8QM8 DMIProductVersion=1234567890 DMIBoardVendor=Supermicro DMIBoardName=H8QM8 DMIBoardVersion=1234567890 DMIBoardAssetTag="To Be Filled By O.E.M." DMIChassisVendor="To Be Filled By O.E.M." DMIChassisType=3 DMIChassisVersion="To Be Filled By O.E.M." DMIChassisAssetTag="To Be Filled By O.E.M." DMIBIOSVendor="American Megatrends Inc." DMIBIOSVersion="080014 " DMIBIOSDate=12/20/2008 DMISysVendor=Supermicro Backend=Linux LinuxCgroup=/prout)
+  NUMANode L#0 (P#0)
     PU L#0 (P#0)
     PU L#1 (P#1)
     PU L#2 (P#2)
     PU L#3 (P#3)
-  NUMANode L#0 (P#1)
-  NUMANode L#1 (P#2 local=8388608KB total=8388608KB)
-  NUMANode L#2 (P#3 local=8388608KB total=8388608KB)
-depth 0:	1 Group0 (type #7)
- depth 1:	1 L3Cache (type #4)
-  depth 2:	3 NUMANode (type #2)
-   depth 3:	4 PU (type #6)
-latency matrix between NUMANodes (depth 2) by logical indexes:
-  index     0     1     2
-      0 1.000 2.000 2.000
-      1 2.000 1.000 2.000
-      2 2.000 2.000 1.000
+  NUMANode L#1 (P#1)
+  NUMANode L#2 (P#2 local=8388608KB total=8388608KB)
+  NUMANode L#3 (P#3 local=8388608KB total=8388608KB)
+depth 0:	1 Machine (type #1)
+ depth 1:	4 NUMANode (type #2)
+  depth 2:	4 PU (type #6)
+latency matrix between NUMANodes (depth 1) by logical indexes:
+  index     0     1     2     3
+      0 1.000 2.000 2.000 2.000
+      1 2.000 1.000 2.000 2.000
+      2 2.000 2.000 1.000 2.000
+      3 2.000 2.000 2.000 1.000
 12 processors not represented in topology: 0x0000fff0
 12 processors online but not allowed: 0x0000fff0
 Topology not from this system

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-8n2c-cpusets_noadmin.output
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-8n2c-cpusets_noadmin.output	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16amd64-8n2c-cpusets_noadmin.output	2012-12-10 03:23:44 UTC (rev 10739)
@@ -29,7 +29,7 @@
         L1dCache L#4 (size=64KB linesize=64 ways=2)
           L1iCache L#4 (size=64KB linesize=64 ways=2)
             Core L#4 (P#0)
-              PU L#4 (P#4)
+              PU L#4 (P#4) (offline)
       L2Cache L#5 (size=1024KB linesize=64 ways=16)
         L1dCache L#5 (size=64KB linesize=64 ways=2)
           L1iCache L#5 (size=64KB linesize=64 ways=2)
@@ -46,31 +46,31 @@
         L1dCache L#7 (size=64KB linesize=64 ways=2)
           L1iCache L#7 (size=64KB linesize=64 ways=2)
             Core L#7 (P#1)
-              PU L#7 (P#7)
+              PU L#7 (P#7) (forbidden)
   NUMANode L#4 (P#4 local=8388608KB total=8388608KB)
     Socket L#4 (P#4 CPUModel="Dual Core AMD Opteron(tm) Processor 865")
       L2Cache L#8 (size=1024KB linesize=64 ways=16)
         L1dCache L#8 (size=64KB linesize=64 ways=2)
           L1iCache L#8 (size=64KB linesize=64 ways=2)
             Core L#8 (P#0)
-              PU L#8 (P#8)
+              PU L#8 (P#8) (forbidden)
       L2Cache L#9 (size=1024KB linesize=64 ways=16)
         L1dCache L#9 (size=64KB linesize=64 ways=2)
           L1iCache L#9 (size=64KB linesize=64 ways=2)
             Core L#9 (P#1)
-              PU L#9 (P#9)
+              PU L#9 (P#9) (forbidden)
   NUMANode L#5 (P#5 local=8388608KB total=8388608KB)
     Socket L#5 (P#5 CPUModel="Dual Core AMD Opteron(tm) Processor 865")
       L2Cache L#10 (size=1024KB linesize=64 ways=16)
         L1dCache L#10 (size=64KB linesize=64 ways=2)
           L1iCache L#10 (size=64KB linesize=64 ways=2)
             Core L#10 (P#0)
-              PU L#10 (P#10)
+              PU L#10 (P#10) (forbidden)
       L2Cache L#11 (size=1024KB linesize=64 ways=16)
         L1dCache L#11 (size=64KB linesize=64 ways=2)
           L1iCache L#11 (size=64KB linesize=64 ways=2)
             Core L#11 (P#1)
-              PU L#11 (P#11)
+              PU L#11 (P#11) (forbidden)
   NUMANode L#6 (P#6 local=8388608KB total=8388608KB)
     Socket L#6 (P#6 CPUModel="Dual Core AMD Opteron(tm) Processor 865")
       L2Cache L#12 (size=1024KB linesize=64 ways=16)

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16em64t-4s2c2t_merge.output
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16em64t-4s2c2t_merge.output	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/16em64t-4s2c2t_merge.output	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,26 +1,26 @@
 Machine (P#0 Backend=Linux)
-  L3Cache L#0 (size=4096KB linesize=64 ways=16)
+  Socket L#0 (P#0 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
     Core L#0 (P#0)
       PU L#0 (P#0)
       PU L#1 (P#8)
     Core L#1 (P#1)
       PU L#2 (P#4)
       PU L#3 (P#12)
-  L3Cache L#1 (size=4096KB linesize=64 ways=16)
+  Socket L#1 (P#1 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
     Core L#2 (P#0)
       PU L#4 (P#1)
       PU L#5 (P#9)
     Core L#3 (P#1)
       PU L#6 (P#5)
       PU L#7 (P#13)
-  L3Cache L#2 (size=4096KB linesize=64 ways=16)
+  Socket L#2 (P#2 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
     Core L#4 (P#0)
       PU L#8 (P#2)
       PU L#9 (P#10)
     Core L#5 (P#1)
       PU L#10 (P#6)
       PU L#11 (P#14)
-  L3Cache L#3 (size=4096KB linesize=64 ways=16)
+  Socket L#3 (P#3 CPUModel="Intel(R) Xeon(TM) CPU 2.60GHz")
     Core L#6 (P#0)
       PU L#12 (P#3)
       PU L#13 (P#11)
@@ -28,7 +28,7 @@
       PU L#14 (P#7)
       PU L#15 (P#15)
 depth 0:	1 Machine (type #1)
- depth 1:	4 L3Cache (type #4)
+ depth 1:	4 Socket (type #3)
   depth 2:	8 Core (type #5)
    depth 3:	16 PU (type #6)
 Topology not from this system

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -140,13 +140,11 @@
 		32amd64-4s2n4c-cgroup.xml.env \
 		96em64t-4n4d3ca2co-forcecpuinfo.env
 
-if HWLOC_BUILD_TESTS
 if HWLOC_HAVE_OPENAT
 if HWLOC_HAVE_BUNZIPP
 TESTS = $(sysfs_outputs)
 endif HWLOC_HAVE_BUNZIPP
 endif HWLOC_HAVE_OPENAT
-endif HWLOC_BUILD_TESTS
 
 EXTRA_DIST = $(sysfs_outputs) $(sysfs_tarballs) $(sysfs_excludes) $(sysfs_options) $(sysfs_envs)
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/gather/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/gather/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/gather/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -2,7 +2,6 @@
 # Copyright © 2010 Cisco Systems, Inc.  All rights reserved.
 # See COPYING in top-level directory.
 
-if HWLOC_BUILD_TESTS
 if HWLOC_HAVE_LINUX
 if HWLOC_HAVE_OPENAT
 if HWLOC_HAVE_BUNZIPP
@@ -10,4 +9,3 @@
 endif HWLOC_HAVE_BUNZIPP
 endif HWLOC_HAVE_OPENAT
 endif HWLOC_HAVE_LINUX
-endif HWLOC_BUILD_TESTS

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/test-topology.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/test-topology.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/linux/test-topology.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -16,6 +16,9 @@
 HWLOC_top_builddir="@HWLOC_top_builddir@"
 lstopo="$HWLOC_top_builddir/utils/lstopo-no-graphics"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 actual_output="$1"
 
 # make sure we use default numeric formats

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -9,11 +9,9 @@
 
 SRC = $(HWLOC_top_srcdir)/src
 
-if HWLOC_BUILD_TESTS
 if HWLOC_HAVE_LINUX
 check_LTLIBRARIES = libhwloc-ports.la
 endif HWLOC_HAVE_LINUX
-endif HWLOC_BUILD_TESTS
 
 # Note that AC_CONFIG_LINKS sets up the sym links for the files in
 # this directory (back to the $top_srcdir/src directory).  So if you
@@ -62,7 +60,7 @@
         -DHWLOC_OSF_SYS \
         -DHWLOC_WIN_SYS \
         -DHWLOC_DARWIN_SYS \
-        -DHWLOC_FREEBSD_SYS -DHAVE_SYS_CPUSET_H \
+        -DHWLOC_FREEBSD_SYS -DHAVE_SYS_CPUSET_H -DHAVE_CPUSET_SETID \
         -DHWLOC_HPUX_SYS \
         -DHWLOC_INSIDE_LIBHWLOC
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/sys/cpuset.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/sys/cpuset.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/sys/cpuset.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -11,11 +11,16 @@
 typedef long cpuset_t;
 typedef int cpulevel_t;
 typedef int cpuwhich_t;
+typedef int cpusetid_t;
 
+#define CPU_LEVEL_CPUSET 2
 #define CPU_LEVEL_WHICH 3
 #define CPU_WHICH_TID 1
 #define CPU_WHICH_PID 2
 
+int cpuset_setid(cpuwhich_t which, id_t id, cpusetid_t setid);
+int cpuset_getid(cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t *setid);
+
 #undef CPU_SETSIZE
 #define CPU_SETSIZE (sizeof(cpuset_t) * CHAR_BIT)
 #undef CPU_ZERO

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/windows.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/windows.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/ports/include/windows.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 inria.  All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux 1
+ * Copyright © 2009-2012 Université Bordeaux 1
  * See COPYING in top-level directory.
  */
 
@@ -49,7 +49,7 @@
 #define PAGE_EXECUTE_READWRITE	0x0040
 
 WINAPI HINSTANCE LoadLibrary(LPCSTR);
-WINAPI void *GetProcAddress(HINSTANCE, LPCSTR);
+WINAPI FARPROC GetProcAddress(HINSTANCE, LPCSTR);
 WINAPI DWORD GetLastError(void);
 
 DWORD_PTR WINAPI SetThreadAffinityMask(HANDLE hThread, DWORD_PTR dwThreadAffinityMask);

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 all-local:
-	@echo Existing targets: 'needed' and 'useless'
+	@echo Existing targets: 'needed' and 'useless' (and 'restore' once done)
 
 prepare:
 	@echo
@@ -11,12 +11,22 @@
 		-e '/^#define HWLOC_SYM_PREFIX_CAPS HWLOC_/s/HWLOC_/FOOBAR_/2'	\
 		-i $(abs_top_builddir)/include/hwloc/autogen/config.h $(abs_top_builddir)/include/private/autogen/config.h
 
+restore:
+	@echo
+	@echo "###############################"
+	@echo Restoring original headers...
+	@echo
+	sed	-e '/^#define HWLOC_SYM_TRANSFORM 1/s/1/0/'			\
+		-e '/^#define HWLOC_SYM_PREFIX foobar_/s/foobar_/hwloc_/1'	\
+		-e '/^#define HWLOC_SYM_PREFIX_CAPS FOOBAR_/s/FOOBAR_/HWLOC_/2'	\
+		-i $(abs_top_builddir)/include/hwloc/autogen/config.h $(abs_top_builddir)/include/private/autogen/config.h
+
 needed: prepare
 	@echo
 	@echo "###########################"
 	@echo Finding missing renaming...
 	@echo
-	cpp $(srcdir)/main.c -I $(abs_top_srcdir)/include -I $(abs_top_builddir)/include \
+	cpp $(CPPFLAGS) $(srcdir)/main.c -I $(abs_top_srcdir)/include -I $(abs_top_builddir)/include \
 		| egrep -i '(^| |\*)hwloc_'
 
 useless: prepare

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/main.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/main.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/rename/main.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -17,3 +17,4 @@
 #include "private/debug.h"
 #include "private/misc.h"
 #include "private/private.h"
+#include "private/xml.h"

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/wrapper.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/wrapper.sh.in	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/wrapper.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,14 @@
+#!/bin/sh
+#-*-sh-*-
+
+#
+# Copyright © 2012 Inria.  All rights reserved.
+# See COPYING in top-level directory.
+#
+
+abs_top_builddir="@abs_top_builddir@"
+
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
+"$@"

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -18,9 +18,7 @@
 
 # Only run the tests if we're building standalone, because the tests
 # call hwloc executables.
-if HWLOC_BUILD_TESTS
 TESTS = $(xml_inputs)
-endif HWLOC_BUILD_TESTS
 
 EXTRA_DIST = $(xml_inputs)
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/test-topology.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/test-topology.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xml/test-topology.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -16,6 +16,9 @@
 HWLOC_top_srcdir="@HWLOC_top_srcdir@"
 lstopo="@HWLOC_top_builddir@/utils/lstopo-no-graphics"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 if test x at HWLOC_XML_LOCALIZED@ = x1; then
   # make sure we use default numeric formats
   LANG=C

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xmlbuffer.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xmlbuffer.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/tests/xmlbuffer.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -53,7 +53,6 @@
   if (strcmp(hwloc_obj_get_info_by_name(hwloc_get_root_obj(topology), "UberUglyString"), "xy"))
     assert(0);
   hwloc_topology_export_xmlbuffer(topology, &buf2, &size2);
-  hwloc_topology_destroy(topology);
   printf("re-exported to buffer %p length %d\n", buf2, size2);
 
   if (strcmp(buf1, buf2)) {
@@ -69,6 +68,8 @@
   hwloc_free_xmlbuffer(topology, buf1);
   hwloc_free_xmlbuffer(topology, buf2);
 
+  hwloc_topology_destroy(topology);
+
   return err;
 }
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/Makefile.am
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/Makefile.am	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/Makefile.am	2012-12-10 03:23:44 UTC (rev 10739)
@@ -4,25 +4,23 @@
 #
 # See COPYING in top-level directory.
 
+# This makefile is only reached when building in standalone mode
+
 AM_CFLAGS = $(HWLOC_CFLAGS)
 AM_CPPFLAGS = $(HWLOC_CPPFLAGS)
 AM_LDFLAGS = $(HWLOC_LDFLAGS)
 
 LDADD = $(HWLOC_top_builddir)/src/libhwloc.la
 
-EXTRA_DIST = test-hwloc-assembler.input1 test-hwloc-assembler.input2 test-hwloc-assembler.output test-hwloc-calc.output test-hwloc-distances.output test-hwloc-distrib.output test-hwloc-ls.output
+EXTRA_DIST = test-hwloc-annotate.input test-hwloc-annotate.output test-hwloc-assembler.input1 test-hwloc-assembler.input2 test-hwloc-assembler.output test-hwloc-calc.output test-hwloc-distances.output test-hwloc-distrib.output test-hwloc-ls.output
 
 noinst_HEADERS = misc.h
 
-# Only build the utilities if we're building in standalone mode
-if HWLOC_BUILD_UTILS
-bin_PROGRAMS = lstopo-no-graphics hwloc-assembler hwloc-calc hwloc-bind hwloc-distances hwloc-distrib hwloc-ps
-endif
+bin_PROGRAMS = lstopo-no-graphics hwloc-annotate hwloc-assembler hwloc-calc hwloc-bind hwloc-distances hwloc-distrib hwloc-ps
 
 lstopo_no_graphics_SOURCES = lstopo.h lstopo.c lstopo-color.c lstopo-text.c lstopo-draw.c lstopo-fig.c lstopo-xml.c
 lstopo_no_graphics_CFLAGS = $(HWLOC_LIBXML2_CFLAGS) $(HWLOC_PCI_CFLAGS)
 lstopo_no_graphics_LDADD = $(LDADD) -lm $(HWLOC_TERMCAP_LIBS)
-if HWLOC_BUILD_UTILS
 lstopo_SOURCES = $(lstopo_no_graphics_SOURCES)
 lstopo_CPPFLAGS = $(AM_CPPFLAGS)
 lstopo_LDADD = $(lstopo_no_graphics_LDADD)
@@ -42,27 +40,24 @@
 lstopo_win_CFLAGS = $(lstopo_CFLAGS) -mwindows
 lstopo_win_LDADD = $(lstopo_LDADD)
 endif
-endif
 
 hwloc_calc_SOURCES = hwloc-calc.c hwloc-calc.h
 
 bin_SCRIPTS = hwloc-assembler-remote
 
-# Only run the tests if we're building standalone, because the tests
-# call hwloc executables.
-if HWLOC_BUILD_TESTS
 if !HWLOC_HAVE_MINGW32
-TESTS = test-hwloc-assembler.sh test-hwloc-calc.sh test-hwloc-distances.sh test-hwloc-distrib.sh test-hwloc-ls.sh
+TESTS = test-hwloc-annotate.sh test-hwloc-assembler.sh test-hwloc-calc.sh test-hwloc-distances.sh test-hwloc-distrib.sh test-hwloc-ls.sh
+if HWLOC_HAVE_PLUGINS
+TESTS += test-fake-plugin.sh
+endif HWLOC_HAVE_PLUGINS
 endif !HWLOC_HAVE_MINGW32
-endif HWLOC_BUILD_TESTS
 
 # Only install man pages if we're building in standalone mode
-if HWLOC_BUILD_UTILS
 man7_pages = hwloc.7
 EXTRA_DIST += $(man7_pages:.7=.7in)
 nodist_man_MANS = $(man7_pages)
 
-man1_pages = lstopo.1 hwloc-bind.1 hwloc-calc.1 hwloc-distances.1 hwloc-distrib.1 hwloc-ps.1 hwloc-assembler.1 hwloc-assembler-remote.1
+man1_pages = lstopo.1 hwloc-annotate.1 hwloc-bind.1 hwloc-calc.1 hwloc-distances.1 hwloc-distrib.1 hwloc-ps.1 hwloc-assembler.1 hwloc-assembler-remote.1
 EXTRA_DIST += $(man1_pages:.1=.1in)
 nodist_man_MANS += $(man1_pages)
 
@@ -123,4 +118,3 @@
 
 distclean-local:
 	rm -f $(nodist_man_MANS)
-endif

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.1in	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,110 @@
+.\" -*- nroff -*-
+.\" Copyright © 2012 inria.  All rights reserved.
+.\" See COPYING in top-level directory.
+.TH HWLOC-ANNOTATE "1" "#HWLOC_DATE#" "#PACKAGE_VERSION#" "#PACKAGE_NAME#"
+.SH NAME
+hwloc-annotate \- Add info attributes to a XML topology
+.
+.\" **************************
+.\"    Synopsis Section
+.\" **************************
+.SH SYNOPSIS
+.B hwloc-annotate
+[\fIoptions\fR]
+\fI<input.xml>\fR
+\fI<output.xml>\fR
+\fI<location>\fR
+\fI<mode>\fR
+\fI<annotation>\fR
+.
+.\" **************************
+.\"    Options Section
+.\" **************************
+.SH OPTIONS
+.
+.TP 10
+\fB\-\-ci\fR
+Clear the existing info attributes in the target objects before annotating.
+If no new annotation has to be added after clearing, \fImode\fR should be
+set to \fInone\fR.
+.
+.\" **************************
+.\"    Description Section
+.\" **************************
+.SH DESCRIPTION
+.
+hwloc-annotate loads a topology from a XML file, adds some annotations,
+and export the resulting topology to another XML file.
+The input and output files may be the same.
+.
+The annotation may be string info attributes.
+This is specified by the \fImode\fR:
+.TP
+.B info <name> <value>
+Specifies a new string info attribute whose name is \fIname\fR and
+value is \fIvalue\fR.
+.TP
+.B none
+No new annotation is added. This is useful when clearing existing attributes.
+.
+.PP
+Annotations may be added to one specific object in the topology,
+all of them, or all of a given type.
+This is specified by the \fIlocation\fR:
+.TP
+.B all
+annotates all objects in the topology.
+.TP
+.B root
+annotates the root object of the topology.
+.TP
+.B <type>:all
+annotates all objects of the given type.
+.TP
+.B <type>:<index>
+annotates the object of the given type and index.
+The index is logical.
+.
+.PP
+.B NOTE:
+It is highly recommended that you read the hwloc(7) overview page
+before reading this man page.  Most of the concepts described in
+hwloc(7) directly apply to the hwloc-annotate utility.
+.
+.\" **************************
+.\"    Examples Section
+.\" **************************
+.SH EXAMPLES
+.PP
+hwloc-annotate's operation is best described through several examples.
+.
+.PP
+Add an info attribute to all Core objects:
+
+    $ hwloc-annotate input.xml output.xml Core:all infoname infovalue
+
+Add an info attribute to the root object of the topology
+and modify the input XML directly:
+
+    $ hwloc-annotate file.xml file.xml root infoname infovalue
+
+.
+.\" **************************
+.\" Return value section
+.\" **************************
+.SH RETURN VALUE
+Upon successful execution, hwloc-annotate generates the output topology.
+The return value is 0.
+.
+.PP
+hwloc-annotate will return nonzero if any kind of error occurs, such as
+(but not limited to) failure to parse the command line.
+.
+.\" **************************
+.\"    See also section
+.\" **************************
+.SH SEE ALSO
+.
+.ft R
+hwloc(7), lstopo(1)
+.sp

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.c	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-annotate.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,166 @@
+/*
+ * Copyright © 2012 Inria.  All rights reserved.
+ * See COPYING in top-level directory.
+ */
+
+#include <private/private.h>
+#include <hwloc-calc.h>
+#include <hwloc.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+static void usage(const char *callname __hwloc_attribute_unused, FILE *where)
+{
+	fprintf(where, "Usage: hwloc-annotate [options] <input.xml> <output.xml> <location> <annotation>\n");
+	fprintf(where, "  <location> may be:\n");
+	fprintf(where, "    all, root, <type>:<logicalindex>, <type>:all\n");
+	fprintf(where, "  <annotation> may be:\n");
+	fprintf(where, "    info <name> <value>\n");
+	fprintf(where, "    none\n");
+        fprintf(where, "Options:\n");
+	fprintf(where, "  --ci\tClear existing infos\n");
+}
+
+static char *infoname = NULL, *infovalue = NULL;
+
+static int clearinfos = 0;
+
+static void apply(hwloc_obj_t obj)
+{
+	unsigned i;
+	if (clearinfos) {
+		/* this may be considered dangerous, applications should not modify objects directly */
+		for(i=0; i<obj->infos_count; i++) {
+			free(obj->infos[i].name);
+			free(obj->infos[i].value);
+		}
+		free(obj->infos);
+		obj->infos = NULL;
+		obj->infos_count = 0;
+	}
+	if (infoname)
+		hwloc_obj_add_info(obj, infoname, infovalue);
+}
+
+static void apply_recursive(hwloc_obj_t obj)
+{
+	unsigned i;
+	for(i=0; i<obj->arity; i++)
+		apply_recursive(obj->children[i]);
+	apply(obj);
+}
+
+int main(int argc, char *argv[])
+{
+	hwloc_topology_t topology;
+	char *callname, *input, *output, *location;
+	int err;
+
+	putenv("HWLOC_XML_VERBOSE=1");
+
+	callname = argv[0];
+	/* skip argv[0], handle options */
+	argc--;
+	argv++;
+
+	while (argc && *argv[0] == '-') {
+		if (!strcmp(argv[0], "--ci"))
+			clearinfos = 1;
+		else {
+			fprintf(stderr, "Unrecognized options: %s\n", argv[0]);
+			usage(callname, stderr);
+			exit(EXIT_FAILURE);
+		}
+		argc--;
+		argv++;
+	}
+
+	if (argc < 3) {
+		usage(callname, stderr);
+		exit(EXIT_FAILURE);
+	}
+	input = argv[0];
+	output = argv[1];
+	location = argv[2];
+	argc -= 3;
+	argv += 3;
+
+	if (argc < 1) {
+		usage(callname, stderr);
+		exit(EXIT_FAILURE);
+	}
+	if (!strcmp(argv[0], "info")) {
+		if (argc < 3) {
+			usage(callname, stderr);
+			exit(EXIT_FAILURE);
+		}
+		infoname = argv[1];
+		infovalue = argv[2];
+
+	} else if (!strcmp(argv[0], "none")) {
+		/* do nothing (maybe clear) */
+	} else {
+		fprintf(stderr, "Unrecognized annotation type: %s\n", argv[0]);
+		usage(callname, stderr);
+		exit(EXIT_FAILURE);
+	}
+
+	hwloc_topology_init(&topology);
+	err = hwloc_topology_set_xml(topology, input);
+	if (err < 0)
+		goto out;
+	hwloc_topology_load(topology);
+
+	if (!strcmp(location, "all")) {
+		apply_recursive(hwloc_get_root_obj(topology));
+	} else if (!strcmp(location, "root")) {
+		apply(hwloc_get_root_obj(topology));
+	} else {
+		unsigned i;
+		hwloc_obj_t obj;
+		hwloc_obj_type_t type;
+		size_t typelen;
+		int depth;
+		char *sep;
+		typelen = strspn(location, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+		if (!typelen || location[typelen] != ':') {
+			/* FIXME: warn */
+			goto out;
+		}
+		sep = &location[typelen];
+		depth = hwloc_calc_parse_depth_prefix(topology, hwloc_topology_get_depth(topology),
+						      location, typelen, &type, 0);
+		if (depth < 0) {
+			/* FIXME: warn */
+			goto out;
+		}
+		if (!strcmp(sep+1, "all")) {
+			for(i=0; i<hwloc_get_nbobjs_by_depth(topology, depth); i++) {
+				obj = hwloc_get_obj_by_depth(topology, depth, i);
+				assert(obj);
+				apply(obj);
+			}
+		} else {
+			i = atoi(sep+1);
+			obj = hwloc_get_obj_by_depth(topology, depth, i);
+			if (!obj) {
+				/* FIXME: warn */
+				goto out;
+			}
+			apply(obj);
+		}
+	}
+
+	err = hwloc_topology_export_xml(topology, output);
+	if (err < 0)
+		goto out;
+
+	hwloc_topology_destroy(topology);
+	exit(EXIT_SUCCESS);
+
+out:
+	hwloc_topology_destroy(topology);
+	exit(EXIT_FAILURE);
+}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-assembler.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-assembler.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-assembler.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2011 inria.  All rights reserved.
+ * Copyright © 2011-2012 Inria.  All rights reserved.
  * See COPYING in top-level directory.
  */
 
@@ -34,6 +34,7 @@
     callname = argv[0];
   else
     callname++;
+  /* skip argv[0], handle options */
   argc--;
   argv++;
 
@@ -70,6 +71,7 @@
   argv++;
 
   hwloc_topology_init(&topology);
+  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_IO|HWLOC_TOPOLOGY_FLAG_ICACHES);
   hwloc_topology_set_custom(topology);
 
   for(i=0, j=0; i<argc; i++, j++) {
@@ -95,6 +97,7 @@
     }
 
     hwloc_topology_init(&input);
+    hwloc_topology_set_flags(input, HWLOC_TOPOLOGY_FLAG_WHOLE_IO|HWLOC_TOPOLOGY_FLAG_ICACHES);
     if (hwloc_topology_set_xml(input, argv[i])) {
       fprintf(stderr, "Failed to set source XML file %s (%s)\n", argv[i], strerror(errno));
       hwloc_topology_destroy(input);

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -73,7 +73,16 @@
 This option has no impact on the format of input CPU set strings,
 both formats are always accepted.
 .TP
-\fB\-v\fR
+\fB\-f\fR \fB\-\-force\fR
+Launch the executable even if binding failed.
+.TP
+\fB\-q\fR \fB\-\-quiet\fR
+Hide non-fatal error messages.
+It includes locations pointing to non-existing objects,
+as well as failure to bind.
+This is usually useful in addition to \fB\-\-force\fR.
+.TP
+\fB\-v\fR \fB\-\-verbose\fR
 Verbose output.
 .TP
 \fB\-\-version\fR
@@ -89,6 +98,10 @@
 successful execution, hwloc-bind simply sets bindings and then execs
 the executable over itself.
 .
+If binding fails, or if the binding set is empty, and \fB\-\-force\fR
+was not given, hwloc-bind returns with an error instead of launching
+the executable.
+.
 .PP
 .B NOTE:
 It is highly recommended that you read the hwloc(7) overview page

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-bind.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
- * Copyright © 2009-2010 Université Bordeaux 1
+ * Copyright © 2009-2012 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.
  */
@@ -15,9 +15,11 @@
 #endif
 #include <errno.h>
 
-static void usage(FILE *where)
+#include "misc.h"
+
+void usage(const char *name, FILE *where)
 {
-  fprintf(where, "Usage: hwloc-bind [options] <location> -- command ...\n");
+  fprintf(where, "Usage: %s [options] <location> -- command ...\n", name);
   fprintf(where, " <location> may be a space-separated list of cpusets or objects\n");
   fprintf(where, "            as supported by the hwloc-calc utility, e.g:\n");
   hwloc_calc_locations_usage(where);
@@ -35,7 +37,9 @@
 		 "                 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, "  -v             Show verbose messages\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");
   fprintf(where, "  --version      Report version and exit\n");
 }
 
@@ -44,9 +48,11 @@
   hwloc_topology_t topology;
   unsigned depth;
   hwloc_bitmap_t cpubind_set, membind_set;
-  int cpubind = 1; /* membind if 0 */
+  int got_cpubind = 0, got_membind = 0;
+  int working_on_cpubind = 1; /* membind if 0 */
   int get_binding = 0;
   int get_last_cpu_location = 0;
+  int force = 0;
   int single = 0;
   int verbose = 0;
   int logical = 1;
@@ -56,8 +62,9 @@
   int membind_flags = 0;
   int opt;
   int ret;
-  hwloc_pid_t pid = 0;
-  char **orig_argv = argv;
+  int pid_number = 0;
+  hwloc_pid_t pid;
+  char *callname;
 
   cpubind_set = hwloc_bitmap_alloc();
   membind_set = hwloc_bitmap_alloc();
@@ -67,6 +74,7 @@
   hwloc_topology_load(topology);
   depth = hwloc_topology_get_depth(topology);
 
+  callname = argv[0];
   /* skip argv[0], handle options */
   argv++;
   argc--;
@@ -81,18 +89,26 @@
     opt = 0;
 
     if (*argv[0] == '-') {
-      if (!strcmp(argv[0], "-v")) {
-	verbose = 1;
+      if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose")) {
+	verbose++;
 	goto next;
       }
+      else if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
+	verbose--;
+	goto next;
+      }
       else if (!strcmp(argv[0], "--help")) {
-	usage(stdout);
+        usage("hwloc-bind", stdout);
 	return EXIT_SUCCESS;
       }
       else if (!strcmp(argv[0], "--single")) {
 	single = 1;
 	goto next;
       }
+      else if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--force")) {
+	force = 1;
+	goto next;
+      }
       else if (!strcmp(argv[0], "--strict")) {
 	cpubind_flags |= HWLOC_CPUBIND_STRICT;
 	membind_flags |= HWLOC_MEMBIND_STRICT;
@@ -100,15 +116,15 @@
       }
       else if (!strcmp(argv[0], "--pid")) {
         if (argc < 2) {
-          usage (stderr);
+          usage ("hwloc-bind", stderr);
           exit(EXIT_FAILURE);
         }
-        pid = atoi(argv[1]);
+        pid_number = atoi(argv[1]);
         opt = 1;
         goto next;
       }
       else if (!strcmp (argv[0], "--version")) {
-          printf("%s %s\n", orig_argv[0], VERSION);
+          printf("%s %s\n", callname, VERSION);
           exit(EXIT_SUCCESS);
       }
       if (!strcmp(argv[0], "-l") || !strcmp(argv[0], "--logical")) {
@@ -132,11 +148,11 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--cpubind")) {
-	  cpubind = 1;
+	  working_on_cpubind = 1;
 	  goto next;
       }
       else if (!strcmp (argv[0], "--membind")) {
-	  cpubind = 0;
+	  working_on_cpubind = 0;
 	  goto next;
       }
       else if (!strcmp (argv[0], "--mempolicy")) {
@@ -154,7 +170,7 @@
 	  membind_policy = HWLOC_MEMBIND_NEXTTOUCH;
 	else {
 	  fprintf(stderr, "Unrecognized memory binding policy %s\n", argv[1]);
-          usage (stderr);
+          usage ("hwloc-bind", stderr);
           exit(EXIT_FAILURE);
 	}
 	opt = 1;
@@ -162,44 +178,50 @@
       }
 
       fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
-      usage(stderr);
+      usage("hwloc-bind", stderr);
       return EXIT_FAILURE;
     }
 
     ret = hwloc_calc_process_arg(topology, depth, argv[0], logical,
-				 cpubind ? cpubind_set : membind_set,
+				 working_on_cpubind ? cpubind_set : membind_set,
 				 verbose);
     if (ret < 0) {
-      if (verbose)
+      if (verbose > 0)
 	fprintf(stderr, "assuming the command starts at %s\n", argv[0]);
       break;
     }
+    if (working_on_cpubind)
+      got_cpubind = 1;
+    else
+      got_membind = 1;
 
   next:
     argc -= opt+1;
     argv += opt+1;
   }
 
+  pid = hwloc_pid_from_number(pid_number, !(get_binding || get_last_cpu_location));
+
   if (get_binding || get_last_cpu_location) {
     char *s;
     const char *policystr = NULL;
     int err;
-    if (cpubind) {
+    if (working_on_cpubind) {
       if (get_last_cpu_location) {
-	if (pid)
+	if (pid_number)
 	  err = hwloc_get_proc_last_cpu_location(topology, pid, cpubind_set, 0);
 	else
 	  err = hwloc_get_last_cpu_location(topology, cpubind_set, 0);
       } else {
-	if (pid)
+	if (pid_number)
 	  err = hwloc_get_proc_cpubind(topology, pid, cpubind_set, 0);
 	else
 	  err = hwloc_get_cpubind(topology, cpubind_set, 0);
       }
       if (err) {
 	const char *errmsg = strerror(errno);
-	if (pid)
-	  fprintf(stderr, "hwloc_get_proc_%s %ld failed (errno %d %s)\n", get_last_cpu_location ? "last_cpu_location" : "cpubind", (long) pid, errno, errmsg);
+	if (pid_number)
+	  fprintf(stderr, "hwloc_get_proc_%s %d failed (errno %d %s)\n", get_last_cpu_location ? "last_cpu_location" : "cpubind", pid_number, errno, errmsg);
 	else
 	  fprintf(stderr, "hwloc_get_%s failed (errno %d %s)\n", get_last_cpu_location ? "last_cpu_location" : "cpubind", errno, errmsg);
 	return EXIT_FAILURE;
@@ -210,14 +232,14 @@
 	hwloc_bitmap_asprintf(&s, cpubind_set);
     } else {
       hwloc_membind_policy_t policy;
-      if (pid)
+      if (pid_number)
 	err = hwloc_get_proc_membind(topology, pid, membind_set, &policy, 0);
       else
 	err = hwloc_get_membind(topology, membind_set, &policy, 0);
       if (err) {
 	const char *errmsg = strerror(errno);
-        if (pid)
-          fprintf(stderr, "hwloc_get_proc_membind %ld failed (errno %d %s)\n", (long) pid, errno, errmsg);
+        if (pid_number)
+          fprintf(stderr, "hwloc_get_proc_membind %d failed (errno %d %s)\n", pid_number, errno, errmsg);
         else
 	  fprintf(stderr, "hwloc_get_membind failed (errno %d %s)\n", errno, errmsg);
 	return EXIT_FAILURE;
@@ -244,8 +266,14 @@
     return EXIT_SUCCESS;
   }
 
-  if (!hwloc_bitmap_iszero(membind_set)) {
-    if (verbose) {
+  if (got_membind) {
+    if (hwloc_bitmap_iszero(membind_set)) {
+      if (verbose >= 0)
+	fprintf(stderr, "cannot membind to empty set\n");
+      if (!force)
+	goto failed_binding;
+    }
+    if (verbose > 0) {
       char *s;
       hwloc_bitmap_asprintf(&s, membind_set);
       fprintf(stderr, "binding on memory set %s\n", s);
@@ -253,25 +281,33 @@
     }
     if (single)
       hwloc_bitmap_singlify(membind_set);
-    if (pid)
+    if (pid_number)
       ret = hwloc_set_proc_membind(topology, pid, membind_set, membind_policy, membind_flags);
     else
       ret = hwloc_set_membind(topology, membind_set, membind_policy, membind_flags);
-    if (ret) {
+    if (ret && verbose >= 0) {
       int bind_errno = errno;
       const char *errmsg = strerror(bind_errno);
       char *s;
       hwloc_bitmap_asprintf(&s, membind_set);
-      if (pid)
-        fprintf(stderr, "hwloc_set_proc_membind %s %ld failed (errno %d %s)\n", s, (long) pid, bind_errno, errmsg);
+      if (pid_number)
+        fprintf(stderr, "hwloc_set_proc_membind %s %d failed (errno %d %s)\n", s, pid_number, bind_errno, errmsg);
       else
         fprintf(stderr, "hwloc_set_membind %s failed (errno %d %s)\n", s, bind_errno, errmsg);
       free(s);
     }
+    if (ret && !force)
+      goto failed_binding;
   }
 
-  if (!hwloc_bitmap_iszero(cpubind_set)) {
-    if (verbose) {
+  if (got_cpubind) {
+    if (hwloc_bitmap_iszero(cpubind_set)) {
+      if (verbose >= 0)
+	fprintf(stderr, "cannot cpubind to empty set\n");
+      if (!force)
+	goto failed_binding;
+    }
+    if (verbose > 0) {
       char *s;
       hwloc_bitmap_asprintf(&s, cpubind_set);
       fprintf(stderr, "binding on cpu set %s\n", s);
@@ -279,21 +315,23 @@
     }
     if (single)
       hwloc_bitmap_singlify(cpubind_set);
-    if (pid)
+    if (pid_number)
       ret = hwloc_set_proc_cpubind(topology, pid, cpubind_set, cpubind_flags);
     else
       ret = hwloc_set_cpubind(topology, cpubind_set, cpubind_flags);
-    if (ret) {
+    if (ret && verbose >= 0) {
       int bind_errno = errno;
       const char *errmsg = strerror(bind_errno);
       char *s;
       hwloc_bitmap_asprintf(&s, cpubind_set);
-      if (pid)
-        fprintf(stderr, "hwloc_set_proc_cpubind %s %ld failed (errno %d %s)\n", s, (long) pid, bind_errno, errmsg);
+      if (pid_number)
+        fprintf(stderr, "hwloc_set_proc_cpubind %s %d failed (errno %d %s)\n", s, pid_number, bind_errno, errmsg);
       else
         fprintf(stderr, "hwloc_set_cpubind %s failed (errno %d %s)\n", s, bind_errno, errmsg);
       free(s);
     }
+    if (ret && !force)
+      goto failed_binding;
   }
 
   hwloc_bitmap_free(cpubind_set);
@@ -301,19 +339,26 @@
 
   hwloc_topology_destroy(topology);
 
-  if (pid)
+  if (pid_number)
     return EXIT_SUCCESS;
 
   if (0 == argc) {
-    fprintf(stderr, "%s: nothing to do!\n", orig_argv[0]);
+    fprintf(stderr, "%s: nothing to do!\n", callname);
     return EXIT_FAILURE;
   }
 
   ret = execvp(argv[0], argv);
   if (ret) {
       fprintf(stderr, "%s: Failed to launch executable \"%s\"\n", 
-              orig_argv[0], argv[0]);
+              callname, argv[0]);
       perror("execvp");
   }
   return EXIT_FAILURE;
+
+
+failed_binding:
+  hwloc_bitmap_free(cpubind_set);
+  hwloc_bitmap_free(membind_set);
+  hwloc_topology_destroy(topology);
+  return EXIT_FAILURE;
 }

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2010 inria.  All rights reserved.
+.\" Copyright © 2010-2012 Inria.  All rights reserved.
 .\" Copyright © 2009 Cisco Systems, Inc.  All rights reserved.
 .\" See COPYING in top-level directory.
 .TH HWLOC-CALC "1" "#HWLOC_DATE#" "#PACKAGE_VERSION#" "#PACKAGE_NAME#"
@@ -110,7 +110,11 @@
 Enforce the input in the given format, among \fBxml\fR, \fBfsroot\fR
 and \fBsynthetic\fR.
 .TP
-\fB\-v\fR
+\fB\-q\fR \fB\-\-quiet\fR
+Hide non-fatal error messages.
+It mostly includes locations pointing to non-existing objects.
+.TP
+\fB\-v\fR \fB\-\-verbose\fR
 Verbose output.
 .TP
 \fB\-\-version\fR

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2012 inria.  All rights reserved.
+ * Copyright © 2009-2012 Inria.  All rights reserved.
  * Copyright © 2009-2011 Université Bordeaux 1
  * Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
@@ -47,7 +47,8 @@
   fprintf(where, "  --restrict <cpuset>       Restrict the topology to processors listed in <cpuset>\n");
   hwloc_utils_input_format_usage(where, 10);
   fprintf(where, "Miscellaneous options:\n");
-  fprintf(where, "  -v                        Show verbose messages\n");
+  fprintf(where, "  -q --quiet                Hide non-fatal error messages\n");
+  fprintf(where, "  -v --verbose              Show verbose messages\n");
   fprintf(where, "  --version                 Report version and exit\n");
 }
 
@@ -191,7 +192,6 @@
   unsigned depth;
   hwloc_bitmap_t set;
   int cmdline_args = 0;
-  char **orig_argv = argv;
   hwloc_obj_type_t numberoftype = (hwloc_obj_type_t) -1;
   hwloc_obj_type_t intersecttype = (hwloc_obj_type_t) -1;
   hwloc_obj_type_t *hiertype = NULL;
@@ -206,8 +206,6 @@
   putenv("HWLOC_XML_VERBOSE=1");
   putenv("HWLOC_SYNTHETIC_VERBOSE=1");
 
-  callname = argv[0];
-
   set = hwloc_bitmap_alloc();
 
   hwloc_topology_init(&topology);
@@ -215,24 +213,33 @@
   hwloc_topology_load(topology);
   depth = hwloc_topology_get_depth(topology);
 
-  while (argc >= 2) {
-    if (*argv[1] == '-') {
-      if (!strcmp(argv[1], "-v")) {
-        verbose = 1;
+  callname = argv[0];
+  /* skip argv[0], handle options */
+  argv++;
+  argc--;
+
+  while (argc >= 1) {
+    if (*argv[0] == '-') {
+      if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose")) {
+        verbose++;
         goto next;
       }
-      if (!strcmp(argv[1], "--help")) {
+      if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
+        verbose--;
+        goto next;
+      }
+      if (!strcmp(argv[0], "--help")) {
 	usage(callname, stdout);
 	return EXIT_SUCCESS;
       }
-      if (!strcmp (argv[1], "--restrict")) {
+      if (!strcmp (argv[0], "--restrict")) {
 	hwloc_bitmap_t restrictset;
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
 	restrictset = hwloc_bitmap_alloc();
-	hwloc_bitmap_sscanf(restrictset, argv[2]);
+	hwloc_bitmap_sscanf(restrictset, argv[1]);
 	err = hwloc_topology_restrict (topology, restrictset, 0);
 	if (err) {
 	  perror("Restricting the topology");
@@ -243,13 +250,13 @@
 	argc--;
 	goto next;
       }
-      if (!strcmp(argv[1], "--number-of") || !strcmp(argv[1], "-N")) {
-	if (argc <= 2) {
+      if (!strcmp(argv[0], "--number-of") || !strcmp(argv[0], "-N")) {
+	if (argc < 2) {
 	  usage(callname, stderr);
 	  return EXIT_SUCCESS;
 	}
-	if (hwloc_calc_type_depth(argv[2], &numberoftype, &numberofdepth) < 0) {
-	  fprintf(stderr, "unrecognized --number-of type or depth %s\n", argv[2]);
+	if (hwloc_calc_type_depth(argv[1], &numberoftype, &numberofdepth) < 0) {
+	  fprintf(stderr, "unrecognized --number-of type or depth %s\n", argv[1]);
 	  usage(callname, stderr);
 	  return EXIT_SUCCESS;
 	}
@@ -257,13 +264,13 @@
 	argc--;
 	goto next;
       }
-      if (!strcmp(argv[1], "--intersect") || !strcmp(argv[1], "-I")) {
-	if (argc <= 2) {
+      if (!strcmp(argv[0], "--intersect") || !strcmp(argv[0], "-I")) {
+	if (argc < 2) {
 	  usage(callname, stderr);
 	  return EXIT_SUCCESS;
 	}
-	if (hwloc_calc_type_depth(argv[2], &intersecttype, &intersectdepth) < 0) {
-	  fprintf(stderr, "unrecognized --intersect type or depth %s\n", argv[2]);
+	if (hwloc_calc_type_depth(argv[1], &intersecttype, &intersectdepth) < 0) {
+	  fprintf(stderr, "unrecognized --intersect type or depth %s\n", argv[1]);
 	  usage(callname, stderr);
 	  return EXIT_SUCCESS;
 	}
@@ -271,14 +278,14 @@
 	argc--;
 	goto next;
       }
-      if (!strcmp(argv[1], "--hierarchical") || !strcmp(argv[1], "-H")) {
+      if (!strcmp(argv[0], "--hierarchical") || !strcmp(argv[0], "-H")) {
 	char *tmp, *next;
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage(callname, stderr);
 	  return EXIT_SUCCESS;
 	}
 	hiernblevels = 1;
-	tmp = argv[2];
+	tmp = argv[1];
         while (1) {
 	  tmp = strchr(tmp, '.');
 	  if (!tmp)
@@ -288,7 +295,7 @@
         }
 	hiertype = malloc(hiernblevels * sizeof(hwloc_obj_type_t));
 	hierdepth = malloc(hiernblevels * sizeof(int));
-	tmp = argv[2];
+	tmp = argv[1];
 	for(i=0; i<hiernblevels; i++) {
 	  next = strchr(tmp, '.');
 	  if (next)
@@ -304,69 +311,69 @@
 	argc--;
 	goto next;
       }
-      if (!strcasecmp(argv[1], "--pulist") || !strcmp(argv[1], "--proclist")) {
+      if (!strcasecmp(argv[0], "--pulist") || !strcmp(argv[0], "--proclist")) {
 	/* backward compat with 1.0 */
 	intersecttype = HWLOC_OBJ_PU;
         goto next;
       }
-      if (!strcmp(argv[1], "--nodelist")) {
+      if (!strcmp(argv[0], "--nodelist")) {
 	/* backward compat with 1.0 */
 	intersecttype = HWLOC_OBJ_NODE;
         goto next;
       }
-      if (!strcmp(argv[1], "--largest")  || !strcmp(argv[1], "--objects") /* backward compat with 1.0 */) {
+      if (!strcmp(argv[0], "--largest")  || !strcmp(argv[0], "--objects") /* backward compat with 1.0 */) {
 	showobjs = 1;
         goto next;
       }
-      if (!strcmp(argv[1], "--version")) {
-        printf("%s %s\n", orig_argv[0], VERSION);
+      if (!strcmp(argv[0], "--version")) {
+        printf("%s %s\n", callname, VERSION);
         exit(EXIT_SUCCESS);
       }
-      if (!strcmp(argv[1], "-l") || !strcmp(argv[1], "--logical")) {
+      if (!strcmp(argv[0], "-l") || !strcmp(argv[0], "--logical")) {
 	logicali = 1;
 	logicalo = 1;
 	goto next;
       }
-      if (!strcmp(argv[1], "--li") || !strcmp(argv[1], "--logical-input")) {
+      if (!strcmp(argv[0], "--li") || !strcmp(argv[0], "--logical-input")) {
 	logicali = 1;
 	goto next;
       }
-      if (!strcmp(argv[1], "--lo") || !strcmp(argv[1], "--logical-output")) {
+      if (!strcmp(argv[0], "--lo") || !strcmp(argv[0], "--logical-output")) {
 	logicalo = 1;
 	goto next;
       }
-      if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--physical")) {
+      if (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--physical")) {
 	logicali = 0;
 	logicalo = 0;
 	goto next;
       }
-      if (!strcmp(argv[1], "--pi") || !strcmp(argv[1], "--physical-input")) {
+      if (!strcmp(argv[0], "--pi") || !strcmp(argv[0], "--physical-input")) {
 	logicali = 0;
 	goto next;
       }
-      if (!strcmp(argv[1], "--po") || !strcmp(argv[1], "--physical-output")) {
+      if (!strcmp(argv[0], "--po") || !strcmp(argv[0], "--physical-output")) {
 	logicalo = 0;
 	goto next;
       }
-      if (!strcmp(argv[1], "--sep")) {
-	if (argc <= 2) {
+      if (!strcmp(argv[0], "--sep")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-	outsep = argv[2];
+	outsep = argv[1];
 	argv++;
 	argc--;
 	goto next;
       }
-      if (!strcmp(argv[1], "--single")) {
+      if (!strcmp(argv[0], "--single")) {
 	singlify = 1;
 	goto next;
       }
-      if (!strcmp(argv[1], "--taskset")) {
+      if (!strcmp(argv[0], "--taskset")) {
 	taskset = 1;
 	goto next;
       }
-      if (hwloc_utils_lookup_input_option(argv+1, argc, &opt,
+      if (hwloc_utils_lookup_input_option(argv, argc, &opt,
 					  &input, &input_format,
 					  callname)) {
 	argv += opt;
@@ -375,7 +382,7 @@
 	goto next;
       }
 
-      fprintf (stderr, "Unrecognized option: %s\n", argv[1]);
+      fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
       usage(callname, stderr);
       return EXIT_FAILURE;
     }
@@ -391,8 +398,8 @@
     }
 
     cmdline_args++;
-    if (hwloc_calc_process_arg(topology, depth, argv[1], logicali, set, verbose) < 0)
-      fprintf(stderr, "ignored unrecognized argument %s\n", argv[1]);
+    if (hwloc_calc_process_arg(topology, depth, argv[0], logicali, set, verbose) < 0)
+      fprintf(stderr, "ignored unrecognized argument %s\n", argv[0]);
 
  next:
     argc--;
@@ -455,7 +462,7 @@
 	  break;
 	current = NULL;
 	if (hwloc_calc_process_arg(topology, depth, token, logicali, set, verbose) < 0)
-	  fprintf(stderr, "ignored unrecognized argument %s\n", argv[1]);
+	  fprintf(stderr, "ignored unrecognized argument %s\n", token);
       }
       hwloc_calc_output(topology, outsep, set);
     }

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-calc.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -38,25 +38,25 @@
   hwloc_bitmap_asprintf(&s2, set);
   switch (mode) {
   case HWLOC_CALC_APPEND_ADD:
-    if (verbose)
+    if (verbose > 0)
       fprintf(stderr, "adding %s to %s\n",
           s1, s2);
     hwloc_bitmap_or(set, set, newset);
     break;
   case HWLOC_CALC_APPEND_CLR:
-    if (verbose)
+    if (verbose > 0)
       fprintf(stderr, "clearing %s from %s\n",
           s1, s2);
     hwloc_bitmap_andnot(set, set, newset);
     break;
   case HWLOC_CALC_APPEND_AND:
-    if (verbose)
+    if (verbose > 0)
       fprintf(stderr, "and'ing %s from %s\n",
           s1, s2);
     hwloc_bitmap_and(set, set, newset);
     break;
   case HWLOC_CALC_APPEND_XOR:
-    if (verbose)
+    if (verbose > 0)
       fprintf(stderr, "xor'ing %s from %s\n",
           s1, s2);
     hwloc_bitmap_xor(set, set, newset);
@@ -160,14 +160,16 @@
       return -1;
     depth = hwloc_get_type_or_above_depth(topology, type);
     if (depth == HWLOC_TYPE_DEPTH_MULTIPLE) {
-      fprintf(stderr, "type %s has multiple possible depths\n", hwloc_obj_type_string(type));
+      if (verbose >= 0)
+	fprintf(stderr, "type %s has multiple possible depths\n", hwloc_obj_type_string(type));
       return -1;
     } else if (depth == HWLOC_TYPE_DEPTH_UNKNOWN) {
-      fprintf(stderr, "type %s isn't available\n", hwloc_obj_type_string(type));
+      if (verbose >= 0)
+	fprintf(stderr, "type %s isn't available\n", hwloc_obj_type_string(type));
       return -1;
     }
     realtype = hwloc_get_depth_type(topology, depth);
-    if (type != realtype && verbose)
+    if (type != realtype && verbose > 0)
       fprintf(stderr, "using type %s (depth %d) instead of %s\n",
 	      hwloc_obj_type_string(realtype), depth, hwloc_obj_type_string(type));
     return depth;
@@ -178,8 +180,9 @@
       for(i=0; ; i++) {
 	hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, i, 0);
 	if (!obj) {
-	  fprintf(stderr, "Group with custom depth %d does not exist\n",
-		  depthattr);
+	  if (verbose >= 0)
+	    fprintf(stderr, "Group with custom depth %d does not exist\n",
+		    depthattr);
 	  return -1;
 	}
 	if (obj->type == type
@@ -188,10 +191,12 @@
       }
     else if (type == HWLOC_OBJ_CACHE) {
       depth = hwloc_get_cache_type_depth(topology, depthattr, cachetype);
-      if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
-	fprintf(stderr, "Cache with custom depth %d and type %d does not exist\n", depthattr, cachetype);
-      else if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
-	fprintf(stderr, "Cache with custom depth %d and type %d has multiple possible depths\n", depthattr, cachetype);
+      if (verbose >= 0) {
+	if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)
+	  fprintf(stderr, "Cache with custom depth %d and type %d does not exist\n", depthattr, cachetype);
+	else if (depth == HWLOC_TYPE_DEPTH_MULTIPLE)
+	  fprintf(stderr, "Cache with custom depth %d and type %d has multiple possible depths\n", depthattr, cachetype);
+      }
       return depth;
     } else
       assert(0);
@@ -216,7 +221,8 @@
   int err;
 
   if (typelen >= sizeof(typestring)) {
-    fprintf(stderr, "invalid type name %s\n", string);
+    if (verbose >= 0)
+      fprintf(stderr, "invalid type name %s\n", string);
     return -1;
   }
   strncpy(typestring, string, typelen);
@@ -232,11 +238,13 @@
   /* try to match a numeric depth */
   depth = strtol(string, &end, 0);
   if (end != &string[typelen]) {
-    fprintf(stderr, "invalid type name %s\n", string);
+    if (verbose >= 0)
+      fprintf(stderr, "invalid type name %s\n", string);
     return -1;
   }
   if ((unsigned) depth >= topodepth) {
-    fprintf(stderr, "ignoring invalid depth %u\n", depth);
+    if (verbose >= 0)
+      fprintf(stderr, "ignoring invalid depth %u\n", depth);
     return -1;
   }
   *typep = (hwloc_obj_type_t) -1;
@@ -351,7 +359,7 @@
       i = 0;
 
     obj = hwloc_calc_get_obj_inside_cpuset_by_depth(topology, rootset, depth, i, logical);
-    if (verbose || !obj) {
+    if (verbose > 0 || (!obj && verbose >= 0)) {
       char *s;
       hwloc_bitmap_asprintf(&s, rootset);
       if (obj)
@@ -461,13 +469,14 @@
   for(oldi=-1, i=first, j=0; j<amount || amount == -1; oldi=i, i+=step, j++) {
     obj = hwloc_calc_find_next_pci_object(topology, vendor, device, obj, i-oldi, wrap);
     if (obj) {
-      if (verbose)
+      if (verbose > 0)
 	printf("using matching PCI object #%d bus id %04x:%02x:%02x.%01x\n", i,
 	       obj->attr->pcidev.domain, obj->attr->pcidev.bus, obj->attr->pcidev.dev, obj->attr->pcidev.func);
       hwloc_calc_append_iodev(set, obj, HWLOC_CALC_APPEND_ADD, verbose);
     } else {
       if (amount != -1)
-	fprintf(stderr, "no matching PCI object #%d\n", i);
+	if (verbose >= 0)
+	  fprintf(stderr, "no matching PCI object #%d\n", i);
       break;
     }
   }
@@ -478,7 +487,8 @@
    * but we don't want some ugly and unmaintainable code
    */
 
-  fprintf(stderr, "invalid PCI device %s\n", string);
+  if (verbose >= 0)
+    fprintf(stderr, "invalid PCI device %s\n", string);
   return -1;
 }
 
@@ -534,7 +544,8 @@
 	obj = hwloc_get_pcidev_by_busidstring(topology, sep+1);
 	if (obj)
 	  return hwloc_calc_append_iodev(set, obj, mode, verbose);
-	fprintf(stderr, "invalid PCI device %s\n", sep+1);
+	if (verbose >= 0)
+	  fprintf(stderr, "invalid PCI device %s\n", sep+1);
 	return -1;
       } else if (*sep == '=' && type == HWLOC_OBJ_OS_DEVICE) {
 	/* try to match a OS device name */
@@ -542,7 +553,8 @@
 	  if (!strcmp(obj->name, sep+1))
 	    return hwloc_calc_append_iodev(set, obj, mode, verbose);
 	}
-	fprintf(stderr, "invalid OS device %s\n", sep+1);
+	if (verbose >= 0)
+	  fprintf(stderr, "invalid OS device %s\n", sep+1);
 	return -1;
       } else
 	return -1;

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2011 inria.  All rights reserved.
+.\" Copyright © 2012 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,7 +49,7 @@
 \fB\-\-restrict\fR <cpuset>
 Restrict the topology to the given cpuset.
 .TP
-\fB\-v\fR
+\fB\-v\fR \fB\-\-verbose\fR
 Verbose messages.
 .TP
 \fB\-\-version\fR

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distances.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2009-2011 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -26,7 +26,7 @@
   fprintf(where, "  --restrict <set> Restrict the topology to processors listed in <set>\n");
   hwloc_utils_input_format_usage(where, 0);
   fprintf(where, "Miscellaneous options:\n");
-  fprintf(where, "  -v               Show verbose messages\n");
+  fprintf(where, "  -v --verbose     Show verbose messages\n");
   fprintf(where, "  --version        Report version and exit\n");
 }
 
@@ -49,8 +49,8 @@
 
   hwloc_topology_init(&topology);
 
+  callname = argv[0];
   /* skip argv[0], handle options */
-  callname = argv[0];
   argv++;
   argc--;
 
@@ -66,7 +66,7 @@
 	usage(callname, stdout);
 	return EXIT_SUCCESS;
       }
-      if (!strcmp(argv[0], "-v")) {
+      if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose")) {
 	verbose++;
 	goto next;
       }
@@ -86,7 +86,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--restrict")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage (callname, stdout);
 	  exit(EXIT_FAILURE);
 	}

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2010 inria.  All rights reserved.
+.\" Copyright © 2010-2012 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#"
@@ -25,7 +25,7 @@
 Show CPU set strings in the format recognized by the taskset command-line
 program instead of hwloc-specific CPU set string format.
 .TP
-\fB\-v\fR
+\fB\-v\fR \fB\-\-verbose\fR
 Verbose messages.
 .TP
 \fB\-i\fR <file>, \fB\-\-input\fR <file>

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-distrib.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2010 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -30,7 +30,7 @@
   fprintf(where, "  --single         Singlify each output to a single CPU\n");
   fprintf(where, "  --taskset        Show taskset-specific cpuset strings\n");
   fprintf(where, "Miscellaneous options:\n");
-  fprintf(where, "  -v               Show verbose messages\n");
+  fprintf(where, "  -v --verbose     Show verbose messages\n");
   fprintf(where, "  --version        Report version and exit\n");
 }
 
@@ -45,7 +45,6 @@
   int verbose = 0;
   char *restrictstring = NULL;
   hwloc_obj_type_t from_type = (hwloc_obj_type_t) -1, to_type = (hwloc_obj_type_t) -1;
-  char **orig_argv = argv;
   hwloc_topology_t topology;
   int opt;
   int err;
@@ -56,8 +55,8 @@
 
   hwloc_topology_init(&topology);
 
-  /* skip argv[0], handle options */
   callname = argv[0];
+  /* skip argv[0], handle options */
   argv++;
   argc--;
 
@@ -77,7 +76,7 @@
 	taskset = 1;
 	goto next;
       }
-      if (!strcmp(argv[0], "-v")) {
+      if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--verbose")) {
 	verbose = 1;
 	goto next;
       }
@@ -93,7 +92,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--ignore")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage(callname, stdout);
 	  exit(EXIT_FAILURE);
 	}
@@ -103,7 +102,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--from")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage(callname, stdout);
 	  exit(EXIT_FAILURE);
 	}
@@ -113,7 +112,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--to")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage(callname, stdout);
 	  exit(EXIT_FAILURE);
 	}
@@ -123,7 +122,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--at")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage(callname, stdout);
 	  exit(EXIT_FAILURE);
 	}
@@ -133,7 +132,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--restrict")) {
-	if (argc <= 2) {
+	if (argc < 2) {
 	  usage (callname, stdout);
 	  exit(EXIT_FAILURE);
 	}
@@ -143,7 +142,7 @@
 	goto next;
       }
       else if (!strcmp (argv[0], "--version")) {
-          printf("%s %s\n", orig_argv[0], VERSION);
+          printf("%s %s\n", callname, VERSION);
           exit(EXIT_SUCCESS);
       }
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -41,6 +41,12 @@
 .TP
 \fB\-\-whole\-system\fR
 Do not consider administration limitations.
+.TP
+\fB\-\-pid\-cmd <cmd>\fR
+Append the output of the given command to each PID line.
+For each displayed process ID, execute the command \fI<cmd> <pid>\fR
+and append \fBthe first line\fR of its output to the regular hwloc-ps
+line.
 .
 .\" **************************
 .\"    Description Section
@@ -96,6 +102,20 @@
      4762	PU:2		
      4765	PU:1		
 
+To display the binding of already running MPI processes (launched by
+Open MPI) and append their MPI rank (in MPI_COMM_WORLD) to each line:
+
+    $ utils/hwloc-ps --pid-cmd myscript
+    29093	L1dCache:0	myprogram	OMPI_COMM_WORLD_RANK=0
+    29094	L1dCache:2	myprogram	OMPI_COMM_WORLD_RANK=1
+    29095	L1dCache:1	myprogram	OMPI_COMM_WORLD_RANK=2
+    29096	L1dCache:3	myprogram	OMPI_COMM_WORLD_RANK=3
+
+where \fBmyscript\fR is a bash script doing:
+
+    #!/bin/sh
+    cat /proc/$1/environ 2>/dev/null | xargs --null --max-args=1 echo | grep OMPI_COMM_WORLD_RANK
+
 .\" **************************
 .\"    See also section
 .\" **************************

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc-ps.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
- * Copyright © 2009-2010 inria.  All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux 1
+ * Copyright © 2009-2012 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.
  */
@@ -19,26 +19,30 @@
 #endif
 #include <fcntl.h>
 
+#include "misc.h"
+
 static int show_cpuset = 0;
 static int logical = 1;
 
-static void usage(char *name, FILE *where)
+void usage(const char *name, FILE *where)
 {
   fprintf (where, "Usage: %s [ options ] ...\n", name);
   fprintf (where, "Options:\n");
-  fprintf (where, "  -a             Show all processes, including those that are not bound\n");
-  fprintf (where, "  -l --logical   Use logical object indexes (default)\n");
-  fprintf (where, "  -p --physical  Use physical object indexes\n");
-  fprintf (where, "  -c --cpuset    Show cpuset instead of objects\n");
-  fprintf (where, "  -t --threads   Show threads\n");
-  fprintf (where, "  --whole-system Do not consider administration limitations\n");
+  fprintf (where, "  -a               Show all processes, including those that are not bound\n");
+  fprintf (where, "  -l --logical     Use logical object indexes (default)\n");
+  fprintf (where, "  -p --physical    Use physical object indexes\n");
+  fprintf (where, "  -c --cpuset      Show cpuset instead of objects\n");
+  fprintf (where, "  -t --threads     Show threads\n");
+  fprintf (where, "  --pid-cmd <cmd>  Append the output of <cmd> <pid> to each PID line\n");
+  fprintf (where, "  --whole-system   Do not consider administration limitations\n");
 }
 
 static void print_task(hwloc_topology_t topology,
-		       long pid, const char *name, hwloc_bitmap_t cpuset,
+		       long pid_number, const char *name, hwloc_bitmap_t cpuset,
+		       char *pidoutput,
 		       int thread)
 {
-  printf("%s%ld\t", thread ? " " : "", pid);
+  printf("%s%ld\t", thread ? " " : "", pid_number);
 
   if (show_cpuset) {
     char *cpuset_str = NULL;
@@ -64,7 +68,7 @@
     hwloc_bitmap_free(remaining);
   }
 
-  printf("\t\t%s\n", name);
+  printf("\t\t%s%s%s\n", name, pidoutput ? "\t" : "", pidoutput ? pidoutput : "");
 }
 
 int main(int argc, char *argv[])
@@ -79,6 +83,7 @@
   int show_all = 0;
   int show_threads = 0;
   char *callname;
+  char *pidcmd = NULL;
   int err;
   int opt;
 
@@ -87,27 +92,37 @@
     callname = argv[0];
   else
     callname++;
+  /* skip argv[0], handle options */
+  argc--;
+  argv++;
 
-  while (argc >= 2) {
+  while (argc >= 1) {
     opt = 0;
-    if (!strcmp(argv[1], "-a"))
+    if (!strcmp(argv[0], "-a"))
       show_all = 1;
-    else if (!strcmp(argv[1], "-l") || !strcmp(argv[1], "--logical")) {
+    else if (!strcmp(argv[0], "-l") || !strcmp(argv[0], "--logical")) {
       logical = 1;
-    } else if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--physical")) {
+    } else if (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--physical")) {
       logical = 0;
-    } else if (!strcmp(argv[1], "-c") || !strcmp(argv[1], "--cpuset")) {
+    } else if (!strcmp(argv[0], "-c") || !strcmp(argv[0], "--cpuset")) {
       show_cpuset = 1;
-    } else if (!strcmp(argv[1], "-t") || !strcmp(argv[1], "--threads")) {
+    } else if (!strcmp(argv[0], "-t") || !strcmp(argv[0], "--threads")) {
 #ifdef HWLOC_LINUX_SYS
       show_threads = 1;
 #else
       fprintf (stderr, "Listing threads is currently only supported on Linux\n");
 #endif
-    } else if (!strcmp (argv[1], "--whole-system")) {
+    } else if (!strcmp (argv[0], "--whole-system")) {
       flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
+    } else if (!strcmp (argv[0], "--pid-cmd")) {
+      if (argc < 2) {
+	usage(callname, stdout);
+	exit(EXIT_FAILURE);
+      }
+      pidcmd = argv[1];
+      opt = 1;
     } else {
-      fprintf (stderr, "Unrecognized option: %s\n", argv[1]);
+      fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
       usage (callname, stderr);
       exit(EXIT_FAILURE);
     }
@@ -141,7 +156,9 @@
     goto out_with_dir;
 
   while ((dirent = readdir(dir))) {
-    long pid;
+    long pid_number;
+    hwloc_pid_t pid;
+    char pidoutput[1024];
     char *end;
     char name[64] = "";
     /* management of threads */
@@ -149,11 +166,13 @@
     long *tids = NULL; /* NULL if process is not threaded */
     hwloc_bitmap_t *tidcpusets = NULL;
 
-    pid = strtol(dirent->d_name, &end, 10);
+    pid_number = strtol(dirent->d_name, &end, 10);
     if (*end)
       /* Not a number */
       continue;
 
+    pid = hwloc_pid_from_number(pid_number, 0);
+
 #ifdef HWLOC_LINUX_SYS
     {
       unsigned pathlen = 6 + strlen(dirent->d_name) + 1 + 7 + 1;
@@ -249,12 +268,31 @@
     if (hwloc_bitmap_isequal(cpuset, topocpuset) && (!tids || !boundthreads) && !show_all)
       continue;
 
+    pidoutput[0] = '\0';
+    if (pidcmd) {
+      char *cmd;
+      FILE *file;
+      char *end;
+      cmd = malloc(strlen(pidcmd)+1+5+2+1);
+      sprintf(cmd, "%s %u", pidcmd, pid);
+      file = popen(cmd, "r");
+      if (file) {
+	if (fgets(pidoutput, sizeof(pidoutput), file)) {
+	  end = strchr(pidoutput, '\n');
+	  if (end)
+	    *end = '\0';
+	}
+	pclose(file);
+      }
+      free(cmd);
+    }
+
     /* print the process */
-    print_task(topology, pid, name, cpuset, 0);
+    print_task(topology, pid_number, name, cpuset, pidoutput[0] == '\0' ? NULL : pidoutput, 0);
     if (tids)
       /* print each tid we found (it's tidcpuset isn't NULL anymore) */
       for(i=0; tidcpusets[i] != NULL; i++) {
-	print_task(topology, tids[i], "", tidcpusets[i], 1);
+	print_task(topology, tids[i], "", tidcpusets[i], NULL, 1);
 	hwloc_bitmap_free(tidcpusets[i]);
       }
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc.7in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc.7in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/hwloc.7in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,5 +1,5 @@
 .\" -*- nroff -*-
-.\" Copyright © 2010 inria.  All rights reserved.
+.\" Copyright © 2010-2012 Inria.  All rights reserved.
 .\" Copyright © 2010 Université of Bordeaux
 .\" Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
 .\" See COPYING in top-level directory.
@@ -149,7 +149,7 @@
 xor'ed.
 .
 .PP
-"all" and "root" are a special location consisting in the entire
+"all" and "root" are special locations consisting in the entire
 current topology.
 .
 More complex operations may be performed by using
@@ -159,7 +159,7 @@
 .SS Hwloc Objects
 .
 .PP
-Objects can be any of the following strings
+Objects in tuples can be any of the following strings
 .
 (listed from "biggest" to "smallest"):
 .
@@ -178,6 +178,12 @@
 processors.
 .
 .TP
+.B cache
+A cache memory. If several kinds of caches exist in the system,
+a specific one may be identified by its level (e.g. \fBl1cache\fR)
+and optionally by its type (e.g. \fBl1icache\fR).
+.
+.TP
 .B core
 A single, physical processing unit which may still contain multiple
 logical processors, such as hardware threads.
@@ -196,6 +202,9 @@
 .B system
 type can be used when several machines form an overall single system image
 (SSI), such as Kerrighed.
+.PP
+I/O devices are not listed here since they are not identified using
+tuples as explained in \fBLocation Specification\fR.
 .
 .PP
 Finally, note that an object can be denoted by its numeric "depth" in

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-draw.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-draw.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-draw.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2010 inria.  All rights reserved.
- * Copyright © 2009-2011 Université Bordeaux 1
+ * Copyright © 2009-2012 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.
  */
@@ -251,7 +251,9 @@
     } else { \
       unsigned found = 0; \
       /* Try to find a fitting rectangle */ \
-      for (rows = floor(sqrt(numsubobjs)); rows >= ceil(pow(numsubobjs,0.33)) && rows > 1; rows--) { \
+      for (rows = (unsigned) floor(sqrt(numsubobjs)); \
+	   rows >= (unsigned) ceil(pow(numsubobjs,0.33)) && rows > 1; \
+	   rows--) { \
         columns = numsubobjs / rows; \
         if (columns > 1 && columns * rows == numsubobjs) { \
           found = 1; \
@@ -266,7 +268,7 @@
         float idealtotheight = (float) sqrt(area/RATIO); \
         float under_ratio, over_ratio; \
         /* approximation of number of rows */ \
-        rows = idealtotheight / obj_avgheight; \
+        rows = (unsigned) (idealtotheight / obj_avgheight); \
         columns = rows ? (numsubobjs + rows - 1) / rows : 1; \
         /* Ratio obtained by underestimation */ \
         under_ratio = (float) (columns * obj_avgwidth) / (rows * obj_avgheight); \
@@ -499,7 +501,10 @@
           speed = subobjs[i]->attr->bridge.upstream.pci.linkspeed;
         if (speed != 0.) {
           char text[4];
-          snprintf(text, sizeof(text), "%0.1f", subobjs[i]->attr->pcidev.linkspeed);
+          if (speed >= 10.)
+	    snprintf(text, sizeof(text), "%.0f", subobjs[i]->attr->pcidev.linkspeed);
+	  else
+	    snprintf(text, sizeof(text), "%0.1f", subobjs[i]->attr->pcidev.linkspeed);
           methods->text(output, 0, 0, 0, fontsize, depth-1, x + 2*gridsize + gridsize, y + totheight, text);
         }
       }
@@ -528,23 +533,14 @@
 
   RECURSE_RECT(level, &null_draw_methods, 0, gridsize);
 
-  if (hwloc_bitmap_isset(level->online_cpuset, level->os_index))
-    if (!hwloc_bitmap_isset(level->allowed_cpuset, level->os_index))
-      methods->box(output, FORBIDDEN_R_COLOR, FORBIDDEN_G_COLOR, FORBIDDEN_B_COLOR, depth, x, *retwidth, y, *retheight);
-    else {
-      hwloc_bitmap_t bind = hwloc_bitmap_alloc();
-      if (pid != (hwloc_pid_t) -1 && pid != 0)
-        hwloc_get_proc_cpubind(topology, pid, bind, 0);
-      else if (pid == 0)
-        hwloc_get_cpubind(topology, bind, 0);
-      if (bind && hwloc_bitmap_isset(bind, level->os_index))
-        methods->box(output, RUNNING_R_COLOR, RUNNING_G_COLOR, RUNNING_B_COLOR, depth, x, *retwidth, y, *retheight);
-      else
-        methods->box(output, THREAD_R_COLOR, THREAD_G_COLOR, THREAD_B_COLOR, depth, x, *retwidth, y, *retheight);
-      hwloc_bitmap_free(bind);
-    }
-  else
+  if (lstopo_pu_offline(level))
     methods->box(output, OFFLINE_R_COLOR, OFFLINE_G_COLOR, OFFLINE_B_COLOR, depth, x, *retwidth, y, *retheight);
+  else if (lstopo_pu_forbidden(level))
+    methods->box(output, FORBIDDEN_R_COLOR, FORBIDDEN_G_COLOR, FORBIDDEN_B_COLOR, depth, x, *retwidth, y, *retheight);
+  else if (lstopo_pu_running(topology, level))
+    methods->box(output, RUNNING_R_COLOR, RUNNING_G_COLOR, RUNNING_B_COLOR, depth, x, *retwidth, y, *retheight);
+  else
+    methods->box(output, THREAD_R_COLOR, THREAD_G_COLOR, THREAD_B_COLOR, depth, x, *retwidth, y, *retheight);
 
   if (fontsize) {
     char text[64];

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-text.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-text.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo-text.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -46,7 +46,7 @@
  */
 
 static void
-output_console_obj (hwloc_obj_t l, FILE *output, int logical, int verbose_mode)
+output_console_obj (hwloc_topology_t topology, hwloc_obj_t l, FILE *output, int logical, int verbose_mode)
 {
   char type[32], *attr, phys[32] = "";
   unsigned idx = logical ? l->logical_index : l->os_index;
@@ -92,6 +92,16 @@
     fprintf(output, "%s", cpusetstr);
     free(cpusetstr);
   }
+
+  /* annotate if the PU is forbidden/offline/running */
+  if (l->type == HWLOC_OBJ_PU && verbose_mode >= 2) {
+    if (lstopo_pu_offline(l))
+      printf(" (offline)");
+    else if (lstopo_pu_forbidden(l))
+      printf(" (forbidden)");
+    else if (lstopo_pu_running(topology, l))
+      printf(" (running)");
+  }
 }
 
 /* Recursively output topology in a console fashion */
@@ -111,7 +121,7 @@
     indent (output, 2*i);
     i++;
   }
-  output_console_obj(l, output, logical, verbose_mode);
+  output_console_obj(topology, l, output, logical, verbose_mode);
   if (l->arity || (!i && !l->arity))
     {
       for (x=0; x<l->arity; x++)
@@ -125,7 +135,7 @@
 {
   unsigned x;
   if (show_only == l->type) {
-    output_console_obj (l, output, logical, verbose_mode);
+    output_console_obj (topology, l, output, logical, verbose_mode);
     fprintf (output, "\n");
   }
   for (x=0; x<l->arity; x++)
@@ -164,7 +174,7 @@
     fprintf(output, "\n");
   }
 
-  if (verbose_mode > 1 || !verbose_mode) {
+  if ((verbose_mode > 1 || !verbose_mode) && show_only == (hwloc_obj_type_t)-1) {
     unsigned depth, nbobjs;
     for (depth = 0; depth < topodepth; depth++) {
       hwloc_obj_t obj = hwloc_get_obj_by_depth(topology, depth, 0);
@@ -189,7 +199,7 @@
 	       HWLOC_TYPE_DEPTH_OS_DEVICE, nbobjs, "OS Device", HWLOC_OBJ_OS_DEVICE);
   }
 
-  if (verbose_mode > 1) {
+  if (verbose_mode > 1 && show_only == (hwloc_obj_type_t)-1) {
     const struct hwloc_distances_s * distances;
     unsigned depth;
 
@@ -205,7 +215,7 @@
     }
   }
 
-  if (verbose_mode > 1) {
+  if (verbose_mode > 1 && show_only == (hwloc_obj_type_t)-1) {
     hwloc_const_bitmap_t complete = hwloc_topology_get_complete_cpuset(topology);
     hwloc_const_bitmap_t topo = hwloc_topology_get_topology_cpuset(topology);
     hwloc_const_bitmap_t online = hwloc_topology_get_online_cpuset(topology);
@@ -278,7 +288,8 @@
   }
 
   if (!obj->symmetric_subtree) {
-    fprintf(stderr, "Cannot output assymetric topology in synthetic format\n");
+    fprintf(stderr, "Cannot output assymetric topology in synthetic format.\n");
+    fprintf(stderr, "Adding --no-io may help making the topology symmetric.\n");
     return;
   }
 

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.1in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.1in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.1in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -137,8 +137,9 @@
 Detect topology as seen by process <pid>, i.e. as if process <pid> did the
 discovery itself.
 Note that this can for instance change the set of allowed processors.
-Also show this process current CPU binding in the graphical output
-(in Green, see the COLORS section below).
+Also show this process current CPU binding by marking the corresponding
+PUs (in Green in the graphical output, see the COLORS section below,
+or by appending \fI(binding)\fR to the verbose text output).
 If 0 is given as pid, the current binding for the lstopo process will be shown.
 .TP
 \fB\-\-ps\fR \fB\-\-top\fR
@@ -219,8 +220,8 @@
 .TP
 .B console
 Send a text summary to stdout.
-No color annotation for binding, unallowed or offline processors
-is shown in this mode; see the COLORS section, below.
+Binding, unallowed or offline processors are only annotated in this mode
+if verbose; see the COLORS section, below.
 .
 .TP
 .B txt
@@ -254,9 +255,14 @@
 .
 .TP
 .B synthetic
-If the topology is symmetric, lstopo outputs a synthetic description
-string. This output may be reused as an input synthetic topology
+If the topology is symmetric
+(which requires that the root object has its symmetric_subtree field set),
+lstopo outputs a synthetic description string.
+This output may be reused as an input synthetic topology
 description later.
+Note that I/O devices often cause topology asymmetry.
+Adding \-\-no\-io may then be useful when the synthetic export fails.
+See also the Synthetic topologies section in the documentation.
 .
 .TP
 .B xml
@@ -324,7 +330,8 @@
 .PP
 Some lstopo output modes, e.g. the console mode (default non-graphical output),
 do not support colors at all.
-The above characteristics are not shown in this case.
+The console mode displays the above characteristics by appending text
+to each PU line if verbose messages are enabled.
 .
 .\" **************************
 .\"    Layout Section

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.c	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.c	2012-12-10 03:23:44 UTC (rev 10739)
@@ -43,7 +43,8 @@
 enum lstopo_orient_e force_orient[HWLOC_OBJ_TYPE_MAX];
 unsigned int legend = 1;
 unsigned int top = 0;
-hwloc_pid_t pid = (hwloc_pid_t) -1;
+int pid_number = -1;
+hwloc_pid_t pid;
 
 FILE *open_file(const char *filename, const char *mode)
 {
@@ -114,18 +115,21 @@
 #endif /* HWLOC_LINUX_SYS */
 
   while ((dirent = readdir(dir))) {
-    long local_pid;
+    long local_pid_number;
+    hwloc_pid_t local_pid;
     char *end;
     char name[64];
     int proc_cpubind;
 
-    local_pid = strtol(dirent->d_name, &end, 10);
+    local_pid_number = strtol(dirent->d_name, &end, 10);
     if (*end)
       /* Not a number */
       continue;
 
-    snprintf(name, sizeof(name), "%ld", local_pid);
+    snprintf(name, sizeof(name), "%ld", local_pid_number);
 
+    local_pid = hwloc_pid_from_number(local_pid_number, 0);
+
     proc_cpubind = hwloc_get_proc_cpubind(topology, local_pid, cpuset, 0) != -1;
 
 #ifdef HWLOC_LINUX_SYS
@@ -153,7 +157,7 @@
         cmd[n] = 0;
         if ((c = strchr(cmd, ' ')))
           *c = 0;
-        snprintf(name, sizeof(name), "%ld %s", local_pid, cmd);
+        snprintf(name, sizeof(name), "%ld %s", local_pid_number, cmd);
       }
     }
 
@@ -361,86 +365,89 @@
     callname = argv[0];
   else
     callname++;
+  /* skip argv[0], handle options */
+  argc--;
+  argv++;
 
   err = hwloc_topology_init (&topology);
   if (err)
     return EXIT_FAILURE;
 
-  while (argc >= 2)
+  while (argc >= 1)
     {
       opt = 0;
-      if (!strcmp (argv[1], "-v") || !strcmp (argv[1], "--verbose")) {
+      if (!strcmp (argv[0], "-v") || !strcmp (argv[0], "--verbose")) {
 	verbose_mode++;
-      } else if (!strcmp (argv[1], "-s") || !strcmp (argv[1], "--silent")) {
+      } else if (!strcmp (argv[0], "-s") || !strcmp (argv[0], "--silent")) {
 	verbose_mode--;
-      } else if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
+      } else if (!strcmp (argv[0], "-h") || !strcmp (argv[0], "--help")) {
 	usage(callname, stdout);
         exit(EXIT_SUCCESS);
-      } else if (!strcmp (argv[1], "-l") || !strcmp (argv[1], "--logical"))
+      } else if (!strcmp (argv[0], "-l") || !strcmp (argv[0], "--logical"))
 	logical = 1;
-      else if (!strcmp (argv[1], "-p") || !strcmp (argv[1], "--physical"))
+      else if (!strcmp (argv[0], "-p") || !strcmp (argv[0], "--physical"))
 	logical = 0;
-      else if (!strcmp (argv[1], "-c") || !strcmp (argv[1], "--cpuset"))
+      else if (!strcmp (argv[0], "-c") || !strcmp (argv[0], "--cpuset"))
 	show_cpuset = 1;
-      else if (!strcmp (argv[1], "-C") || !strcmp (argv[1], "--cpuset-only"))
+      else if (!strcmp (argv[0], "-C") || !strcmp (argv[0], "--cpuset-only"))
 	show_cpuset = 2;
-      else if (!strcmp (argv[1], "--taskset")) {
+      else if (!strcmp (argv[0], "--taskset")) {
 	taskset = 1;
 	if (!show_cpuset)
 	  show_cpuset = 1;
-      } else if (!strcmp (argv[1], "--only")) {
-	if (argc <= 2) {
+      } else if (!strcmp (argv[0], "--only")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-        show_only = hwloc_obj_type_of_string(argv[2]);
+        show_only = hwloc_obj_type_of_string(argv[1]);
 	opt = 1;
       }
-      else if (!strcmp (argv[1], "--ignore")) {
-	if (argc <= 2) {
+      else if (!strcmp (argv[0], "--ignore")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-        hwloc_topology_ignore_type(topology, hwloc_obj_type_of_string(argv[2]));
+        hwloc_topology_ignore_type(topology, hwloc_obj_type_of_string(argv[1]));
 	opt = 1;
       }
-      else if (!strcmp (argv[1], "--no-caches"))
+      else if (!strcmp (argv[0], "--no-caches"))
 	ignorecache = 2;
-      else if (!strcmp (argv[1], "--no-useless-caches"))
+      else if (!strcmp (argv[0], "--no-useless-caches"))
 	ignorecache = 1;
-      else if (!strcmp (argv[1], "--no-icaches"))
+      else if (!strcmp (argv[0], "--no-icaches"))
 	flags &= ~HWLOC_TOPOLOGY_FLAG_ICACHES;
-      else if (!strcmp (argv[1], "--whole-system"))
+      else if (!strcmp (argv[0], "--whole-system"))
 	flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
-      else if (!strcmp (argv[1], "--no-io"))
+      else if (!strcmp (argv[0], "--no-io"))
 	flags &= ~(HWLOC_TOPOLOGY_FLAG_IO_DEVICES | HWLOC_TOPOLOGY_FLAG_IO_BRIDGES);
-      else if (!strcmp (argv[1], "--no-bridges"))
+      else if (!strcmp (argv[0], "--no-bridges"))
 	flags &= ~(HWLOC_TOPOLOGY_FLAG_IO_BRIDGES);
-      else if (!strcmp (argv[1], "--whole-io"))
+      else if (!strcmp (argv[0], "--whole-io"))
 	flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_IO;
-      else if (!strcmp (argv[1], "--merge"))
+      else if (!strcmp (argv[0], "--merge"))
 	merge = 1;
-      else if (!strcmp (argv[1], "--thissystem"))
+      else if (!strcmp (argv[0], "--thissystem"))
 	flags |= HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM;
-      else if (!strcmp (argv[1], "--restrict")) {
-	if (argc <= 2) {
+      else if (!strcmp (argv[0], "--restrict")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-	restrictstring = strdup(argv[2]);
+	restrictstring = strdup(argv[1]);
 	opt = 1;
       }
 
-      else if (!strcmp (argv[1], "--horiz"))
+      else if (!strcmp (argv[0], "--horiz"))
 	for(i=0; i<HWLOC_OBJ_TYPE_MAX; i++)
 	  force_orient[i] = LSTOPO_ORIENT_HORIZ;
-      else if (!strcmp (argv[1], "--vert"))
+      else if (!strcmp (argv[0], "--vert"))
 	for(i=0; i<HWLOC_OBJ_TYPE_MAX; i++)
 	  force_orient[i] = LSTOPO_ORIENT_VERT;
-      else if (!strncmp (argv[1], "--horiz=", 8)
-	       || !strncmp (argv[1], "--vert=", 7)) {
-	enum lstopo_orient_e orient = (argv[1][2] == 'h') ? LSTOPO_ORIENT_HORIZ : LSTOPO_ORIENT_VERT;
-	char *tmp = argv[1] + ((argv[1][2] == 'h') ? 8 : 7);
+      else if (!strncmp (argv[0], "--horiz=", 8)
+	       || !strncmp (argv[0], "--vert=", 7)) {
+	enum lstopo_orient_e orient = (argv[0][2] == 'h') ? LSTOPO_ORIENT_HORIZ : LSTOPO_ORIENT_VERT;
+	char *tmp = argv[0] + ((argv[0][2] == 'h') ? 8 : 7);
 	while (tmp) {
 	  char *end = strchr(tmp, ',');
 	  hwloc_obj_type_t type;
@@ -455,56 +462,56 @@
         }
       }
 
-      else if (!strcmp (argv[1], "--fontsize")) {
-	if (argc <= 2) {
+      else if (!strcmp (argv[0], "--fontsize")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-	fontsize = atoi(argv[2]);
+	fontsize = atoi(argv[1]);
 	opt = 1;
       }
-      else if (!strcmp (argv[1], "--gridsize")) {
-	if (argc <= 2) {
+      else if (!strcmp (argv[0], "--gridsize")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-	gridsize = atoi(argv[2]);
+	gridsize = atoi(argv[1]);
 	opt = 1;
       }
-      else if (!strcmp (argv[1], "--no-legend")) {
+      else if (!strcmp (argv[0], "--no-legend")) {
 	legend = 0;
       }
 
-      else if (hwloc_utils_lookup_input_option(argv+1, argc-1, &opt,
+      else if (hwloc_utils_lookup_input_option(argv, argc, &opt,
 					       &input, &input_format,
 					       callname)) {
 	/* nothing to do anymore */
 
-      } else if (!strcmp (argv[1], "--pid")) {
-	if (argc <= 2) {
+      } else if (!strcmp (argv[0], "--pid")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-	pid = atoi(argv[2]); opt = 1;
-      } else if (!strcmp (argv[1], "--ps") || !strcmp (argv[1], "--top"))
+	pid_number = atoi(argv[1]); opt = 1;
+      } else if (!strcmp (argv[0], "--ps") || !strcmp (argv[0], "--top"))
         top = 1;
-      else if (!strcmp (argv[1], "--version")) {
+      else if (!strcmp (argv[0], "--version")) {
           printf("%s %s\n", callname, VERSION);
           exit(EXIT_SUCCESS);
-      } else if (!strcmp (argv[1], "--output-format") || !strcmp (argv[1], "--of")) {
-	if (argc <= 2) {
+      } else if (!strcmp (argv[0], "--output-format") || !strcmp (argv[0], "--of")) {
+	if (argc < 2) {
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	}
-        output_format = parse_output_format(argv[2], callname);
+        output_format = parse_output_format(argv[1], callname);
         opt = 1;
       } else {
 	if (filename) {
-	  fprintf (stderr, "Unrecognized option: %s\n", argv[1]);
+	  fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
 	  usage (callname, stderr);
 	  exit(EXIT_FAILURE);
 	} else
-	  filename = argv[1];
+	  filename = argv[0];
       }
       argc -= opt+1;
       argv += opt+1;
@@ -529,7 +536,8 @@
       return err;
   }
 
-  if (pid != (hwloc_pid_t) -1 && pid != 0) {
+  if (pid_number != -1 && pid_number != 0) {
+    pid = hwloc_pid_from_number(pid_number, 0);
     if (hwloc_topology_set_pid(topology, pid)) {
       perror("Setting target pid");
       return EXIT_FAILURE;
@@ -546,7 +554,7 @@
   if (restrictstring) {
     hwloc_bitmap_t restrictset = hwloc_bitmap_alloc();
     if (!strcmp (restrictstring, "binding")) {
-      if (pid != (hwloc_pid_t) -1 && pid != 0)
+      if (pid_number != -1 && pid_number != 0)
 	hwloc_get_proc_cpubind(topology, pid, restrictset, HWLOC_CPUBIND_PROCESS);
       else
 	hwloc_get_cpubind(topology, restrictset, HWLOC_CPUBIND_PROCESS);

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/lstopo.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2009 CNRS
  * Copyright © 2009-2010 inria.  All rights reserved.
- * Copyright © 2009-2010 Université Bordeaux 1
+ * Copyright © 2009-2010, 2012 Université Bordeaux 1
  * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
  * See COPYING in top-level directory.
  */
@@ -14,6 +14,7 @@
 extern hwloc_obj_type_t show_only;
 extern int show_cpuset;
 extern int taskset;
+extern int pid_number;
 extern hwloc_pid_t pid;
 
 typedef void output_method (struct hwloc_topology *topology, const char *output, int logical, int legend, int verbose_mode);
@@ -46,4 +47,28 @@
 int rgb_to_color(int r, int g, int b) __hwloc_attribute_const;
 int declare_color(int r, int g, int b);
 
+static __hwloc_inline int lstopo_pu_offline(hwloc_obj_t l)
+{
+  return !hwloc_bitmap_isset(l->online_cpuset, l->os_index);
+}
+
+static __hwloc_inline int lstopo_pu_forbidden(hwloc_obj_t l)
+{
+  return !hwloc_bitmap_isset(l->allowed_cpuset, l->os_index);
+}
+
+static __hwloc_inline int lstopo_pu_running(hwloc_topology_t topology, hwloc_obj_t l)
+{
+  hwloc_bitmap_t bind = hwloc_bitmap_alloc();
+  int res;
+  if (pid_number != -1 && pid_number != 0)
+    hwloc_get_proc_cpubind(topology, pid, bind, 0);
+  else if (pid_number == 0)
+    hwloc_get_cpubind(topology, bind, 0);
+  res = bind && hwloc_bitmap_isset(bind, l->os_index);
+  hwloc_bitmap_free(bind);
+  return res;
+}
+
+
 #endif /* UTILS_LSTOPO_H */

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/misc.h
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/misc.h	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/misc.h	2012-12-10 03:23:44 UTC (rev 10739)
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2009 CNRS
- * Copyright © 2009-2010 inria.  All rights reserved.
+ * Copyright © 2009-2012 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.
@@ -144,20 +144,21 @@
     int err;
     err = stat(input, &inputst);
     if (err < 0) {
-      if (verbose)
+      if (verbose > 0)
 	printf("assuming `%s' is a synthetic topology description\n", input);
       input_format = HWLOC_UTILS_INPUT_SYNTHETIC;
     } else if (S_ISDIR(inputst.st_mode)) {
-      if (verbose)
+      if (verbose > 0)
 	printf("assuming `%s' is a file-system root\n", input);
       input_format = HWLOC_UTILS_INPUT_FSROOT;
     } else if (S_ISREG(inputst.st_mode)) {
-      if (verbose)
+      if (verbose > 0)
 	printf("assuming `%s' is a XML file\n", input);
       input_format = HWLOC_UTILS_INPUT_XML;
     } else {
       fprintf (stderr, "Unrecognized input file: %s\n", input);
       usage (callname, stderr);
+      return EXIT_FAILURE;
     }
   }
 
@@ -229,3 +230,22 @@
   }
 }
 
+static __hwloc_inline hwloc_pid_t
+hwloc_pid_from_number(int pid_number, int set_info __hwloc_attribute_unused)
+{
+  hwloc_pid_t pid;
+#ifdef HWLOC_WIN_SYS
+  pid = OpenProcess(set_info ? PROCESS_SET_INFORMATION : PROCESS_QUERY_INFORMATION, FALSE, pid_number);
+  if (!pid) {
+    DWORD error = GetLastError();
+    char *message;
+    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+                  NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char *)&message, 0, NULL);
+    fprintf(stderr, "OpenProcess %d failed %ld: %s\n", pid_number, error, message);
+    exit(EXIT_FAILURE);
+  }
+#else
+  pid = pid_number;
+#endif
+  return pid;
+}

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-fake-plugin.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-fake-plugin.sh.in	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-fake-plugin.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,37 @@
+#!/bin/sh
+#-*-sh-*-
+
+#
+# Copyright © 2009-2012 Inria.  All rights reserved.
+# Copyright © 2009, 2011 Université Bordeaux 1
+# See COPYING in top-level directory.
+#
+
+abs_top_builddir="@abs_top_builddir@"
+lstopo="$abs_top_builddir/utils/lstopo-no-graphics"
+
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
+HWLOC_DEBUG_FAKE_COMPONENT=1
+export HWLOC_DEBUG_FAKE_COMPONENT
+
+: ${TMPDIR=/tmp}
+{
+  tmp=`
+    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
+  ` &&
+  test -n "$tmp" && test -d "$tmp"
+} || {
+  tmp=$TMPDIR/foo$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || exit $?
+file="$tmp/test-fake-plugin.output"
+
+set -e
+
+$lstopo > $file
+
+grep "fake component instantiated" $file
+
+rm -rf "$tmp"


Property changes on: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-fake-plugin.sh.in
___________________________________________________________________
Added: svn:executable
   + *

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.input
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.input	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.input	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE topology SYSTEM "hwloc.dtd">
+<topology>
+  <object type="Machine" os_index="0" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f" local_memory="4014030848">
+    <page_type size="4096" count="979988"/>
+    <page_type size="2097152" count="0"/>
+    <info name="DMIProductName" value="Latitude E6410"/>
+    <info name="DMIProductVersion" value="0001"/>
+    <info name="DMIBoardVendor" value="Dell Inc."/>
+    <info name="DMIBoardName" value=" "/>
+    <info name="DMIBoardVersion" value=" "/>
+    <info name="DMIBoardAssetTag" value=" "/>
+    <info name="DMIChassisVendor" value="Dell Inc."/>
+    <info name="DMIChassisType" value="9"/>
+    <info name="DMIChassisVersion" value=" "/>
+    <info name="DMIChassisAssetTag" value=""/>
+    <info name="DMIBIOSVendor" value="Dell Inc."/>
+    <info name="DMIBIOSVersion" value="A12"/>
+    <info name="DMIBIOSDate" value="05/09/2012"/>
+    <info name="DMISysVendor" value="Dell Inc."/>
+    <info name="Backend" value="Linux"/>
+    <info name="OSName" value="Linux"/>
+    <info name="OSRelease" value="3.2.0-3-amd64"/>
+    <info name="OSVersion" value="#1 SMP Thu Jun 28 09:07:26 UTC 2012"/>
+    <info name="HostName" value="rhododendron"/>
+    <info name="Architecture" value="x86_64"/>
+    <object type="Socket" os_index="0" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f">
+      <info name="CPUModel" value="Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz"/>
+      <info name="CPUType" value="x86_64"/>
+      <object type="Cache" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f" cache_size="4194304" depth="3" cache_linesize="64" cache_associativity="16" cache_type="0">
+        <object type="Cache" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005" cache_size="262144" depth="2" cache_linesize="64" cache_associativity="8" cache_type="0">
+          <object type="Cache" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="8" cache_type="1">
+            <object type="Cache" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="4" cache_type="2">
+              <object type="Core" os_index="0" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005">
+                <object type="PU" os_index="0" cpuset="0x00000001" complete_cpuset="0x00000001" online_cpuset="0x00000001" allowed_cpuset="0x00000001"/>
+                <object type="PU" os_index="2" cpuset="0x00000004" complete_cpuset="0x00000004" online_cpuset="0x00000004" allowed_cpuset="0x00000004"/>
+              </object>
+            </object>
+          </object>
+        </object>
+        <object type="Cache" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a" cache_size="262144" depth="2" cache_linesize="64" cache_associativity="8" cache_type="0">
+          <object type="Cache" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="8" cache_type="1">
+            <object type="Cache" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="4" cache_type="2">
+              <object type="Core" os_index="2" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a">
+                <object type="PU" os_index="1" cpuset="0x00000002" complete_cpuset="0x00000002" online_cpuset="0x00000002" allowed_cpuset="0x00000002"/>
+                <object type="PU" os_index="3" cpuset="0x00000008" complete_cpuset="0x00000008" online_cpuset="0x00000008" allowed_cpuset="0x00000008"/>
+              </object>
+            </object>
+          </object>
+        </object>
+      </object>
+    </object>
+    <object type="Bridge" os_index="0" bridge_type="0-1" depth="0" bridge_pci="0000:[00-05]">
+      <object type="PCIDev" os_index="32" name="Intel Corporation Core Processor Integrated Graphics Controller" pci_busid="0000:00:02.0" pci_type="0300 [8086:0046] [0028:000a] 02" pci_link_speed="0.000000">
+        <info name="PCIVendor" value="Intel Corporation"/>
+        <info name="PCIDevice" value="Core Processor Integrated Graphics Controller"/>
+        <object type="OSDev" name="controlD64" osdev_type="1"/>
+        <object type="OSDev" name="card0" osdev_type="1"/>
+      </object>
+      <object type="PCIDev" os_index="400" name="Intel Corporation 82577LM Gigabit Network Connection" pci_busid="0000:00:19.0" pci_type="0200 [8086:10ea] [0028:000a] 05" pci_link_speed="0.000000">
+        <info name="PCIVendor" value="Intel Corporation"/>
+        <info name="PCIDevice" value="82577LM Gigabit Network Connection"/>
+        <object type="OSDev" name="eth0" osdev_type="2">
+          <info name="Address" value="5c:26:0a:53:da:8c"/>
+        </object>
+      </object>
+      <object type="Bridge" os_index="449" name="Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 2" bridge_type="1-1" depth="1" bridge_pci="0000:[02-02]" pci_busid="0000:00:1c.1" pci_type="0604 [8086:3b44] [0000:0000] 05" pci_link_speed="0.000000">
+        <info name="PCIVendor" value="Intel Corporation"/>
+        <info name="PCIDevice" value="5 Series/3400 Series Chipset PCI Express Root Port 2"/>
+        <object type="PCIDev" os_index="8192" name="Intel Corporation Centrino Ultimate-N 6300" pci_busid="0000:02:00.0" pci_type="0280 [8086:422b] [0086:0021] 35" pci_link_speed="0.000000">
+          <info name="PCIVendor" value="Intel Corporation"/>
+          <info name="PCIDevice" value="Centrino Ultimate-N 6300"/>
+          <object type="OSDev" name="wlan0" osdev_type="2">
+            <info name="Address" value="00:24:d7:0f:bd:34"/>
+          </object>
+        </object>
+      </object>
+      <object type="PCIDev" os_index="498" name="Intel Corporation 5 Series/3400 Series Chipset 6 port SATA AHCI Controller" pci_busid="0000:00:1f.2" pci_type="0106 [8086:3b2f] [0028:000a] 05" pci_link_speed="0.000000">
+        <info name="PCIVendor" value="Intel Corporation"/>
+        <info name="PCIDevice" value="5 Series/3400 Series Chipset 6 port SATA AHCI Controller"/>
+        <object type="OSDev" name="sda" osdev_type="0"/>
+        <object type="OSDev" name="sr0" osdev_type="0"/>
+      </object>
+    </object>
+  </object>
+</topology>

Added: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.output
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.output	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.output	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE topology SYSTEM "hwloc.dtd">
+<topology>
+  <object type="Machine" os_index="0" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f" local_memory="4014030848">
+    <page_type size="4096" count="979988"/>
+    <page_type size="2097152" count="0"/>
+    <info name="DMIProductName" value="Latitude E6410"/>
+    <info name="DMIProductVersion" value="0001"/>
+    <info name="DMIBoardVendor" value="Dell Inc."/>
+    <info name="DMIBoardName" value=" "/>
+    <info name="DMIBoardVersion" value=" "/>
+    <info name="DMIBoardAssetTag" value=" "/>
+    <info name="DMIChassisVendor" value="Dell Inc."/>
+    <info name="DMIChassisType" value="9"/>
+    <info name="DMIChassisVersion" value=" "/>
+    <info name="DMIChassisAssetTag" value=""/>
+    <info name="DMIBIOSVendor" value="Dell Inc."/>
+    <info name="DMIBIOSVersion" value="A12"/>
+    <info name="DMIBIOSDate" value="05/09/2012"/>
+    <info name="DMISysVendor" value="Dell Inc."/>
+    <info name="Backend" value="Linux"/>
+    <info name="OSName" value="Linux"/>
+    <info name="OSRelease" value="3.2.0-3-amd64"/>
+    <info name="OSVersion" value="#1 SMP Thu Jun 28 09:07:26 UTC 2012"/>
+    <info name="HostName" value="rhododendron"/>
+    <info name="Architecture" value="x86_64"/>
+    <info name="Foo" value="Bar"/>
+    <object type="Socket" os_index="0" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f">
+      <info name="CPUModel" value="Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz"/>
+      <info name="CPUType" value="x86_64"/>
+      <info name="Foo" value="Bar"/>
+      <object type="Cache" cpuset="0x0000000f" complete_cpuset="0x0000000f" online_cpuset="0x0000000f" allowed_cpuset="0x0000000f" cache_size="4194304" depth="3" cache_linesize="64" cache_associativity="16" cache_type="0">
+        <info name="Foo" value="Bar"/>
+        <object type="Cache" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005" cache_size="262144" depth="2" cache_linesize="64" cache_associativity="8" cache_type="0">
+          <object type="Cache" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="8" cache_type="1">
+            <info name="Foo" value="Bar"/>
+            <object type="Core" os_index="0" cpuset="0x00000005" complete_cpuset="0x00000005" online_cpuset="0x00000005" allowed_cpuset="0x00000005">
+              <info name="Foo2" value="Bar2"/>
+              <object type="PU" os_index="0" cpuset="0x00000001" complete_cpuset="0x00000001" online_cpuset="0x00000001" allowed_cpuset="0x00000001">
+                <info name="Foo" value="Bar"/>
+              </object>
+              <object type="PU" os_index="2" cpuset="0x00000004" complete_cpuset="0x00000004" online_cpuset="0x00000004" allowed_cpuset="0x00000004">
+                <info name="Foo" value="Bar"/>
+              </object>
+            </object>
+          </object>
+        </object>
+        <object type="Cache" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a" cache_size="262144" depth="2" cache_linesize="64" cache_associativity="8" cache_type="0">
+          <info name="Foo" value="Bar"/>
+          <object type="Cache" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a" cache_size="32768" depth="1" cache_linesize="64" cache_associativity="8" cache_type="1">
+            <info name="Foo" value="Bar"/>
+            <object type="Core" os_index="2" cpuset="0x0000000a" complete_cpuset="0x0000000a" online_cpuset="0x0000000a" allowed_cpuset="0x0000000a">
+              <info name="Foo2" value="Bar2"/>
+              <object type="PU" os_index="1" cpuset="0x00000002" complete_cpuset="0x00000002" online_cpuset="0x00000002" allowed_cpuset="0x00000002">
+                <info name="Foo" value="Bar"/>
+              </object>
+              <object type="PU" os_index="3" cpuset="0x00000008" complete_cpuset="0x00000008" online_cpuset="0x00000008" allowed_cpuset="0x00000008">
+                <info name="Foo" value="Bar"/>
+              </object>
+            </object>
+          </object>
+        </object>
+      </object>
+    </object>
+  </object>
+</topology>

Copied: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.sh.in (from rev 10732, mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-assembler.sh.in)
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.sh.in	                        (rev 0)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-annotate.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -0,0 +1,42 @@
+#!/bin/sh
+#-*-sh-*-
+
+#
+# Copyright © 2009-2012 Inria.  All rights reserved.
+# See COPYING in top-level directory.
+#
+
+abs_top_builddir="@abs_top_builddir@"
+annotate="$abs_top_builddir/utils/hwloc-annotate"
+abs_top_srcdir="@abs_top_srcdir@"
+
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
+if test x at HWLOC_XML_LOCALIZED@ = x1; then
+  # make sure we use default numeric formats
+  LANG=C
+  LC_ALL=C
+  export LANG LC_ALL
+fi
+
+: ${TMPDIR=/tmp}
+{
+  tmp=`
+    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
+  ` &&
+  test -n "$tmp" && test -d "$tmp"
+} || {
+  tmp=$TMPDIR/foo$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || exit $?
+file="$tmp/test-hwloc-annotate.output"
+
+set -e
+
+$annotate $abs_top_srcdir/utils/test-hwloc-annotate.input $file all info Foo Bar
+$annotate --ci $file $file Core:all info Foo2 Bar2
+$annotate --ci $file $file L2Cache:0 none
+
+diff @HWLOC_DIFF_U@ $abs_top_srcdir/utils/test-hwloc-annotate.output "$file"
+rm -rf "$tmp"

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-assembler.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-assembler.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-assembler.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -2,7 +2,7 @@
 #-*-sh-*-
 
 #
-# Copyright © 2009-2011 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009, 2011 Université Bordeaux 1
 # See COPYING in top-level directory.
 #
@@ -11,6 +11,9 @@
 assembler="$abs_top_builddir/utils/hwloc-assembler"
 abs_top_srcdir="@abs_top_srcdir@"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 if test x at HWLOC_XML_LOCALIZED@ = x1; then
   # make sure we use default numeric formats
   LANG=C

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-calc.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-calc.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-calc.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -3,7 +3,7 @@
 
 #
 # Copyright © 2009 CNRS
-# Copyright © 2009-2011 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009, 2011 Université Bordeaux 1
 # See COPYING in top-level directory.
 #
@@ -12,6 +12,9 @@
 calc="$abs_top_builddir/utils/hwloc-calc"
 abs_top_srcdir="@abs_top_srcdir@"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 : ${TMPDIR=/tmp}
 {
   tmp=`

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distances.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distances.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distances.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -2,7 +2,7 @@
 #-*-sh-*-
 
 #
-# Copyright © 2011 inria.  All rights reserved.
+# Copyright © 2012 Inria.  All rights reserved.
 # See COPYING in top-level directory.
 #
 
@@ -10,6 +10,9 @@
 distances="$abs_top_builddir/utils/hwloc-distances"
 abs_top_srcdir="@abs_top_srcdir@"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 # make sure we use default numeric formats
 LANG=C
 LC_ALL=C

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distrib.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distrib.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-distrib.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -3,7 +3,7 @@
 
 #
 # Copyright © 2009 CNRS
-# Copyright © 2009-2010 inria.  All rights reserved.
+# Copyright © 2009-2012 Inria.  All rights reserved.
 # Copyright © 2009 Université Bordeaux 1
 # See COPYING in top-level directory.
 #
@@ -12,6 +12,9 @@
 distrib="$abs_top_builddir/utils/hwloc-distrib"
 abs_top_srcdir="@abs_top_srcdir@"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 : ${TMPDIR=/tmp}
 {
   tmp=`

Modified: mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-ls.sh.in
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-ls.sh.in	2012-12-10 01:23:47 UTC (rev 10738)
+++ mpich2/trunk/src/pm/hydra/tools/topo/hwloc/hwloc/utils/test-hwloc-ls.sh.in	2012-12-10 03:23:44 UTC (rev 10739)
@@ -12,6 +12,9 @@
 ls="$abs_top_builddir/utils/lstopo-no-graphics"
 abs_top_srcdir="@abs_top_srcdir@"
 
+HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
+export HWLOC_PLUGINS_PATH
+
 : ${TMPDIR=/tmp}
 {
   tmp=`



More information about the commits mailing list