Skip to content

Commit 91ca50b

Browse files
Add sub-RFC for increased availability of NUMA API (#1545)
1 parent bf798c8 commit 91ca50b

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# -*- fill-column: 80; -*-
2+
3+
#+title: Link ~tbbbind~ with Static HWLOC for NUMA API predictability
4+
5+
*Note:* This document is a sub-RFC of the [[file:README.md][umbrella RFC about improving NUMA
6+
support]]. Specifically, the "Increased availability of NUMA support" section.
7+
8+
* Introduction
9+
oneTBB has a soft dependency on several variants of ~tbbbind~, which the library
10+
loads during the initialization stage. Each ~tbbbind~, in turn, has a hard
11+
dependency on a specific version of the HWLOC library [1, 2]. The soft
12+
dependency means that the library continues the execution even if the system
13+
loader fails to resolve the hard dependency on HWLOC for ~tbbbind~. In this
14+
case, oneTBB does not discover the hardware topology. Instead, it defaults to
15+
viewing all CPU cores as uniform, consistent with TBB behavior when NUMA
16+
constraints are not used. As a result, the following code returns the irrelevant
17+
values that do not reflect the actual topology:
18+
19+
#+begin_src C++
20+
std::vector<oneapi::tbb::numa_node_id> numa_nodes = oneapi::tbb::info::numa_nodes();
21+
std::vector<oneapi::tbb::core_type_id> core_types = oneapi::tbb::info::core_types();
22+
#+end_src
23+
24+
This lack of valid HW topology, caused by the absence of a third-party library,
25+
is the major problem with the current oneTBB behavior. The problem lies in the
26+
lack of diagnostics making it difficult for developers to detect. As a result,
27+
the code continues to run but fails to use NUMA as intended.
28+
29+
Dependency on a shared HWLOC library has the following benefits:
30+
1. Code reuse with all of the positive consequences out of this, including
31+
relying on the same code that has been tested and debugged, allowing the OS
32+
to share it among different processes, which consequently improves on cache
33+
locality and memory footprint. That's the primary purpose of shared
34+
libraries.
35+
2. A drop-in replacement. Users are able to use their own version of HWLOC
36+
without recompilation of oneTBB. This specific version of HWLOC could include
37+
a hotfix to support a particular and/or new hardware that a customer has, but
38+
whose support is not yet upstreamed to HWLOC project. It is also possible
39+
that such support won't be upstreamed at all if that hardware is not going to
40+
be available for massive users. It could also be a development version of
41+
HWLOC that someone wants to test on their systems first. Of course, they can
42+
do it with the static version as well, but that's more cumbersome as it
43+
requires recompilation of every dependent component.
44+
45+
The only disadvantage from depending on HWLOC library dynamically is that the
46+
developers that use oneTBB's NUMA support API need to make sure the library is
47+
available and can be found by oneTBB. Depending on the distribution model of a
48+
developer's code, this is achieved either by:
49+
1. Asking the end user to have necessary version of a dependency pre-installed.
50+
2. Bundling necessary HWLOC version together with other pieces of a product
51+
release.
52+
53+
However, the requirement to fulfill one of the above steps for the NUMA API to
54+
start paying off may be considered as an incovenience and, what is more
55+
important, it is not always obvious that one of these steps is needed.
56+
Especially, due to silent behavior in case HWLOC library cannot be found in the
57+
environment.
58+
59+
The proposal is to reduce the effect of the disadvantage of relying on a dynamic
60+
HWLOC library. The improvements involve statically linking HWLOC with one of the
61+
~tbbbind~ libraries distributed together with oneTBB. At the same time, you
62+
retain the flexibility to specify different version of HWLOC library if needed.
63+
64+
Since HWLOC 1.x is an older version and modern operating systems install HWLOC
65+
2.x by default, the probability of users being restricted to HWLOC 1.x is
66+
relatively small. Thus, we can reuse the filename of the ~tbbbind~ library
67+
linked to HWLOC 1.x for the library linked against a static HWLOC 2.x.
68+
69+
* Proposal
70+
1. Replace the dynamic link of ~tbbbind~ library currently linked
71+
against HWLOC 1.x with a link to a static HWLOC library version 2.x.
72+
2. Add loading of that ~tbbbind~ variant as the last attempt to resolve the
73+
dependency on functionality provided by the ~tbbbind~ layer.
74+
3. Update the oneTBB documentation, including [[https://oneapi-src.github.io/oneTBB/search.html?q=tbb%3A%3Ainfo][these pages]], to
75+
detail the steps for identifying which ~tbbbind~ is being used.
76+
77+
** Advantages
78+
1. The proposed behavior introduces a fallback mechanism for resolving the HWLOC
79+
library dependency when it is not in the environment, while still preferring
80+
user-provided versions. As a result, the problematic oneTBB API usage works
81+
as expected, returning an enumerated list of actual NUMA nodes and core types
82+
on the system the code is running on, provided that the loaded HWLOC library
83+
works on that system and that an application properly distributes all
84+
binaries of oneTBB, sets the environment so that the necessary variant of
85+
~tbbbind~ library can be found and loaded.
86+
2. Dropping support for HWLOC 1.x, does not introduce an additional ~tbbbind~
87+
variant while maintaining support for widely used versions of HWLOC.
88+
89+
** Disadvantages
90+
By default, there is still no diagnostics if you fail to correctly setup an
91+
environment with your version of HWLOC. Although, specifying the ~TBB_VERSION=1~
92+
environment variable helps identify configuration issues quickly.
93+
94+
* Alternative Handling for Missing System Topology
95+
The other behavior in case HWLOC library cannot be found is to be more explicit
96+
about the problem of a missing component and to either issue a warning or to
97+
refuse working requiring one of the ~tbbbind~ variant to be loaded (e.g., throw
98+
an exception).
99+
100+
Comparing these alternative approaches to the one proposed.
101+
** Common Advantages
102+
- Explicitly indicates that the functionality being used does not work, instead
103+
of failing silently.
104+
- Avoids the need to distribute an additional variant of ~tbbbind~ library.
105+
106+
** Common Disadvantages
107+
- Requires additional step from the user side to resolve the problem. In other
108+
words, it does not provide complete solution to the problem.
109+
110+
*** Disadvantages of Issuing a Warning
111+
- The warning may be unnoticed, especially if standard streams are closed.
112+
113+
*** Disadvantages of Throwing an Exception
114+
- May break existing code that does not expect an exception to be thrown.
115+
- Requires introduction of an additional exception hierarchy.
116+
117+
* References
118+
1. [[https://www.open-mpi.org/projects/hwloc/][HWLOC project main page]]
119+
2. [[https://github.com/open-mpi/hwloc][HWLOC project repository on GitHub]]

0 commit comments

Comments
 (0)