From c32f493ab452117d1ecaa223d7b14299ee7818d3 Mon Sep 17 00:00:00 2001 From: Luca Terracciano Date: Fri, 24 Oct 2025 12:37:52 +0200 Subject: [PATCH 1/2] refactor: rename fenceCount to instanceCount --- include/hicr/backends/pthreads/core.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hicr/backends/pthreads/core.hpp b/include/hicr/backends/pthreads/core.hpp index 61e73455..b8f258dc 100644 --- a/include/hicr/backends/pthreads/core.hpp +++ b/include/hicr/backends/pthreads/core.hpp @@ -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 From cd1a84ad446825986b40432b74ee33911d9cce95 Mon Sep 17 00:00:00 2001 From: Luca Terracciano Date: Fri, 24 Oct 2025 12:37:56 +0200 Subject: [PATCH 2/2] feat: add helperfunction to compute payload buffer size in var size spsc channel --- .../channels/variableSize/spsc/include/consumer.hpp | 2 +- .../frontends/channel/variableSize/spsc/consumer.hpp | 10 ++++++++++ .../variableSize/spsc/include/channelFixture.hpp | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/channels/variableSize/spsc/include/consumer.hpp b/examples/channels/variableSize/spsc/include/consumer.hpp index 8b4ee68f..19a8b58b 100644 --- a/examples/channels/variableSize/spsc/include/consumer.hpp +++ b/examples/channels/variableSize/spsc/include/consumer.hpp @@ -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(); diff --git a/include/hicr/frontends/channel/variableSize/spsc/consumer.hpp b/include/hicr/frontends/channel/variableSize/spsc/consumer.hpp index 457e7948..737e9980 100644 --- a/include/hicr/frontends/channel/variableSize/spsc/consumer.hpp +++ b/include/hicr/frontends/channel/variableSize/spsc/consumer.hpp @@ -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 diff --git a/tests/frontends/channel/variableSize/spsc/include/channelFixture.hpp b/tests/frontends/channel/variableSize/spsc/include/channelFixture.hpp index 39490226..6361efa6 100644 --- a/tests/frontends/channel/variableSize/spsc/include/channelFixture.hpp +++ b/tests/frontends/channel/variableSize/spsc/include/channelFixture.hpp @@ -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();