You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #48 from Algebraic-Programming/feat/channelExcessBuffer
Feat: channel excess buffer
Variable size SPSC channel:
- the payload is not split into chunks. We require the user to provide a bigger buffer (ideally double the capacity of the channel), and we use part of it to store entire tokens. The channel logic remains unchanged and it allows you to push only MAX_TOKENS * TOKEN_SIZE
- channels take into account both how many tokens are in the channel and the available space
- extended the isFull function to take a size_t and compute whether a push with such size can be made.
- add MPI tests for channel testing the following:
- a single push that fills the payload buffer
- a series of push that fills the payload buffer
- a series of push that fills the coordination buffer
- push-pop-push with a buffer big enough to force the second push to use the excess buffer
Copy file name to clipboardExpand all lines: include/hicr/frontends/channel/variableSize/spsc/consumer.hpp
+34-8Lines changed: 34 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,9 @@ class Consumer final : public variableSize::Base
49
49
*
50
50
* \param[in] coordinationCommunicationManager The backend's memory manager to facilitate communication between the producer and consumer coordination buffers
51
51
* \param[in] payloadCommunicationManager The backend's memory manager to facilitate communication between the producer and consumer payload buffers
52
-
* \param[in] payloadBuffer The memory slot pertaining to the payload buffer. The producer will push new tokens
53
-
* into this buffer, while there is enough space (in bytes). This buffer should be big enough to hold at least the
54
-
* largest message of the variable-sized messages to be pushed.
52
+
* \param[in] payloadBuffer The memory slot pertaining to the payload buffer. The producer will push messages into this
53
+
* buffer, while there is enough space. This buffer should be large enough to hold twice the capacity specified by payloadCapacity argument.
54
+
* Half of the buffer is used as excess buffer to avoid internal fragmentation of messages
55
55
* \param[in] tokenBuffer The memory slot pertaining to the token buffer. This buffer is only used to exchange internal metadata
56
56
* about the sizes of the individual messages being sent.
57
57
* \param[in] internalCoordinationBufferForCounts This is a small buffer to hold the internal (local) state of the
@@ -62,7 +62,7 @@ class Consumer final : public variableSize::Base
62
62
* buffer for message counts, used for remote updates on pop()
63
63
* \param[in] producerCoordinationBufferForPayloads A global reference to the producer channel's internal coordination
64
64
* buffer for payload sizes (in bytes), used for remote updates on pop()
65
-
* \param[in] payloadCapacity The capacity (in bytes) of the buffer for variable-sized messages
65
+
* \param[in] payloadCapacity The capacity (in bytes) of the buffer for variable-sized messages.
66
66
* \param[in] capacity The maximum number of tokens that will be held by this channel
67
67
* @note: The token size in var-size channels is used only internally, and is passed as having a type size_t (with size sizeof(size_t))
68
68
*/
@@ -243,23 +243,28 @@ class Consumer final : public variableSize::Base
243
243
* receiving the message counts (phase 2), returning this depth should guarantee
244
244
* we already have received the payloads
245
245
*
246
-
* \note This is not a thread-safe call
247
246
*
248
247
* This is a getter function that should complete in \f$ \Theta(1) \f$ time.
249
248
*
250
249
* @return The number of elements in variable-size consumer channel
250
+
*
251
+
* \note This is not a thread-safe call
252
+
* \note Even though there might be space for additional tokens in the coordination buffer, it is not guaranteed that
253
+
* the push() will succeed due to insufficient space in the payload buffer
0 commit comments