Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/channels/variableSize/spsc/include/consumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void consumerFc(HiCR::MemoryManager &coordinationMemoryManager,
auto sizesBufferSlot = coordinationMemoryManager.allocateLocalMemorySlot(coordinationMemorySpace, sizesBufferSize);

// Allocating payload buffer as a local memory slot
auto payloadBufferSlot = payloadMemoryManager.allocateLocalMemorySlot(payloadMemorySpace, PAYLOAD_CAPACITY * 2);
auto payloadBufferSlot = payloadMemoryManager.allocateLocalMemorySlot(payloadMemorySpace, HiCR::channel::variableSize::SPSC::Consumer::getPayloadBufferSize(PAYLOAD_CAPACITY));

// Getting required buffer size
auto coordinationBufferSize = HiCR::channel::variableSize::Base::getCoordinationBufferSize();
Expand Down
6 changes: 3 additions & 3 deletions include/hicr/backends/pthreads/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class Core
/**
* Constructor
*
* \param[in] fenceCount barrier size. Indicates how many threads should reach the barrier before continuing
* \param[in] instanceCount how many instances will be in the application
*/
Core(const size_t fenceCount)
: _fenceCount(fenceCount),
Core(const size_t instanceCount)
: _fenceCount(instanceCount),
_currentInstanceId(0)
{
// Init barrier
Expand Down
10 changes: 10 additions & 0 deletions include/hicr/frontends/channel/variableSize/spsc/consumer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ class Consumer final : public variableSize::Base
return bufferPos;
}

/**
* This function can be used to check the size of the payload buffer that needs to be provided
* in the creation of the channel. The returned size might differ based on the specific channle implementation
*
* \param[in] payloadSize the desired payload buffer size
*
* \return Size (bytes) of the payload buffer
*/
__INLINE__ static size_t getPayloadBufferSize(const size_t payloadSize) noexcept { return payloadSize * 2; }

/**
* This function gets the (starting position, size) pair for a given element in the consumer channel
* @param[in] pos The payload position required. \p pos = 0 indicates earliest payload that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class ChannelFixture : public ::testing::Test
auto sizesBufferSlot = coordinationMemoryManager.allocateLocalMemorySlot(coordinationMemorySpace, sizesBufferSize);

// Allocating payload buffer as a local memory slot
auto payloadBufferSlot = payloadMemoryManager.allocateLocalMemorySlot(payloadMemorySpace, 2 * CHANNEL_CAPACITY * sizeof(ELEMENT_TYPE));
auto payloadBufferSlot =
payloadMemoryManager.allocateLocalMemorySlot(payloadMemorySpace, HiCR::channel::variableSize::SPSC::Consumer::getPayloadBufferSize(CHANNEL_CAPACITY * sizeof(ELEMENT_TYPE)));

// Getting required buffer size
auto coordinationBufferSize = HiCR::channel::variableSize::Base::getCoordinationBufferSize();
Expand Down