Base Class Reference

HiCR: HiCR::channel::Base Class Reference
HiCR

#include <base.hpp>

Inheritance diagram for HiCR::channel::Base:
HiCR::channel::fixedSize::Base HiCR::channel::variableSize::Base HiCR::channel::fixedSize::MPSC::locking::Consumer HiCR::channel::fixedSize::MPSC::locking::Producer HiCR::channel::fixedSize::SPSC::Consumer HiCR::channel::fixedSize::SPSC::Producer HiCR::channel::variableSize::MPSC::locking::Consumer HiCR::channel::variableSize::MPSC::locking::Producer HiCR::channel::variableSize::SPSC::Consumer HiCR::channel::variableSize::SPSC::Producer

Public Member Functions

__INLINE__ size_t getTokenSize () const noexcept
 
__INLINE__ size_t getDepth () const noexcept
 
__INLINE__ bool isFull () const noexcept
 
__INLINE__ bool isEmpty () const noexcept
 
__INLINE__ auto getCircularBuffer () const noexcept
 

Static Public Member Functions

static __INLINE__ size_t getCoordinationBufferSize () noexcept
 
static __INLINE__ void initializeCoordinationBuffer (const std::shared_ptr< LocalMemorySlot > &coordinationBuffer)
 
static __INLINE__ size_t getTokenBufferSize (const size_t tokenSize, const size_t capacity) noexcept
 

Protected Member Functions

 Base (CommunicationManager &communicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBuffer, const size_t tokenSize, const size_t capacity)
 
__INLINE__ CommunicationManagergetCommunicationManager () const
 
__INLINE__ auto getCoordinationBuffer () const
 

Detailed Description

Base class definition for a HiCR Multiple-Producer Single-Consumer Channel

Constructor & Destructor Documentation

◆ Base()

HiCR::channel::Base::Base ( CommunicationManager communicationManager,
const std::shared_ptr< LocalMemorySlot > &  coordinationBuffer,
const size_t  tokenSize,
const size_t  capacity 
)
inlineprotected

The constructor of the base Channel class.

It requires the user to provide the allocated memory slots for the exchange (data) and coordination buffers.

Parameters
[in]communicationManagerThe backend's memory manager to facilitate communication between the producer and consumer sides
[in]coordinationBufferThis is a small buffer that needs to be allocated at the producer side. enables the consumer to signal how many tokens it has popped. It may also be used for other coordination signals.
[in]tokenSizeThe size of each token.
[in]capacityThe maximum number of tokens that will be held by this channel

Member Function Documentation

◆ getCircularBuffer()

__INLINE__ auto HiCR::channel::Base::getCircularBuffer ( ) const
inlinenoexcept

A function to obtain the low-level circular buffer where tokens are stored

Returns
The internal circular buffer

◆ getCommunicationManager()

__INLINE__ CommunicationManager * HiCR::channel::Base::getCommunicationManager ( ) const
inlineprotected

Get the internal communication buffer assigned to this channel

Returns
The internal communication buffer assigned to this channel

◆ getCoordinationBuffer()

__INLINE__ auto HiCR::channel::Base::getCoordinationBuffer ( ) const
inlineprotected

Get the internal coordination buffer assigned to this channel

Returns
The internal coordination buffer assigned to this channel

◆ getCoordinationBufferSize()

static __INLINE__ size_t HiCR::channel::Base::getCoordinationBufferSize ( )
inlinestaticnoexcept

This function can be used to check the size of the coordination buffer that needs to be provided in the creation of the producer channel

Returns
Size (bytes) of the coordination buffer

◆ getDepth()

__INLINE__ size_t HiCR::channel::Base::getDepth ( ) const
inlinenoexcept

Returns the current channel depth.

If the current channel is a consumer, it corresponds to how many tokens may yet be consumed. If the current channel is a producer, it corresponds the channel capacity minus the returned value equals how many tokens may still be pushed.

Note
This is not a thread-safe call

This is a getter function that should complete in $ \Theta(1) $ time.

Returns
The number of tokens in this channel.

This function when called on a valid channel instance will never fail.

◆ getTokenBufferSize()

static __INLINE__ size_t HiCR::channel::Base::getTokenBufferSize ( const size_t  tokenSize,
const size_t  capacity 
)
inlinestaticnoexcept

This function can be used to check the minimum size of the token buffer that needs to be provided to the consumer channel.

Parameters
[in]tokenSizeThe expected size of the tokens to use in the channel
[in]capacityThe expected capacity (in token count) to use in the channel
Returns
Minimum size (bytes) required of the token buffer

◆ getTokenSize()

__INLINE__ size_t HiCR::channel::Base::getTokenSize ( ) const
inlinenoexcept
Returns
The size of the tokens in this channel.

Returns simply the size per token. All tokens have the same size.

This is a one-sided blocking call that need not be made collectively.

This is a getter function that should complete in $ \Theta(1) $ time.

This function when called on a valid channel instance will never fail.

◆ initializeCoordinationBuffer()

static __INLINE__ void HiCR::channel::Base::initializeCoordinationBuffer ( const std::shared_ptr< LocalMemorySlot > &  coordinationBuffer)
inlinestatic

This function can be used to check the size of the coordination buffer that needs to be provided in the creation of the producer channel

Parameters
[in]coordinationBufferMemory slot corresponding to the coordination buffer

◆ isEmpty()

__INLINE__ bool HiCR::channel::Base::isEmpty ( ) const
inlinenoexcept

This function can be used to quickly check whether the channel is empty.

It does not affects the internal state of the channel

Returns
true, if the buffer is empty
false, if the buffer is not empty

◆ isFull()

__INLINE__ bool HiCR::channel::Base::isFull ( ) const
inlinenoexcept

This function can be used to quickly check whether the channel is full.

It affects the internal state of the channel because it detects any updates in the internal state of the buffers

Returns
true, if the buffer is full
false, if the buffer is not full

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