Producer Class Reference

HiCR: HiCR::channel::variableSize::SPSC::Producer Class Reference
HiCR
HiCR::channel::variableSize::SPSC::Producer Class Reference

#include <producer.hpp>

Inheritance diagram for HiCR::channel::variableSize::SPSC::Producer:
HiCR::channel::variableSize::Base HiCR::channel::Base HiCR::channel::variableSize::MPSC::nonlocking::Producer

Public Member Functions

 Producer (CommunicationManager &communicationManager, std::shared_ptr< LocalMemorySlot > sizeInfoBuffer, std::shared_ptr< GlobalMemorySlot > payloadBuffer, std::shared_ptr< GlobalMemorySlot > tokenBuffer, const std::shared_ptr< LocalMemorySlot > &internalCoordinationBufferForCounts, const std::shared_ptr< LocalMemorySlot > &internalCoordinationBufferForPayloads, std::shared_ptr< GlobalMemorySlot > consumerCoordinationBufferForCounts, std::shared_ptr< GlobalMemorySlot > consumerCoordinationBufferForPayloads, const size_t payloadCapacity, const size_t payloadSize, const size_t capacity)
 
__INLINE__ void updateDepth ()
 
__INLINE__ void advancePayloadTail (const size_t n=1)
 
__INLINE__ size_t getPayloadHeadPosition () const noexcept
 
__INLINE__ size_t getPayloadSize ()
 
__INLINE__ size_t getPayloadDepth ()
 
__INLINE__ size_t getPayloadCapacity ()
 
__INLINE__ void push (const std::shared_ptr< LocalMemorySlot > &sourceSlot, const size_t n=1)
 
size_t getDepth ()
 
bool isEmpty ()
 
- Public Member Functions inherited from HiCR::channel::Base
__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
 

Additional Inherited Members

- Static Public Member Functions inherited from HiCR::channel::Base
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 inherited from HiCR::channel::variableSize::Base
 Base (CommunicationManager &communicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBufferForCounts, const std::shared_ptr< LocalMemorySlot > &coordinationBufferForPayloads, const size_t capacity, const size_t payloadCapacity)
 
__INLINE__ auto getCircularBufferForCounts () const
 
__INLINE__ auto getCircularBufferForPayloads () const
 
__INLINE__ auto getCoordinationBufferForCounts () const
 
__INLINE__ auto getCoordinationBufferForPayloads () const
 
- Protected Member Functions inherited from HiCR::channel::Base
 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

Class definition for a HiCR Producer Channel

It exposes the functionality to be expected for a producer channel

Constructor & Destructor Documentation

◆ Producer()

HiCR::channel::variableSize::SPSC::Producer::Producer ( CommunicationManager communicationManager,
std::shared_ptr< LocalMemorySlot sizeInfoBuffer,
std::shared_ptr< GlobalMemorySlot payloadBuffer,
std::shared_ptr< GlobalMemorySlot tokenBuffer,
const std::shared_ptr< LocalMemorySlot > &  internalCoordinationBufferForCounts,
const std::shared_ptr< LocalMemorySlot > &  internalCoordinationBufferForPayloads,
std::shared_ptr< GlobalMemorySlot consumerCoordinationBufferForCounts,
std::shared_ptr< GlobalMemorySlot consumerCoordinationBufferForPayloads,
const size_t  payloadCapacity,
const size_t  payloadSize,
const size_t  capacity 
)
inline

The constructor of the variable-sized producer channel class.

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

Parameters
[in]communicationManagerThe backend to facilitate communication between the producer and consumer sides
[in]sizeInfoBufferThe local memory slot used to hold the information about the next message size
[in]payloadBufferThe global memory slot pertaining to the payload of all messages. The producer will push messages into this buffer, while there is enough space. This buffer should be large enough to hold at least the largest of the variable-size messages.
[in]tokenBufferThe memory slot pertaining to the token buffer, which is used to hold message size data. The producer will push message sizes into this buffer, while there is enough space. This buffer should be large enough to hold at least one message size.
[in]internalCoordinationBufferForCountsThis is a small buffer to hold the internal (local) state of the channel's message counts
[in]internalCoordinationBufferForPayloadsThis is a small buffer to hold the internal (local) state of the channel's payload sizes (in bytes)
[in]consumerCoordinationBufferForCountsA global reference of the consumer's own coordination buffer to check for updates on message counts
[in]consumerCoordinationBufferForPayloadsA global reference of the consumer's own coordination buffer to check for updates on payload sizes (in bytes)
[in]payloadCapacitycapacity in bytes of the buffer for message payloads
[in]payloadSizesize in bytes of the datatype used for variable-sized messages
[in]capacityThe maximum number of tokens that will be held by this channel

Member Function Documentation

◆ advancePayloadTail()

__INLINE__ void HiCR::channel::variableSize::SPSC::Producer::advancePayloadTail ( const size_t  n = 1)
inline

advance payload buffer tail by a number of bytes

Parameters
[in]nbytes to advance payload buffer tail by

◆ getDepth()

size_t HiCR::channel::variableSize::SPSC::Producer::getDepth ( )
inline
 Get depth of variable-size producer. Since we have 2 buffers - one
 for counts, and one for payloads, we need to be careful.
 Because the current implementation first receives the payload (phase 1) before

receiving the message counts (phase 2), returning this depth should guarantee we already have received the payloads

Returns
The number of elements in the variable-size producer channel

◆ getPayloadCapacity()

__INLINE__ size_t HiCR::channel::variableSize::SPSC::Producer::getPayloadCapacity ( )
inline

get payload buffer capacity

Returns
payload buffer capacity (in bytes)

◆ getPayloadDepth()

__INLINE__ size_t HiCR::channel::variableSize::SPSC::Producer::getPayloadDepth ( )
inline

get payload buffer depth

Returns
payload buffer depth (in bytes)

◆ getPayloadHeadPosition()

__INLINE__ size_t HiCR::channel::variableSize::SPSC::Producer::getPayloadHeadPosition ( ) const
inlinenoexcept

get payload buffer head position

Returns
payload buffer head position (in bytes)

◆ getPayloadSize()

__INLINE__ size_t HiCR::channel::variableSize::SPSC::Producer::getPayloadSize ( )
inline

get the datatype size used for payload buffer

Returns
datatype size (in bytes) for payload buffer

◆ isEmpty()

bool HiCR::channel::variableSize::SPSC::Producer::isEmpty ( )
inline

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 both message count and payload buffers are empty
false, if one of the buffers is not empty

◆ push()

__INLINE__ void HiCR::channel::variableSize::SPSC::Producer::push ( const std::shared_ptr< LocalMemorySlot > &  sourceSlot,
const size_t  n = 1 
)
inline

Puts new variable-sized messages unto the channel. The implementation consists of two phases. In phase 1, we copy the payload data. In phase 2, we copy the message size of the data we just copied. The reason we postpone copying the data size is following: The method getDepth is now simply a check for the depth of the sizes buffer, since we guarantee that the copying of the actual payload has already happened (phase 1 before phase 2).

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

Parameters
[in]sourceSlotSource slot (buffer) to copy into buffer
[in]nNumber of times to copy this sourceSlot into buffer

This operation will fail with an exception if:

  • The source buffer is smaller than required
  • The operation would exceed the buffer size

A call to this function throws an exception if:

  1. the channel at this locality is a consumer.

◆ updateDepth()

__INLINE__ void HiCR::channel::variableSize::SPSC::Producer::updateDepth ( )
inline

Identical to Producer::updateDepth(), but this coordination buffer is larger and contains payload information as well as token metadata


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