Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2301 Add cmake flags to build experimental 32-64 …
Browse files Browse the repository at this point in the history
…bit mix mode
  • Loading branch information
elBoberido committed Sep 23, 2024
1 parent bbc5f04 commit 1d86469
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 40 deletions.
2 changes: 2 additions & 0 deletions iceoryx_meta/build_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(THREAD_SANITIZER "Build with thread sanitizer" OFF)
option(TEST_WITH_ADDITIONAL_USER "Build Test with additional user accounts for testing access control" OFF)
option(TEST_WITH_HUGE_PAYLOAD "Build Tests which use payload bigger than 2GB" OFF)
option(TOML_CONFIG "TOML support for RouDi with dynamic configuration" ON)
option(IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE "Enable experimental 32<->64 bit mix mode zero-copy communication" OFF)
option(IOX_EXPERIMENTAL_POSH "Export experimental posh features (no guarantees)" OFF)
option(IOX_REPRODUCIBLE_BUILD "Create reproducible builds by omit setting the build timestamp in the version header" ON)

Expand Down Expand Up @@ -95,6 +96,7 @@ function(show_config_options)
message(" TEST_WITH_ADDITIONAL_USER ...........: " ${TEST_WITH_ADDITIONAL_USER})
message(" TEST_WITH_HUGE_PAYLOAD ..............: " ${TEST_WITH_HUGE_PAYLOAD})
message(" TOML_CONFIG..........................: " ${TOML_CONFIG})
message(" IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE..: " ${IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE})
message(" IOX_EXPERIMENTAL_POSH................: " ${IOX_EXPERIMENTAL_POSH})
message(" IOX_REPRODUCIBLE_BUILD...............: " ${IOX_REPRODUCIBLE_BUILD})
endfunction()
2 changes: 2 additions & 0 deletions iceoryx_posh/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ configure_file(
"@platforms//os:macos": {
"IOX_COMMUNICATION_POLICY": "ManyToManyPolicy",
"IOX_DEFAULT_RESOURCE_PREFIX": "iox1",
"IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE": "false",
"IOX_EXPERIMENTAL_POSH_FLAG": "false",
"IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY": "8",
"IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY": "256",
Expand Down Expand Up @@ -57,6 +58,7 @@ configure_file(
"//conditions:default": {
"IOX_COMMUNICATION_POLICY": "ManyToManyPolicy",
"IOX_DEFAULT_RESOURCE_PREFIX": "iox1",
"IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE": "false",
"IOX_EXPERIMENTAL_POSH_FLAG": "false",
"IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY": "8",
"IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY": "256",
Expand Down
9 changes: 9 additions & 0 deletions iceoryx_posh/cmake/IceoryxPoshDeployment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ if(IOX_EXPERIMENTAL_POSH)
else()
set(IOX_EXPERIMENTAL_POSH_FLAG false)
endif()

if(IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE)
set(IOX_INTERPROCESS_LOCK concurrent::SpinLock)
set(IOX_INTERPROCESS_SEMAPHORE concurrent::SpinSemaphore)
else()
set(IOX_INTERPROCESS_LOCK mutex)
set(IOX_INTERPROCESS_SEMAPHORE UnnamedSemaphore)
endif()

message(STATUS "[i] IOX_EXPERIMENTAL_POSH_FLAG: ${IOX_EXPERIMENTAL_POSH_FLAG}")

message(STATUS "[i] <<<<<<<<<<<<<< End iceoryx_posh configuration: >>>>>>>>>>>>>>")
Expand Down
57 changes: 35 additions & 22 deletions iceoryx_posh/cmake/iceoryx_posh_deployment.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@

namespace iox
{
class mutex;
class UnnamedSemaphore;
namespace concurrent
{
class SpinLock;
class SpinSemaphore;
}
namespace build
{
using InterProcessLock = @IOX_INTERPROCESS_LOCK@;
using InterProcessSemaphore = @IOX_INTERPROCESS_SEMAPHORE@;
}

namespace popo
{
class SubscriberPortSingleProducer;
Expand All @@ -46,28 +59,28 @@ constexpr uint32_t IOX_MAX_CHUNKS_ALLOCATED_PER_PUBLISHER_SIMULTANEOUSLY =
constexpr uint64_t IOX_MAX_PUBLISHER_HISTORY = static_cast<uint32_t>(@IOX_MAX_PUBLISHER_HISTORY@);
constexpr uint32_t IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY =
static_cast<uint32_t>(@IOX_MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY@);
constexpr uint32_t IOX_MAX_NUMBER_OF_NOTIFIERS = static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_NOTIFIERS@);
constexpr uint32_t IOX_MAX_PROCESS_NUMBER = static_cast<uint32_t>(@IOX_MAX_PROCESS_NUMBER@);
// NOTE: this is currently only used in the experimental API and corresponds to 'IOX_MAX_PROCESS_NUMBER'
// due to a limitation in the 'PointerRepository'
constexpr uint32_t IOX_MAX_NODE_NUMBER = static_cast<uint32_t>(@IOX_MAX_NODE_NUMBER@);
// NOTE: this is currently set to 1 due to the limitation in the 'PointerRepository'
constexpr uint32_t IOX_MAX_NODE_PER_PROCESS = static_cast<uint32_t>(@IOX_MAX_NODE_PER_PROCESS@);
constexpr uint32_t IOX_MAX_SHM_SEGMENTS = static_cast<uint32_t>(@IOX_MAX_SHM_SEGMENTS@);
constexpr uint32_t IOX_MAX_NUMBER_OF_MEMPOOLS = static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_MEMPOOLS@);
constexpr uint32_t IOX_MAX_NUMBER_OF_CONDITION_VARIABLES =
static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_CONDITION_VARIABLES@);
constexpr uint32_t IOX_MAX_NODE_NAME_LENGTH = static_cast<uint32_t>(@IOX_MAX_NODE_NAME_LENGTH@);
constexpr uint32_t IOX_MAX_ID_STRING_LENGTH = static_cast<uint32_t>(@IOX_MAX_ID_STRING_LENGTH@);
constexpr uint32_t IOX_MAX_RUNTIME_NAME_LENGTH = static_cast<uint32_t>(@IOX_MAX_RUNTIME_NAME_LENGTH@);
constexpr uint32_t IOX_MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY =
static_cast<uint32_t>(@IOX_MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY@);
constexpr uint32_t IOX_MAX_RESPONSE_QUEUE_CAPACITY = static_cast<uint32_t>(@IOX_MAX_RESPONSE_QUEUE_CAPACITY@);
constexpr uint32_t IOX_MAX_REQUEST_QUEUE_CAPACITY = static_cast<uint32_t>(@IOX_MAX_REQUEST_QUEUE_CAPACITY@);
constexpr uint32_t IOX_MAX_CLIENTS_PER_SERVER = static_cast<uint32_t>(@IOX_MAX_CLIENTS_PER_SERVER@);
constexpr uint32_t IOX_MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY = static_cast<uint32_t>(@IOX_MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY@);
constexpr const char IOX_DEFAULT_RESOURCE_PREFIX[] = "@IOX_DEFAULT_RESOURCE_PREFIX@";
constexpr bool IOX_EXPERIMENTAL_POSH_FLAG = @IOX_EXPERIMENTAL_POSH_FLAG@;
constexpr uint32_t IOX_MAX_NUMBER_OF_NOTIFIERS = static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_NOTIFIERS@);
constexpr uint32_t IOX_MAX_PROCESS_NUMBER = static_cast<uint32_t>(@IOX_MAX_PROCESS_NUMBER@);
// NOTE: this is currently only used in the experimental API and corresponds to 'IOX_MAX_PROCESS_NUMBER'
// due to a limitation in the 'PointerRepository'
constexpr uint32_t IOX_MAX_NODE_NUMBER = static_cast<uint32_t>(@IOX_MAX_NODE_NUMBER@);
// NOTE: this is currently set to 1 due to the limitation in the 'PointerRepository'
constexpr uint32_t IOX_MAX_NODE_PER_PROCESS = static_cast<uint32_t>(@IOX_MAX_NODE_PER_PROCESS@);
constexpr uint32_t IOX_MAX_SHM_SEGMENTS = static_cast<uint32_t>(@IOX_MAX_SHM_SEGMENTS@);
constexpr uint32_t IOX_MAX_NUMBER_OF_MEMPOOLS = static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_MEMPOOLS@);
constexpr uint32_t IOX_MAX_NUMBER_OF_CONDITION_VARIABLES =
static_cast<uint32_t>(@IOX_MAX_NUMBER_OF_CONDITION_VARIABLES@);
constexpr uint32_t IOX_MAX_NODE_NAME_LENGTH = static_cast<uint32_t>(@IOX_MAX_NODE_NAME_LENGTH@);
constexpr uint32_t IOX_MAX_ID_STRING_LENGTH = static_cast<uint32_t>(@IOX_MAX_ID_STRING_LENGTH@);
constexpr uint32_t IOX_MAX_RUNTIME_NAME_LENGTH = static_cast<uint32_t>(@IOX_MAX_RUNTIME_NAME_LENGTH@);
constexpr uint32_t IOX_MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY =
static_cast<uint32_t>(@IOX_MAX_RESPONSES_PROCESSED_SIMULTANEOUSLY@);
constexpr uint32_t IOX_MAX_RESPONSE_QUEUE_CAPACITY = static_cast<uint32_t>(@IOX_MAX_RESPONSE_QUEUE_CAPACITY@);
constexpr uint32_t IOX_MAX_REQUEST_QUEUE_CAPACITY = static_cast<uint32_t>(@IOX_MAX_REQUEST_QUEUE_CAPACITY@);
constexpr uint32_t IOX_MAX_CLIENTS_PER_SERVER = static_cast<uint32_t>(@IOX_MAX_CLIENTS_PER_SERVER@);
constexpr uint32_t IOX_MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY = static_cast<uint32_t>(@IOX_MAX_REQUESTS_PROCESSED_SIMULTANEOUSLY@);
constexpr const char IOX_DEFAULT_RESOURCE_PREFIX[] = "@IOX_DEFAULT_RESOURCE_PREFIX@";
constexpr bool IOX_EXPERIMENTAL_POSH_FLAG = @IOX_EXPERIMENTAL_POSH_FLAG@;
// clang-format on
} // namespace build
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_DATA_HPP
#define IOX_POSH_POPO_BUILDING_BLOCKS_CONDITION_VARIABLE_DATA_HPP

#include "iceoryx_posh/iceoryx_posh_deployment.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/internal/posh_error_reporting.hpp"
#include "iox/atomic.hpp"
Expand All @@ -27,12 +28,6 @@ namespace iox
{
namespace popo
{
#ifdef IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE
using InterProcessSemaphore = concurrent::SpinSemaphore;
#else
using InterProcessSemaphore = UnnamedSemaphore;
#endif

struct ConditionVariableData
{
ConditionVariableData() noexcept;
Expand All @@ -44,7 +39,7 @@ struct ConditionVariableData
ConditionVariableData& operator=(ConditionVariableData&& rhs) = delete;
~ConditionVariableData() noexcept = default;

optional<InterProcessSemaphore> m_semaphore;
optional<build::InterProcessSemaphore> m_semaphore;
RuntimeName_t m_runtimeName;
concurrent::Atomic<bool> m_toBeDestroyed{false};
concurrent::Atomic<bool> m_activeNotifications[MAX_NUMBER_OF_NOTIFIERS];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@
#ifndef IOX_POSH_POPO_BUILDING_BLOCKS_LOCKING_POLICY_HPP
#define IOX_POSH_POPO_BUILDING_BLOCKS_LOCKING_POLICY_HPP

#include "iceoryx_posh/iceoryx_posh_deployment.hpp"
#include "iox/mutex.hpp"
#include "iox/spin_lock.hpp"

namespace iox
{
namespace popo
{
#ifdef IOX_EXPERIMENTAL_32_64_BIT_MIX_MODE
using InterProcessLock = concurrent::SpinLock;
#else
using InterProcessLock = mutex;
#endif

class ThreadSafePolicy
{
public:
Expand All @@ -40,7 +35,7 @@ class ThreadSafePolicy
bool tryLock() const noexcept;

private:
mutable optional<InterProcessLock> m_lock;
mutable optional<build::InterProcessLock> m_lock;
};

class SingleThreadedPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ ConditionVariableData::ConditionVariableData() noexcept
ConditionVariableData::ConditionVariableData(const RuntimeName_t& runtimeName) noexcept
: m_runtimeName(runtimeName)
{
InterProcessSemaphore::Builder().initialValue(0U).isInterProcessCapable(true).create(m_semaphore).or_else([](auto) {
IOX_REPORT_FATAL(PoshError::POPO__CONDITION_VARIABLE_DATA_FAILED_TO_CREATE_SEMAPHORE);
});
build::InterProcessSemaphore::Builder()
.initialValue(0U)
.isInterProcessCapable(true)
.create(m_semaphore)
.or_else([](auto) { IOX_REPORT_FATAL(PoshError::POPO__CONDITION_VARIABLE_DATA_FAILED_TO_CREATE_SEMAPHORE); });

for (auto& id : m_activeNotifications)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace popo
{
ThreadSafePolicy::ThreadSafePolicy() noexcept
{
InterProcessLock::Builder()
build::InterProcessLock::Builder()
.is_inter_process_capable(true)
.lock_behavior(LockBehavior::RECURSIVE)
.create(m_lock)
Expand Down
9 changes: 9 additions & 0 deletions tools/iceoryx_build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ TEST_HUGE_PAYLOAD="OFF"
OUT_OF_TREE_FLAG="OFF"
EXAMPLE_FLAG="OFF"
EXPERIMENTAL_FLAG="OFF"
EXPERIMENTAL_32_64_MIX_MODE_FLAG="OFF"
BUILD_ALL_FLAG="OFF"
BUILD_SHARED="OFF"
TOML_FLAG="ON"
Expand Down Expand Up @@ -170,6 +171,11 @@ while (( "$#" )); do
EXPERIMENTAL_FLAG="ON"
shift 1
;;
"experimental-32-64-bit-mix-mode")
echo " [i] Build experimental 32<->64 bit mix mode zero-copy communication"
EXPERIMENTAL_32_64_MIX_MODE_FLAG="ON"
shift 1
;;
"out-of-tree")
echo " [i] Out-of-tree build"
OUT_OF_TREE_FLAG="ON"
Expand Down Expand Up @@ -253,6 +259,8 @@ while (( "$#" )); do
echo " doc Build and generate doxygen"
echo " help Print this help"
echo " examples Build all examples"
echo " experimental Build experimental features"
echo " experimental-32-64-bit-mix-mode Enable experimental 32<->64 bit mix mode zero-copy communication"
echo " one-to-many-only Restrict to 1:n communication only"
echo " out-of-tree Out-of-tree build for CI"
echo " package Create a debian package from clean build in build_package"
Expand Down Expand Up @@ -331,6 +339,7 @@ if [ "$NO_BUILD" == false ]; then
-DROUDI_ENVIRONMENT=$ROUDI_ENV_FLAG \
-DEXAMPLES=$EXAMPLE_FLAG \
-DIOX_EXPERIMENTAL_POSH=$EXPERIMENTAL_FLAG \
-DIOX_EXPERIMENTAL_32_64_BIT_MIX_MODE=$EXPERIMENTAL_32_64_MIX_MODE_FLAG \
-DTOML_CONFIG=$TOML_FLAG \
-DBUILD_DOC=$BUILD_DOC \
-DBINDING_C=$BINDING_C_FLAG \
Expand Down

0 comments on commit 1d86469

Please sign in to comment.