bronx.system.numa

This module provides informations on the NUMA partitioning of the CPUs.

On Belenos (2x AMD Rome socket with 64 cores each):

>>> numa_i = numa_nodes_info()
>>> print(numa_i)
There are 8 nodes.
Node 0 description:
- cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- totalsize: 34234114048 bytes
Node 1 description:
- cpus: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
- totalsize: 34358689792 bytes
Node 2 description:
- cpus: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
- totalsize: 34358689792 bytes
Node 3 description:
- cpus: 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
- totalsize: 34346106880 bytes
Node 4 description:
- cpus: 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
- totalsize: 34358689792 bytes
Node 5 description:
- cpus: 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
- totalsize: 34358689792 bytes
Node 6 description:
- cpus: 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
- totalsize: 34358689792 bytes
Node 7 description:
- cpus: 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
- totalsize: 34358689792 bytes
Distances matrix:
          0    1    2    3    4    5    6    7
   0:    10   12   12   12   32   32   32   32
   1:    12   10   12   12   32   32   32   32
   2:    12   12   10   12   32   32   32   32
   3:    12   12   12   10   32   32   32   32
   4:    32   32   32   32   10   12   12   12
   5:    32   32   32   32   12   10   12   12
   6:    32   32   32   32   12   12   10   12
   7:    32   32   32   32   12   12   12   10
>>> import pprint
# To obtain a partitioning in blocks of 4 cores that takes NUMA nodes
# into account
>>> pprint.pprint(numa_i.numapacked_cpulist(blocksize=4))
[[0, 1, 2, 3],
 [64, 65, 66, 67],
 [16, 17, 18, 19],
 [80, 81, 82, 83],
 [32, 33, 34, 35],
 [96, 97, 98, 99],
 [48, 49, 50, 51],
 [112, 113, 114, 115],
 [4, 5, 6, 7],
 [68, 69, 70, 71],
 [20, 21, 22, 23],
 [84, 85, 86, 87],
 [36, 37, 38, 39],
 [100, 101, 102, 103],
 [52, 53, 54, 55],
 [116, 117, 118, 119],
 [8, 9, 10, 11],
 [72, 73, 74, 75],
 [24, 25, 26, 27],
 [88, 89, 90, 91],
 [40, 41, 42, 43],
 [104, 105, 106, 107],
 [56, 57, 58, 59],
 [120, 121, 122, 123],
 [12, 13, 14, 15],
 [76, 77, 78, 79],
 [28, 29, 30, 31],
 [92, 93, 94, 95],
 [44, 45, 46, 47],
 [108, 109, 110, 111],
 [60, 61, 62, 63],
 [124, 125, 126, 127]]

Functions

bronx.system.numa.numa_nodes_info()[source]

Pick a subclass of NumaNodesInfo and instantiate it.

Depending on the operating system, the approriate class will be picked. If no NumaNodesInfo is available, the NotImplementedError exception will be raised.

Classes

class bronx.system.numa.LibNumaNodesInfo(**kwargs)[source]

Bases: NumaNodesInfo

Hold information on the system’s NUMA nodes.

The information about NUMA nodes is retrieved using the standard libnuma.

class bronx.system.numa.LibnumaGateway(*args, **kw)[source]

Bases: Singleton

Interface to the libnuma DLL.

The DLL is initialised on the first call.

property lib

Return the libnuma DLL (provided by the ctypes package).

numa_node_size64(node)[source]

Return the memory associated with a given node.

Return type:

tuple

Returns:

(total_memory, free_memory)

class bronx.system.numa.NumaNodeInfo(cpus, distances, totalsize)[source]

Bases: object

Hold information on a single Numa node.

Parameters:
  • cpus (set) – The CPU numbers associated with this NUMA node

  • distances (dict) – The distance to other NUMA nodes

  • totalsize – The NUMA node memory size (in bytes)

property cpus

The set of CPU numbers associated with this NUMA node.

property distances

The distance to other NUMA nodes.

property totalsize

The NUMA node memory size (in bytes).

class bronx.system.numa.NumaNodesInfo[source]

Bases: Mapping

Hold information on the system’s NUMA nodes.

Abstract class.

freesize(nodeid)[source]

Return the amount of free memory for the nodeid NUMA node.

property nodes_clustering

Perform a hierarchical clustering over the NUMA nodes based on the inter-node distance (using a ‘Farthest Point Algorithm’ method)

An harcoded version of the clustering algorithm is available, but a version based on scipy is also included (depending on the number of nodes on or another is chosen).

numabalanced_cpu_dispenser(smtlayout=None, default_bsize=None)[source]

Return a new _NumaBalancedCpuIdDispenser object.

Parameters:
  • smtlayout – A dictionary that associates a physical CPU ids to its virtual CPUs

  • default_bsize – The default blocksize

numabalanced_cpulist(blocksize, smtlayout=None)[source]

Return a list of consecutive blocksize CPU ids.

Parameters:
  • blocksize – The size of each block of CPUs

  • smtlayout – A dictionary that associates a physical CPU ids to its virtual CPUs

Such CPU ids should be evenly distributed across NUMA zones in order to spread as much as possible (regardless of the NUMA distance between CPUs).

numapacked_cpu_dispenser(smtlayout=None, default_bsize=None)[source]

Return a new _NumaPackedCpuIdDispenser object.

Parameters:
  • smtlayout – A dictionary that associates a physical CPU ids to its virtual CPUs

  • default_bsize – The default blocksize

numapacked_cpulist(blocksize, smtlayout=None)[source]

Return a list of consecutive blocksize CPU ids.

Parameters:
  • blocksize – The size of each block of CPUs

  • smtlayout – A dictionary that associates a physical CPU ids to its virtual CPUs

Such CPU ids should be evenly distributed across NUMA zones while trying to minimise the NUMA distance between CPUs.