@@ -1427,6 +1427,42 @@ HWLOC_DARWIN_CPUKINDS_FROM_SYSCTL=0
1427
1427
<div class="section">
1428
1428
\endhtmlonly
1429
1429
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
+
1430
1466
Some operating systems do not systematically provide separate
1431
1467
functions for CPU and memory binding. This means that CPU binding
1432
1468
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
1454
1490
memory, the CPU binding should be performed again in case the memory
1455
1491
binding altered the previously-selected CPU binding.
1456
1492
1493
+
1494
+ \section cpu_mem_bind_current_membind Current Memory Binding Policy
1495
+
1457
1496
Not all operating systems support the notion of a "current" memory
1458
1497
binding policy for the current process, but such operating systems often still
1459
1498
provide a way to allocate data on a given node set. Conversely, some
@@ -1464,7 +1503,7 @@ these facilities, hwloc provides:
1464
1503
1465
1504
<ul>
1466
1505
<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 ()
1468
1507
<li>a function that allocates memory bound to specific node set without changing
1469
1508
the current memory binding policy (if supported): hwloc_alloc_membind().
1470
1509
<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
1475
1514
manage separately the global process binding policy and directed allocation,
1476
1515
or use the third set of functions if it does not care about the process memory
1477
1516
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.
1482
1518
1483
1519
1484
1520
0 commit comments