33#ifndef GKO_PUBLIC_CORE_BASE_MACHINE_TOPOLOGY_HPP_
34#define GKO_PUBLIC_CORE_BASE_MACHINE_TOPOLOGY_HPP_
48#include <ginkgo/config.hpp>
49#include <ginkgo/core/base/exception.hpp>
50#include <ginkgo/core/base/exception_helpers.hpp>
92 using hwloc_manager = std::unique_ptr<
T, std::function<
void(
T*)>>;
97 struct normal_obj_info {
187 int ancestor_local_id;
192 std::string ancestor_type;
197 std::vector<int> closest_pu_ids;
202 std::string pci_bus_id;
281 GKO_ENSURE_IN_BOUNDS(
id, this->pus_.size());
282 return &this->pus_[
id];
293 GKO_ENSURE_IN_BOUNDS(
id, this->cores_.size());
294 return &this->cores_[
id];
305 GKO_ENSURE_IN_BOUNDS(
id, this->pci_devices_.size());
306 return &this->pci_devices_[
id];
351 void hwloc_binding_helper(
352 const std::vector<machine_topology::normal_obj_info>& obj,
353 const std::vector<int>&
ids,
const bool singlify =
true)
const;
364 std::vector<normal_obj_info>&
objects)
const;
375 std::vector<io_obj_info>& vector)
const;
383 int get_obj_id_by_os_index(
const std::vector<normal_obj_info>&
objects,
392 int get_obj_id_by_gp_index(
const std::vector<normal_obj_info>&
objects,
407 std::vector<normal_obj_info> pus_;
408 std::vector<normal_obj_info> cores_;
409 std::vector<normal_obj_info> packages_;
410 std::vector<normal_obj_info> numa_nodes_;
411 std::vector<io_obj_info> pci_devices_;
418using MachineTopology GKO_DEPRECATED(
"please use machine_topology") =
The machine topology class represents the hierarchical topology of a machine, including NUMA nodes,...
Definition machine_topology.hpp:90
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.
const io_obj_info * get_pci_device(size_type id) const
Get the object of type pci device associated with the id.
Definition machine_topology.hpp:303
size_type get_num_numas() const
Get the number of NUMA objects stored in this Topology tree.
Definition machine_topology.hpp:343
size_type get_num_pus() const
Get the number of PU objects stored in this Topology tree.
Definition machine_topology.hpp:322
void bind_to_pus(const std::vector< int > &ids, const bool singlify=true) const
Bind the calling process to PUs associated with the ids.
Definition machine_topology.hpp:257
static machine_topology * get_instance()
Returns an instance of the machine_topology object.
Definition machine_topology.hpp:211
size_type get_num_cores() const
Get the number of core objects stored in this Topology tree.
Definition machine_topology.hpp:329
void bind_to_pu(const int &id) const
Bind to a Processing unit (PU)
Definition machine_topology.hpp:268
void bind_to_core(const int &id) const
Bind to a single core.
Definition machine_topology.hpp:240
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.
Definition machine_topology.hpp:229
const normal_obj_info * get_core(size_type id) const
Get the object of type core associated with the id.
Definition machine_topology.hpp:291
const normal_obj_info * get_pu(size_type id) const
Get the object of type PU associated with the id.
Definition machine_topology.hpp:279
size_type get_num_pci_devices() const
Get the number of PCI device objects stored in this Topology tree.
Definition machine_topology.hpp:336
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
Definition machine_topology.hpp:60
Definition machine_topology.hpp:59