|
Ginkgo
Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.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>
20 #include <ginkgo/config.hpp>
21 #include <ginkgo/core/base/exception.hpp>
22 #include <ginkgo/core/base/exception_helpers.hpp>
37 struct hwloc_topology;
38 struct hwloc_bitmap_s;
64 using hwloc_manager = std::unique_ptr<T, std::function<void(T*)>>;
69 struct normal_obj_info {
159 int ancestor_local_id;
164 std::string ancestor_type;
169 std::vector<int> closest_pu_ids;
174 std::string pci_bus_id;
202 const bool singlify =
true)
const
204 hwloc_binding_helper(this->cores_, ids, singlify);
230 const bool singlify =
true)
const
232 hwloc_binding_helper(this->pus_, ids, singlify);
253 GKO_ENSURE_IN_BOUNDS(
id, this->pus_.size());
254 return &this->pus_[id];
265 GKO_ENSURE_IN_BOUNDS(
id, this->cores_.size());
266 return &this->cores_[id];
277 GKO_ENSURE_IN_BOUNDS(
id, this->pci_devices_.size());
278 return &this->pci_devices_[id];
287 const io_obj_info*
get_pci_device(
const std::string& pci_bus_id)
const;
323 void hwloc_binding_helper(
324 const std::vector<machine_topology::normal_obj_info>& obj,
325 const std::vector<int>& ids,
const bool singlify =
true)
const;
336 std::vector<normal_obj_info>& objects)
const;
347 std::vector<io_obj_info>& vector)
const;
355 int get_obj_id_by_os_index(
const std::vector<normal_obj_info>& objects,
364 int get_obj_id_by_gp_index(
const std::vector<normal_obj_info>& objects,
379 std::vector<normal_obj_info> pus_;
380 std::vector<normal_obj_info> cores_;
381 std::vector<normal_obj_info> packages_;
382 std::vector<normal_obj_info> numa_nodes_;
383 std::vector<io_obj_info> pci_devices_;
386 hwloc_manager<hwloc_topology> topo_;
390 using MachineTopology GKO_DEPRECATED(
"please use machine_topology") =
397 #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:251
void bind_to_core(const int &id) const
Bind to a single core.
Definition: machine_topology.hpp:212
Definition: machine_topology.hpp:32
size_type get_num_numas() const
Get the number of NUMA objects stored in this Topology tree.
Definition: machine_topology.hpp:315
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:108
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:275
size_type get_num_pci_devices() const
Get the number of PCI device objects stored in this Topology tree.
Definition: machine_topology.hpp:308
void bind_to_pu(const int &id) const
Bind to a Processing unit (PU)
Definition: machine_topology.hpp:240
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
Definition: machine_topology.hpp:31
size_type get_num_cores() const
Get the number of core objects stored in this Topology tree.
Definition: machine_topology.hpp:301
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:201
The machine topology class represents the hierarchical topology of a machine, including NUMA nodes,...
Definition: machine_topology.hpp:62
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:229
static machine_topology * get_instance()
Returns an instance of the machine_topology object.
Definition: machine_topology.hpp:183
const normal_obj_info * get_core(size_type id) const
Get the object of type core associated with the id.
Definition: machine_topology.hpp:263
size_type get_num_pus() const
Get the number of PU objects stored in this Topology tree.
Definition: machine_topology.hpp:294