|
Ginkgo
Generated from pipelines/1554403166 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_BASE_MACHINE_TOPOLOGY_HPP_
6 #define GKO_PUBLIC_CORE_BASE_MACHINE_TOPOLOGY_HPP_
16 #include <type_traits>
19 #include <ginkgo/config.hpp>
20 #include <ginkgo/core/base/exception.hpp>
21 #include <ginkgo/core/base/exception_helpers.hpp>
36 struct hwloc_topology;
37 struct hwloc_bitmap_s;
63 using hwloc_manager = std::unique_ptr<T, std::function<void(T*)>>;
68 struct normal_obj_info {
158 int ancestor_local_id;
163 std::string ancestor_type;
168 std::vector<int> closest_pu_ids;
173 std::string pci_bus_id;
201 const bool singlify =
true)
const
203 hwloc_binding_helper(this->cores_, ids, singlify);
229 const bool singlify =
true)
const
231 hwloc_binding_helper(this->pus_, ids, singlify);
252 GKO_ENSURE_IN_BOUNDS(
id, this->pus_.size());
253 return &this->pus_[id];
264 GKO_ENSURE_IN_BOUNDS(
id, this->cores_.size());
265 return &this->cores_[id];
276 GKO_ENSURE_IN_BOUNDS(
id, this->pci_devices_.size());
277 return &this->pci_devices_[id];
286 const io_obj_info*
get_pci_device(
const std::string& pci_bus_id)
const;
322 void hwloc_binding_helper(
323 const std::vector<machine_topology::normal_obj_info>& obj,
324 const std::vector<int>& ids,
const bool singlify =
true)
const;
335 std::vector<normal_obj_info>& objects)
const;
346 std::vector<io_obj_info>& vector)
const;
354 int get_obj_id_by_os_index(
const std::vector<normal_obj_info>& objects,
363 int get_obj_id_by_gp_index(
const std::vector<normal_obj_info>& objects,
378 std::vector<normal_obj_info> pus_;
379 std::vector<normal_obj_info> cores_;
380 std::vector<normal_obj_info> packages_;
381 std::vector<normal_obj_info> numa_nodes_;
382 std::vector<io_obj_info> pci_devices_;
385 hwloc_manager<hwloc_topology> topo_;
389 using MachineTopology GKO_DEPRECATED(
"please use machine_topology") =
396 #endif // GKO_PUBLIC_CORE_BASE_MACHINE_TOPOLOGY_HPP_
const normal_obj_info * get_pu(size_type id) const
Get the object of type PU associated with the id.
Definition: machine_topology.hpp:250
void bind_to_core(const int &id) const
Bind to a single core.
Definition: machine_topology.hpp:211
Definition: machine_topology.hpp:31
size_type get_num_numas() const
Get the number of NUMA objects stored in this Topology tree.
Definition: machine_topology.hpp:314
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:86
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:274
size_type get_num_pci_devices() const
Get the number of PCI device objects stored in this Topology tree.
Definition: machine_topology.hpp:307
void bind_to_pu(const int &id) const
Bind to a Processing unit (PU)
Definition: machine_topology.hpp:239
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
Definition: machine_topology.hpp:30
size_type get_num_cores() const
Get the number of core objects stored in this Topology tree.
Definition: machine_topology.hpp:300
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:200
The machine topology class represents the hierarchical topology of a machine, including NUMA nodes,...
Definition: machine_topology.hpp:61
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:228
static machine_topology * get_instance()
Returns an instance of the machine_topology object.
Definition: machine_topology.hpp:182
const normal_obj_info * get_core(size_type id) const
Get the object of type core associated with the id.
Definition: machine_topology.hpp:262
size_type get_num_pus() const
Get the number of PU objects stored in this Topology tree.
Definition: machine_topology.hpp:293