Producer Class Reference
|
HiCR
|
#include <producer.hpp>
Public Member Functions | |
| Producer (CommunicationManager &coordinationCommunicationManager, CommunicationManager &payloadCommunicationManager, 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 | push (const std::shared_ptr< LocalMemorySlot > &sourceSlot, const size_t n=1) |
| __INLINE__ void | updateDepth () |
| __INLINE__ size_t | getPayloadHeadPosition () const noexcept |
| __INLINE__ size_t | getPayloadSize () |
| __INLINE__ size_t | getPayloadDepth () |
| __INLINE__ size_t | getPayloadCapacity () |
| size_t | getCoordinationDepth () |
| bool | isEmpty () |
| bool | isFull (const size_t requiredBufferSize) |
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 &coordinationCommunicationManager, CommunicationManager &payloadCommunicationManager, 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 &coordinationCommunicationManager, CommunicationManager &payloadCommunicationManager, const std::shared_ptr< LocalMemorySlot > &coordinationBuffer, const size_t tokenSize, const size_t capacity) | |
| __INLINE__ CommunicationManager * | getPayloadCommunicationManager () const |
| __INLINE__ CommunicationManager * | getCoordinationCommunicationManager () 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()
|
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] coordinationCommunicationManager The backend's memory manager to facilitate communication between the producer and consumer coordination buffers [in] payloadCommunicationManager The backend's memory manager to facilitate communication between the producer and consumer payload buffers [in] sizeInfoBuffer The local memory slot used to hold the information about the next message size [in] payloadBuffer The 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 twice the capacity specified by payloadCapacity argument. Half of the buffer is used as excess buffer to avoid internal fragmentation of messages [in] tokenBuffer The 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] internalCoordinationBufferForCounts This is a small buffer to hold the internal (local) state of the channel's message counts [in] internalCoordinationBufferForPayloads This is a small buffer to hold the internal (local) state of the channel's payload sizes (in bytes) [in] consumerCoordinationBufferForCounts A global reference of the consumer's own coordination buffer to check for updates on message counts [in] consumerCoordinationBufferForPayloads A global reference of the consumer's own coordination buffer to check for updates on payload sizes (in bytes) [in] payloadCapacity capacity in bytes of the buffer for message payloads. [in] payloadSize size in bytes of the datatype used for variable-sized messages. [in] capacity The maximum number of tokens that will be held by this channel
Member Function Documentation
◆ getCoordinationDepth()
|
inline |
Get depth of the coordination buffer of variable-size producer. 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
- Note
- Even though there might be space for additional tokens in the coordination buffer, it is not guaranteed that the push() will succeed due to insufficient space in the payload buffer
◆ getPayloadCapacity()
|
inline |
get payload buffer capacity
- Returns
- payload buffer capacity (in bytes)
◆ getPayloadDepth()
|
inline |
Get payload buffer depth
- Returns
- payload buffer depth (in bytes). It is the occupancy of the buffers
- Note
- Even though there might be space for additional tokens in the payload buffer, it is not guaranteed that the push() will succeed due to insufficient space in the coordination buffer
◆ getPayloadHeadPosition()
|
inlinenoexcept |
get payload buffer head position
- Returns
- payload buffer head position (in bytes)
◆ getPayloadSize()
|
inline |
get the datatype size used for payload buffer
- Returns
- datatype size (in bytes) for payload buffer
◆ 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
◆ isFull()
|
inline |
This funciton can be used to quickly check whether the channel is becoming full when trying to push an element of a given size. First thing, we are checking if we can still push tokens (i.e., if the coordination buffer has space). Second thing, we are checking the payload buffer. If the current depth of the payload and the requiredBufferSize to push exceed the channel capacity, the channel is considered full.
- Parameters
-
[in] requiredBufferSize size of the token to push into the channel
- Returns
- true if there is enough space to push the token, false otherwise
◆ push()
|
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] sourceSlot Source slot (buffer) to copy into buffer [in] n Number of times to copy this sourceSlotinto 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:
- the channel at this locality is a consumer.
Payload copy.
We partition the payload buffer in 2 parts:
- payload buffer: it is the logical size of the buffer, and the channel will work as if a buffer of that size was passed as input
- excess buffer: extra space needed for the example described below. This can not be directly used from the outside, but is used by the channel to avoid fragmentation: we currently require the token to be pushed and peeked as a contiguous memory region
2 possible scenarios after the push:
1) we have space between the head and the end of the buffer 2) we do not have enough space ahead after the push, but we have it at the beginning of the buffer and their sum (i.e., channel capacity - channel depth) allows us to push the token.
If 2), we push to the excess buffer to avoid breaking the token in 2 chunks. The head is always pointing to a valid position in the buffer, meaning that when a push into the excess buffer is made, the logical position of the head behaves as if there were no excess buffer (See below). An excess buffer with the same size as the payload buffer guarantees that all kind of token size will succeed.
0 buffer capacity End of excess buffer TAIL HEAD1 |----—|-----—|----—|----------—|-------—| In this case HEAD1 indicates where the the token HEAD ends in the implementation, while HEAD is its logical position and observable value
◆ 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
Generated by
Public Member Functions inherited from