Topology: Local
This example showcases how the abstract HiCR Core API can be used to discover compute and memory devices in the system. The code is structured as follows:
source/
contains the different variants of this example corresponding to different backends
Topology detection
First, we use the topology manager to query the local HiCR instance’s topology
auto topology = topologyManager.queryTopology();
Compute resources and memory spaces retrieval
Then, we iterate over all its devices, printing the compute resources and memory spaces we find along with their types. For the latter, also their capacity.
for (const auto &d : topology.getDevices())
{
auto c = d->getComputeResourceList(); // Used to print compute resources
auto m = d->getMemorySpaceList(); // Used to print memory spaces
}
The result of running the hwloc example might be, for example:
+ 'NUMA Domain'
Compute Resources: 44 Processing Unit(s)
Memory Space: 'RAM', 94.483532 Gb
+ 'NUMA Domain'
Compute Resources: 44 Processing Unit(s)
Memory Space: 'RAM', 93.024166 Gb
Whereas, for the Ascend example, it would look as follows:
+ 'Ascend Device'
Compute Resources: 1 Ascend Processor(s)
Memory Space: 'Ascend Device RAM', 32.000000 Gb
+ 'Ascend Device'
Compute Resources: 1 Ascend Processor(s)
Memory Space: 'Ascend Device RAM', 32.000000 Gb
and for OpenCL, for example:
+ 'OpenCL GPU'
Compute Resources: 1 OpenCL GPU Processing Unit(s)
Memory Space: 'OpenCL GPU RAM', 49.908493 Gb