Device Class Reference

HiCR: HiCR::Device Class Reference
HiCR

#include <device.hpp>

Inheritance diagram for HiCR::Device:
HiCR::backend::ascend::Device HiCR::backend::hwloc::Device HiCR::backend::opencl::Device

Public Types

using computeResourceList_t = std::vector< std::shared_ptr< ComputeResource > >
 
using memorySpaceList_t = std::vector< std::shared_ptr< MemorySpace > >
 

Public Member Functions

virtual std::string getType () const =0
 
__INLINE__ const computeResourceList_tgetComputeResourceList ()
 
__INLINE__ const memorySpaceList_tgetMemorySpaceList ()
 
__INLINE__ void addComputeResource (const std::shared_ptr< HiCR::ComputeResource > &computeResource)
 
__INLINE__ void addMemorySpace (const std::shared_ptr< HiCR::MemorySpace > &memorySpace)
 
virtual ~Device ()=default
 
 Device (computeResourceList_t computeResources, memorySpaceList_t memorySpaces)
 
__INLINE__ nlohmann::json serialize () const
 
__INLINE__ void deserialize (const nlohmann::json &input)
 

Protected Member Functions

 Device ()=default
 
virtual void serializeImpl (nlohmann::json &output) const =0
 
virtual void deserializeImpl (const nlohmann::json &input)=0
 

Detailed Description

This class represents an abstract definition for a HiCR Device that:

  • Represents a physical computing device (e.g., CPU+RAM, GPU+DRAM), containing a set of compute resources (e.g., cores) and/or memory spaces (e.g., RAM)
  • It may contain information about the connectivity between its compute and memory resources
  • This is a copy-able class that only contains metadata

Member Typedef Documentation

◆ computeResourceList_t

using HiCR::Device::computeResourceList_t = std::vector<std::shared_ptr<ComputeResource> >

Common type for a collection of compute resources

◆ memorySpaceList_t

using HiCR::Device::memorySpaceList_t = std::vector<std::shared_ptr<MemorySpace> >

Common definition of a collection of memory spaces

Constructor & Destructor Documentation

◆ ~Device()

virtual HiCR::Device::~Device ( )
virtualdefault

◆ Device() [1/2]

HiCR::Device::Device ( computeResourceList_t  computeResources,
memorySpaceList_t  memorySpaces 
)
inline

Constructor requires at least to provide the initial set of compute resources and memory spaces

Parameters
[in]computeResourcesThe list of detected compute resources contained in this device
[in]memorySpacesThe list of detected memory spaces contained in this device

◆ Device() [2/2]

HiCR::Device::Device ( )
protecteddefault

Protected constructor only for the derived classes to run the deserializing constructor

Member Function Documentation

◆ addComputeResource()

__INLINE__ void HiCR::Device::addComputeResource ( const std::shared_ptr< HiCR::ComputeResource > &  computeResource)
inline

This function allows the deferred addition (post construction) of compute resources

Parameters
[in]computeResourceThe compute resource to add

◆ addMemorySpace()

__INLINE__ void HiCR::Device::addMemorySpace ( const std::shared_ptr< HiCR::MemorySpace > &  memorySpace)
inline

This function allows the deferred addition (post construction) of memory spaces

Parameters
[in]memorySpaceThe compute resource to add

◆ deserialize()

__INLINE__ void HiCR::Device::deserialize ( const nlohmann::json &  input)
inline

De-serialization function to re-construct the serialized device information coming (typically) from remote instances

Parameters
[in]inputJSON-formatted serialized device information
Note
Important: Deserialized devices are not meant to be used in any from other than printing or reporting its topology. Any attempt of actually using them for computation or data transfers will result in undefined behavior.

◆ deserializeImpl()

virtual void HiCR::Device::deserializeImpl ( const nlohmann::json &  input)
protectedpure virtual

Backend-specific implementation of the deserialize function

Parameters
[in]inputSerialized device information

◆ getComputeResourceList()

__INLINE__ const computeResourceList_t & HiCR::Device::getComputeResourceList ( )
inline

This function returns the list of queried compute resources, as visible by the device.

Returns
The list of compute resources contained in this device

◆ getMemorySpaceList()

__INLINE__ const memorySpaceList_t & HiCR::Device::getMemorySpaceList ( )
inline

This function returns the list of queried memory spaces, as visible by the device.

Returns
The list of memory spaces contained in this device

◆ getType()

virtual std::string HiCR::Device::getType ( ) const
pure virtual

Indicates what type of device is represented in this instance

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

Implemented in HiCR::backend::ascend::Device, HiCR::backend::hwloc::Device, and HiCR::backend::opencl::Device.

◆ serialize()

__INLINE__ nlohmann::json HiCR::Device::serialize ( ) const
inline

Serialization function to enable sharing device information

Returns
JSON-formatted serialized device information

◆ serializeImpl()

virtual void HiCR::Device::serializeImpl ( nlohmann::json &  output) const
protectedpure virtual

Backend-specific implementation of the serialize function

Parameters
[out]outputSerialized device information

The documentation for this class was generated from the following file:
  • /home/runner/work/HiCR/HiCR/include/hicr/core/device.hpp