Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Classes | Public Member Functions | Static Public Member Functions | List of all members
gko::machine_topology Class Reference

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>

Public Member Functions

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
 

Static Public Member Functions

static machine_topologyget_instance ()
 Returns an instance of the machine_topology object. More...
 

Detailed Description

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.

Member Function Documentation

◆ bind_to_core()

void gko::machine_topology::bind_to_core ( const int &  id) const
inline

Bind to a single core.

Parameters
idsThe ids of the core to be bound to the calling process.

References bind_to_cores(), and get_instance().

◆ 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
idsThe ids of cores to be bound.
singlifyThe 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
idsThe 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
idsThe ids of PUs to be bound.
singlifyThe 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
idThe id of the core
Returns
the core object struct.

◆ get_instance()

static machine_topology* gko::machine_topology::get_instance ( )
inlinestatic

Returns an instance of the machine_topology object.

Returns
the machine_topology instance

Referenced by bind_to_core(), and bind_to_pu().

◆ 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_idThe 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
idThe 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
idThe id of the PU
Returns
the PU object struct.

The documentation for this class was generated from the following file: