Skip to content

Commit dfca160

Browse files
committed
doxy: improve the cpu_mem_bind chapter
- subdivide in sections - add an introduction - talk about portability and policies - more cross-references Refs #601 Signed-off-by: Brice Goglin <[email protected]>
1 parent 639d09e commit dfca160

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

doc/hwloc.doxy

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,42 @@ HWLOC_DARWIN_CPUKINDS_FROM_SYSCTL=0
14271427
<div class="section">
14281428
\endhtmlonly
14291429

1430+
Binding tasks and data buffers is hwloc's second main goal after
1431+
discovering and exposing the hardware topology.
1432+
hwloc defines APIs to bind threads and processes to cores and
1433+
processing units (see \ref hwlocality_cpubinding),
1434+
and to bind memory buffers to NUMA nodes (see \ref hwlocality_membinding).
1435+
Some examples are available under doc/examples/ in the source tree.
1436+
1437+
Sections below provide high-level insights on how these APIs work.
1438+
1439+
\section cpu_mem_bind_portability Binding Policies and Portability
1440+
1441+
hwloc binding APIs are portable to multiple operating systems.
1442+
However operating systems sometimes define slightly different policies,
1443+
which means hwloc's behavior might slightly differ.
1444+
1445+
On the CPU binding side, OSes have different constraints of which sets
1446+
of PUs can be used for binding (only full cores, random sets of PUs, etc.).
1447+
Moreover the ::HWLOC_CPUBIND_STRICT may be given to clarify what to do
1448+
in some corner cases.
1449+
It is recommended to read \ref hwlocality_cpubinding for details.
1450+
1451+
On the memory binding side, things are more complicated.
1452+
First, there are multiple API for binding existing memory buffers,
1453+
allocating new ones, etc.
1454+
Second, multiple policies exist (first-touch, bind, interleave, etc.)
1455+
but some of them are not implemented by all operating systems.
1456+
Third, some of these policies have slightly different meanings.
1457+
For instance, hwloc's <b>bind</b> (::HWLOC_MEMBIND_BIND) uses
1458+
Linux' <b>MPOL_PREFERRED_MANY</b> (or <b>MPOL_PREFERRED</b>) by default,
1459+
but it switches to <b>MPOL_BIND</b> when strict binding is requested
1460+
(::HWLOC_MEMBIND_STRICT).
1461+
Reading \ref hwlocality_membinding is strongly recommended.
1462+
1463+
1464+
\section cpu_mem_bind_joint Joint CPU and Memory Binding (or not)
1465+
14301466
Some operating systems do not systematically provide separate
14311467
functions for CPU and memory binding. This means that CPU binding
14321468
functions may have have effects on the memory binding policy.
@@ -1454,6 +1490,9 @@ memory will not change with it. When binding and allocating further
14541490
memory, the CPU binding should be performed again in case the memory
14551491
binding altered the previously-selected CPU binding.
14561492

1493+
1494+
\section cpu_mem_bind_current_membind Current Memory Binding Policy
1495+
14571496
Not all operating systems support the notion of a "current" memory
14581497
binding policy for the current process, but such operating systems often still
14591498
provide a way to allocate data on a given node set. Conversely, some
@@ -1464,7 +1503,7 @@ these facilities, hwloc provides:
14641503

14651504
<ul>
14661505
<li>functions that set/get the current memory binding policies (if supported):
1467-
hwloc_set/get_membind() and hwloc_set/get_proc_membind()
1506+
hwloc_set_membind(), hwloc_get_membind(), hwloc_set_proc_membind() and hwloc_get_proc_membind()
14681507
<li>a function that allocates memory bound to specific node set without changing
14691508
the current memory binding policy (if supported): hwloc_alloc_membind().
14701509
<li>a helper which, if needed, changes the current memory binding policy of the
@@ -1475,10 +1514,7 @@ An application can thus use the two first sets of functions if it wants to
14751514
manage separately the global process binding policy and directed allocation,
14761515
or use the third set of functions if it does not care about the process memory
14771516
binding policy.
1478-
1479-
See \ref hwlocality_cpubinding and \ref hwlocality_membinding for
1480-
hwloc's API functions regarding CPU and memory binding, respectively.
1481-
There are some examples under doc/examples/ in the source tree.
1517+
Again, reading \ref hwlocality_membinding is strongly recommended.
14821518

14831519

14841520

0 commit comments

Comments
 (0)