Consumer Class Reference
HiCR
|
#include <consumer.hpp>

Public Member Functions | |
Consumer (CommunicationManager &communicationManager, const std::shared_ptr< GlobalMemorySlot > &tokenBuffer, const std::shared_ptr< LocalMemorySlot > &internalCoordinationBuffer, std::shared_ptr< GlobalMemorySlot > producerCoordinationBuffer, const size_t tokenSize, const size_t capacity) | |
__INLINE__ size_t | peek (const size_t pos=0) |
__INLINE__ void | pop (const size_t n=1) |
__INLINE__ void | updateDepth () |
__INLINE__ std::shared_ptr< GlobalMemorySlot > | getTokenBuffer () const |
![]() | |
__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 __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 |
![]() | |
Base (CommunicationManager &communicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBuffer, const size_t tokenSize, const size_t capacity) | |
![]() | |
Base (CommunicationManager &communicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBuffer, const size_t tokenSize, const size_t capacity) | |
__INLINE__ CommunicationManager * | getCommunicationManager () const |
__INLINE__ auto | getCoordinationBuffer () const |
Detailed Description
Class definition for a HiCR Consumer Channel
It exposes the functionality to be expected for a consumer channel
Constructor & Destructor Documentation
◆ Consumer()
|
inline |
The constructor of the consumer channel class.
It requires the user to provide the allocated memory slots for the exchange (data) and coordination buffers.
- Parameters
-
[in] communicationManager The backend to facilitate communication between the producer and consumer sides [in] tokenBuffer The 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] internalCoordinationBuffer This is a small buffer to hold the internal (loca) state of the channel's circular buffer [in] producerCoordinationBuffer A global reference to the producer channel's internal coordination buffer, used for remote updates on pop() [in] tokenSize The size of each token. [in] capacity The maximum number of tokens that will be held by this channel
Member Function Documentation
◆ getTokenBuffer()
|
inline |
Function to recover the token buffer This is useful to recover access to the data after the reference to the original memory slot is lost
- Returns
- The reference to the internal token buffer
◆ peek()
|
inline |
Peeks in the local received queue and returns a pointer to the current token.
This is a one-sided blocking call that need not be made collectively.
- Parameters
-
[in] pos The token position required. pos = 0 indicates earliest token that is currently present in the buffer. pos = getDepth()-1 indicates the latest token to have arrived.
- Returns
- A value representing the relative position within the token buffer where the required element can be found.
This is a getter function that should complete in
An exception will occur if you do attempt to peek and no
- See also
- queryDepth to determine whether the channel has an item to pop.
- Note
- While this function does not modify the state of the channel, the contents of the token may be modified by the caller.
◆ pop()
|
inline |
Removes the current token from the channel, and moves to the next token (or to an empty channel state).
This is a one-sided blocking call that need not be made collectively.
- Parameters
-
[in] n How many tokens to pop. Optional; default is one.
In case there are less than n tokens in the channel, no tokens will be popped.
- See also
- queryDepth to determine whether the channel has an item to pop before calling this function.
◆ updateDepth()
|
inline |
In this implementation of SPSC, updateDepth for the consumer is a NOP. Any push by the producer leads the producer to update the consumer head index in a one-sided manner. This implementation has some advantages for MPSC using SPSC.
The documentation for this class was generated from the following file:
- /home/runner/work/HiCR/HiCR/include/hicr/frontends/channel/fixedSize/spsc/consumer.hpp
Generated by