MemorySpace Class Reference

HiCR: HiCR::MemorySpace Class Reference
HiCR

#include <memorySpace.hpp>

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

Public Member Functions

 MemorySpace (const nlohmann::json &input)
 
virtual ~MemorySpace ()=default
 
__INLINE__ std::string getType () const
 
virtual __INLINE__ const size_t getSize () const
 
virtual __INLINE__ size_t getUsage () const
 
__INLINE__ void increaseUsage (const size_t delta)
 
__INLINE__ void decreaseUsage (const size_t delta)
 
__INLINE__ nlohmann::json serialize () const
 
__INLINE__ void deserialize (const nlohmann::json &input)
 

Protected Member Functions

 MemorySpace (const size_t size)
 
 MemorySpace ()=default
 
virtual void serializeImpl (nlohmann::json &output) const
 
virtual void deserializeImpl (const nlohmann::json &input)
 

Protected Attributes

std::string _type
 

Detailed Description

This class represents an generic definition for a Memory Space that:

  • Represents a autonomous unit of byte-addressable memory (e.g., host memory, NUMA domain, device global RAM)
  • The space is assumed to be contiguous and have a fixed sized determined at construction time
  • This is a copy-able class that only contains metadata

A Device object may comprise one or more such Memory Spaces on which data can be allocated, copied and communicated among different Memory Spaces, provided there is connectivity

Constructor & Destructor Documentation

◆ MemorySpace() [1/3]

HiCR::MemorySpace::MemorySpace ( const nlohmann::json &  input)
inline

Deserializing constructor

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

Parameters
[in]inputA JSON-encoded serialized host RAM information

◆ ~MemorySpace()

virtual HiCR::MemorySpace::~MemorySpace ( )
virtualdefault

◆ MemorySpace() [2/3]

HiCR::MemorySpace::MemorySpace ( const size_t  size)
inlineprotected

Constructor for the MemorySpace class

Parameters
[in]sizeThe size of the memory space to create

◆ MemorySpace() [3/3]

HiCR::MemorySpace::MemorySpace ( )
protecteddefault

Default constructor for deserialization purposes

Member Function Documentation

◆ decreaseUsage()

__INLINE__ void HiCR::MemorySpace::decreaseUsage ( const size_t  delta)
inline

Registers a decrease in the used memory size of the current memory space, either by freeing or manual deregistering

Parameters
deltaHow much (in bytes) has the memory usage decreased

◆ deserialize()

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

Serialization function to enable sharing memory space information

Parameters
[in]inputJSON-formatted serialized memory space information

◆ deserializeImpl()

virtual void HiCR::MemorySpace::deserializeImpl ( const nlohmann::json &  input)
inlineprotectedvirtual

Backend-specific implementation of the deserialize function

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

◆ getSize()

virtual __INLINE__ const size_t HiCR::MemorySpace::getSize ( ) const
inlinevirtual

Returns the memory space's size

Returns
The memory space's size

◆ getType()

__INLINE__ std::string HiCR::MemorySpace::getType ( ) const
inline

Indicates what type of memory space this represents

Returns
A string containing a human-readable description of the memory space type

◆ getUsage()

virtual __INLINE__ size_t HiCR::MemorySpace::getUsage ( ) const
inlinevirtual

If supported, obtain the amount of memory currently in use. In conjunction with the total size above, the user may deduce information like, usage%, if a particular allocation will be possible etc.

Returns
The current memory usage for this memory space

◆ increaseUsage()

__INLINE__ void HiCR::MemorySpace::increaseUsage ( const size_t  delta)
inline

Registers an increase in the used memory size of the current memory space, either by allocation or manual registering

Parameters
deltaHow much (in bytes) has the memory usage increased

◆ serialize()

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

Serialization function to enable sharing memory space information

Returns
JSON-formatted serialized memory space information

◆ serializeImpl()

virtual void HiCR::MemorySpace::serializeImpl ( nlohmann::json &  output) const
inlineprotectedvirtual

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

Member Data Documentation

◆ _type

std::string HiCR::MemorySpace::_type
protected

Type, used to identify exactly this memory space's model/technology


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