ComputeResource Class Reference

HiCR: HiCR::backend::hwloc::ComputeResource Class Reference
HiCR

#include <computeResource.hpp>

Inheritance diagram for HiCR::backend::hwloc::ComputeResource:
HiCR::ComputeResource

Public Types

using logicalProcessorId_t = unsigned int
 
using physicalProcessorId_t = unsigned int
 
using numaAffinity_t = unsigned int
 

Public Member Functions

 ComputeResource (hwloc_topology_t topology, const logicalProcessorId_t logicalProcessorId)
 
 ComputeResource (const logicalProcessorId_t logicalProcessorId, const physicalProcessorId_t physicalProcessorId, const numaAffinity_t numaAffinity, std::unordered_set< std::shared_ptr< backend::hwloc::Cache > > caches)
 
 ~ComputeResource () override=default
 
 ComputeResource ()=default
 
__INLINE__ std::string getType () const override
 
__INLINE__ logicalProcessorId_t getProcessorId () const
 
__INLINE__ physicalProcessorId_t getPhysicalProcessorId () const
 
 ComputeResource (const nlohmann::json &input)
 
- Public Member Functions inherited from HiCR::ComputeResource
__INLINE__ nlohmann::json serialize () const
 
__INLINE__ void deserialize (const nlohmann::json &input)
 

Static Public Member Functions

static __INLINE__ void detectThreadPUs (hwloc_topology_t topology, hwloc_obj_t obj, int depth, std::vector< logicalProcessorId_t > &threadPUs)
 
static __INLINE__ physicalProcessorId_t detectPhysicalProcessorId (hwloc_topology_t topology, const logicalProcessorId_t logicalProcessorId)
 
static __INLINE__ numaAffinity_t detectCoreNUMAffinity (hwloc_topology_t topology, const logicalProcessorId_t logicalProcessorId)
 
static __INLINE__ std::unordered_set< std::shared_ptr< backend::hwloc::Cache > > detectCpuCaches (hwloc_topology_t topology, const logicalProcessorId_t logicalProcessorId)
 
static __INLINE__ numaAffinity_t getCpuNumaAffinity (hwloc_topology_t topology, const logicalProcessorId_t logicalProcessorId)
 

Protected Member Functions

__INLINE__ void serializeImpl (nlohmann::json &output) const override
 
__INLINE__ void deserializeImpl (const nlohmann::json &input) override
 

Detailed Description

This class represents a compute resource, visible by HWLoc. That is, a CPU processing unit (core or hyperthread) with information about caches and locality.

Member Typedef Documentation

◆ logicalProcessorId_t

System-given logical processor (core or hyperthread) identifier that this class instance represents

◆ numaAffinity_t

System-given NUMA affinity identifier

◆ physicalProcessorId_t

System-given physical processor identifier that this class instance represents

Constructor & Destructor Documentation

◆ ComputeResource() [1/4]

HiCR::backend::hwloc::ComputeResource::ComputeResource ( hwloc_topology_t  topology,
const logicalProcessorId_t  logicalProcessorId 
)
inline

Constructor for the compute resource class of the hwloc backend

Parameters
topologyHWLoc topology object for discovery
logicalProcessorIdOs-determied core affinity assigned to this compute resource

◆ ComputeResource() [2/4]

HiCR::backend::hwloc::ComputeResource::ComputeResource ( const logicalProcessorId_t  logicalProcessorId,
const physicalProcessorId_t  physicalProcessorId,
const numaAffinity_t  numaAffinity,
std::unordered_set< std::shared_ptr< backend::hwloc::Cache > >  caches 
)
inline

Constructor for the compute resource class of the hwloc backend

Parameters
[in]logicalProcessorIdUnique identifier for the core assigned to this compute resource
[in]numaAffinityThe NUMA domain associated to this core
[in]cachesThe set of caches contained to or accessible by this core
[in]physicalProcessorIdThe identifier of the physical core as assigned by the OS

◆ ~ComputeResource()

HiCR::backend::hwloc::ComputeResource::~ComputeResource ( )
overridevirtualdefault

Default destructor

Reimplemented from HiCR::ComputeResource.

◆ ComputeResource() [3/4]

HiCR::backend::hwloc::ComputeResource::ComputeResource ( )
default

Default constructor for serialization/deserialization purposes

◆ ComputeResource() [4/4]

HiCR::backend::hwloc::ComputeResource::ComputeResource ( const nlohmann::json &  input)
inline

Deserializing constructor

The instance created will contain all information, if successful in deserializing it, corresponding to the passed processing unit This instance should NOT be used for anything else than reporting/printing the contained resources

Parameters
[in]inputA JSON-encoded serialized processing unit information

Member Function Documentation

◆ deserializeImpl()

__INLINE__ void HiCR::backend::hwloc::ComputeResource::deserializeImpl ( const nlohmann::json &  input)
inlineoverrideprotectedvirtual

Backend-specific implementation of the deserialize function

Parameters
[in]inputSerialized compute resource information corresponding to the specific backend's topology manager

Implements HiCR::ComputeResource.

◆ detectCoreNUMAffinity()

static __INLINE__ numaAffinity_t HiCR::backend::hwloc::ComputeResource::detectCoreNUMAffinity ( hwloc_topology_t  topology,
const logicalProcessorId_t  logicalProcessorId 
)
inlinestatic

Uses HWloc to discover the NUMA node associated with a given logical processor ID

Parameters
[in]topologyAn HWLoc topology object, already initialized
[in]logicalProcessorIdThe ID of the processor we are doing the search for
Returns
The ID of the associated memory space

◆ detectCpuCaches()

static __INLINE__ std::unordered_set< std::shared_ptr< backend::hwloc::Cache > > HiCR::backend::hwloc::ComputeResource::detectCpuCaches ( hwloc_topology_t  topology,
const logicalProcessorId_t  logicalProcessorId 
)
inlinestatic

Uses HWloc to discover all caches associated with a given logical processor ID

Parameters
[in]topologyAn HWLoc topology object, already initialized
[in]logicalProcessorIdThe logical ID of the processor we are doing the search for
Returns
A vector of (type,size) entries, where type is a string describing the cache and size is the respective size in Bytes The 'type' string is has the following form: "Level <I/D/U> <P/S> <associated IDs>", where: Level: may be "L1", "L2, "L3" I/D/U: may be "Instruction", "Data", "Unified" P/S: may be "Private" or "Shared" associated IDs: (optional, for Shared cache) a list of core IDs, e.g. "0 1 2 3"

◆ detectPhysicalProcessorId()

static __INLINE__ physicalProcessorId_t HiCR::backend::hwloc::ComputeResource::detectPhysicalProcessorId ( hwloc_topology_t  topology,
const logicalProcessorId_t  logicalProcessorId 
)
inlinestatic

Uses HWloc to discover the (physical) processor ID, associated with a given logical processor ID

Parameters
[in]topologyAn HWLoc topology object, already initialized
[in]logicalProcessorIdThe logical ID of the processor we are doing the search for
Returns
The ID of the associated physical identifier related to the passed logical processor id

◆ detectThreadPUs()

static __INLINE__ void HiCR::backend::hwloc::ComputeResource::detectThreadPUs ( hwloc_topology_t  topology,
hwloc_obj_t  obj,
int  depth,
std::vector< logicalProcessorId_t > &  threadPUs 
)
inlinestatic

Uses HWloc to recursively (tree-like) identify the host's basic processing units (PUs)

Parameters
[in]topologyAn HWLoc topology object, already initialized
[in]objThe root HWLoc object for the start of the exploration tree at every recursion level
[in]depthStores the current exploration depth level, necessary to return only the processing units at the leaf level
[out]threadPUsStorage for the found procesing units

◆ getCpuNumaAffinity()

static __INLINE__ numaAffinity_t HiCR::backend::hwloc::ComputeResource::getCpuNumaAffinity ( hwloc_topology_t  topology,
const logicalProcessorId_t  logicalProcessorId 
)
inlinestatic

Uses HWloc to discover the NUMA node associated with a given logical processor ID

Parameters
[in]topologyHWLoc topology object
[in]logicalProcessorIdThe ID of the processor we are doing the search for
Returns
The ID of the associated memory space

◆ getPhysicalProcessorId()

__INLINE__ physicalProcessorId_t HiCR::backend::hwloc::ComputeResource::getPhysicalProcessorId ( ) const
inline

Obtains the Core ID of the CPU; in non SMT systems that will be the actual id; in SMT it is the id of the actual core the thread belongs to.

Returns
The physical ID of the hardware Core

◆ getProcessorId()

__INLINE__ logicalProcessorId_t HiCR::backend::hwloc::ComputeResource::getProcessorId ( ) const
inline

Function to return the compute resource processor id

Returns
The processor id

◆ getType()

__INLINE__ std::string HiCR::backend::hwloc::ComputeResource::getType ( ) const
inlineoverridevirtual

Indicates what type of compute unit is contained in this instance

Returns
A string containing a human-readable description of the compute resource type

Implements HiCR::ComputeResource.

◆ serializeImpl()

__INLINE__ void HiCR::backend::hwloc::ComputeResource::serializeImpl ( nlohmann::json &  output) const
inlineoverrideprotectedvirtual

Backend-specific implemtation of the serialize function that allows adding more information than the one provided by default by HiCR

Parameters
[out]outputJSON-formatted serialized compute resource information

Implements HiCR::ComputeResource.


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