The machine topology class represents the hierarchical topology of a machine, including NUMA nodes, cores and PCI Devices.
More...
#include <ginkgo/core/base/machine_topology.hpp>
|
void | bind_to_cores (const std::vector< int > &ids, const bool singlify=true) const |
| Bind the calling process to the CPU cores associated with the ids. More...
|
|
void | bind_to_core (const int &id) const |
| Bind to a single core. More...
|
|
void | bind_to_pus (const std::vector< int > &ids, const bool singlify=true) const |
| Bind the calling process to PUs associated with the ids. More...
|
|
void | bind_to_pu (const int &id) const |
| Bind to a Processing unit (PU) More...
|
|
const normal_obj_info * | get_pu (size_type id) const |
| Get the object of type PU associated with the id. More...
|
|
const normal_obj_info * | get_core (size_type id) const |
| Get the object of type core associated with the id. More...
|
|
const io_obj_info * | get_pci_device (size_type id) const |
| Get the object of type pci device associated with the id. More...
|
|
const io_obj_info * | get_pci_device (const std::string &pci_bus_id) const |
| Get the object of type pci device associated with the PCI bus id. More...
|
|
size_type | get_num_pus () const |
| Get the number of PU objects stored in this Topology tree. More...
|
|
size_type | get_num_cores () const |
| Get the number of core objects stored in this Topology tree. More...
|
|
size_type | get_num_pci_devices () const |
| Get the number of PCI device objects stored in this Topology tree. More...
|
|
size_type | get_num_numas () const |
| Get the number of NUMA objects stored in this Topology tree. More...
|
|
void | hwloc_binding_helper (const std::vector< machine_topology::normal_obj_info > &obj, const std::vector< int > &ids, const bool singlify=true) const |
|
void | load_objects (hwloc_obj_type_t type, std::vector< normal_obj_info > &objects) const |
|
void | load_objects (hwloc_obj_type_t type, std::vector< io_obj_info > &vector) const |
|
int | get_obj_id_by_os_index (const std::vector< normal_obj_info > &objects, size_type os_index) const |
|
int | get_obj_id_by_gp_index (const std::vector< normal_obj_info > &objects, size_type gp_index) const |
|
The machine topology class represents the hierarchical topology of a machine, including NUMA nodes, cores and PCI Devices.
Various information of the machine are gathered with the help of the Hardware Locality library (hwloc).
This class also provides functionalities to bind objects in the topology to the execution objects. Binding can enhance performance by allowing data to be closer to the executing object.
See the hwloc documentation (https://www.open-mpi.org/projects/hwloc/doc/) for more detailed information on topology detection and binding interfaces.
- Note
- A global object of machine_topology type is created in a thread safe manner and only destroyed at the end of the program. This means that any subsequent queries will be from the same global object and hence use an extra atomic read.
◆ bind_to_core()
void gko::machine_topology::bind_to_core |
( |
const int & |
id | ) |
const |
|
inline |
◆ bind_to_cores()
void gko::machine_topology::bind_to_cores |
( |
const std::vector< int > & |
ids, |
|
|
const bool |
singlify = true |
|
) |
| const |
|
inline |
Bind the calling process to the CPU cores associated with the ids.
- Parameters
-
ids | The ids of cores to be bound. |
singlify | The ids of PUs are singlified to prevent possibly expensive migrations by the OS. This means that the binding is performed for only one of the ids in the set of ids passed in. See hwloc doc for singlify |
Referenced by bind_to_core().
◆ bind_to_pu()
void gko::machine_topology::bind_to_pu |
( |
const int & |
id | ) |
const |
|
inline |
Bind to a Processing unit (PU)
- Parameters
-
ids | The ids of PUs to be bound to the calling process. |
References bind_to_pus(), and get_instance().
◆ bind_to_pus()
void gko::machine_topology::bind_to_pus |
( |
const std::vector< int > & |
ids, |
|
|
const bool |
singlify = true |
|
) |
| const |
|
inline |
Bind the calling process to PUs associated with the ids.
- Parameters
-
ids | The ids of PUs to be bound. |
singlify | The ids of PUs are singlified to prevent possibly expensive migrations by the OS. This means that the binding is performed for only one of the ids in the set of ids passed in. See hwloc doc for singlify |
Referenced by bind_to_pu().
◆ get_core()
const normal_obj_info* gko::machine_topology::get_core |
( |
size_type |
id | ) |
const |
|
inline |
Get the object of type core associated with the id.
- Parameters
-
- Returns
- the core object struct.
◆ get_instance()
◆ get_num_cores()
size_type gko::machine_topology::get_num_cores |
( |
| ) |
const |
|
inline |
Get the number of core objects stored in this Topology tree.
- Returns
- the number of cores.
◆ get_num_numas()
size_type gko::machine_topology::get_num_numas |
( |
| ) |
const |
|
inline |
Get the number of NUMA objects stored in this Topology tree.
- Returns
- the number of NUMA objects.
◆ get_num_pci_devices()
size_type gko::machine_topology::get_num_pci_devices |
( |
| ) |
const |
|
inline |
Get the number of PCI device objects stored in this Topology tree.
- Returns
- the number of PCI devices.
◆ get_num_pus()
size_type gko::machine_topology::get_num_pus |
( |
| ) |
const |
|
inline |
Get the number of PU objects stored in this Topology tree.
- Returns
- the number of PUs.
◆ get_pci_device() [1/2]
const io_obj_info* gko::machine_topology::get_pci_device |
( |
const std::string & |
pci_bus_id | ) |
const |
Get the object of type pci device associated with the PCI bus id.
- Parameters
-
pci_bus_id | The PCI bus id of the pci device |
- Returns
- the PCI object struct.
◆ get_pci_device() [2/2]
const io_obj_info* gko::machine_topology::get_pci_device |
( |
size_type |
id | ) |
const |
|
inline |
Get the object of type pci device associated with the id.
- Parameters
-
id | The id of the pci device |
- Returns
- the PCI object struct.
◆ get_pu()
const normal_obj_info* gko::machine_topology::get_pu |
( |
size_type |
id | ) |
const |
|
inline |
Get the object of type PU associated with the id.
- Parameters
-
- Returns
- the PU object struct.
The documentation for this class was generated from the following file: