MemorySpace Class Reference

HiCR: HiCR::MemorySpace Class Reference
HiCR
HiCR::MemorySpace Class Referenceabstract

#include <memorySpace.hpp>

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

Public Member Functions

virtual std::string getType () const =0
 
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)
 
virtual ~MemorySpace ()=default
 
__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 =0
 
virtual void deserializeImpl (const nlohmann::json &input)=0
 

Detailed Description

This class represents an abstract 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()

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

◆ MemorySpace() [1/2]

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

Constructor for the MemorySpace class

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

◆ MemorySpace() [2/2]

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)
protectedpure virtual

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()

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

Indicates what type of memory space is contained in this instance

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

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

◆ 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
protectedpure virtual

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

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