Producer Class Reference

HiCR: HiCR::channel::fixedSize::SPSC::Producer Class Reference
HiCR
HiCR::channel::fixedSize::SPSC::Producer Class Reference

#include <producer.hpp>

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

Public Member Functions

 Producer (CommunicationManager &communicationManager, std::shared_ptr< GlobalMemorySlot > tokenBuffer, const std::shared_ptr< LocalMemorySlot > &internalCoordinationBuffer, std::shared_ptr< GlobalMemorySlot > consumerCoordinationBuffer, const size_t tokenSize, const size_t capacity)
 
__INLINE__ void push (const std::shared_ptr< LocalMemorySlot > &sourceSlot, const size_t n=1)
 
__INLINE__ void updateDepth ()
 
- 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::fixedSize::Base
 Base (CommunicationManager &communicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBuffer, const size_t tokenSize, const size_t capacity)
 
- 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::fixedSize::SPSC::Producer::Producer ( CommunicationManager communicationManager,
std::shared_ptr< GlobalMemorySlot tokenBuffer,
const std::shared_ptr< LocalMemorySlot > &  internalCoordinationBuffer,
std::shared_ptr< GlobalMemorySlot consumerCoordinationBuffer,
const size_t  tokenSize,
const size_t  capacity 
)
inline

The constructor of the 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]tokenBufferThe memory slot pertaining to the token buffer. The producer will push new tokens into this buffer, while there is enough space. This buffer should be big enough to hold at least one token.
[in]internalCoordinationBufferThis is a small buffer to hold the internal (loca) state of the channel's circular buffer
[in]consumerCoordinationBufferA global reference to the consumer's coordination buffer in order to push tokens and update their head index produced by the remote consumer
[in]tokenSizeThe size of each token.
[in]capacityThe maximum number of tokens that will be held by this channel

Member Function Documentation

◆ push()

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

Puts new token(s) unto the channel.

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

Parameters
[in]sourceSlotSource slot (buffer) from whence to read the token(s)
[in]nNumber of tokens to read from the 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.

Because it is possible that head advance (by producer) and tail advance (signalled by consumer) overlap, we allow for temporary illegal (tail > head) by using the cached depth when advancing the head

◆ updateDepth()

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

This function updates the internal value of the channel depth


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