Skip to content

Commit c1a2e50

Browse files
committed
Adapting HPX contracts module to C++ modules
- fixing remaining CI failures Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
1 parent 0308e0e commit c1a2e50

6 files changed

Lines changed: 33 additions & 28 deletions

File tree

libs/core/async_mpi/include/hpx/async_mpi/mpi_future.hpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace hpx::mpi::experimental {
4444

4545
// by convention the title is 7 chars (for alignment)
4646
HPX_CXX_EXPORT using print_on = debug::enable_print<false>;
47-
HPX_CXX_EXPORT static constexpr print_on mpi_debug("MPI_FUT");
47+
HPX_CXX_EXPORT inline constexpr print_on mpi_debug("MPI_FUT");
4848

4949
namespace detail {
5050

@@ -59,7 +59,10 @@ namespace hpx::mpi::experimental {
5959
// An implementation of future_data for MPI
6060
HPX_CXX_EXPORT struct future_data : hpx::lcos::detail::future_data<int>
6161
{
62-
HPX_NON_COPYABLE(future_data);
62+
future_data(future_data const&) = delete;
63+
future_data(future_data&&) = delete;
64+
future_data& operator=(future_data const&) = delete;
65+
future_data& operator=(future_data&&) = delete;
6366

6467
using init_no_addref =
6568
typename hpx::lcos::detail::future_data<int>::init_no_addref;
@@ -112,7 +115,7 @@ namespace hpx::mpi::experimental {
112115

113116
// -----------------------------------------------------------------
114117
// a convenience structure to hold state vars
115-
// used extensivey with debug::print to display rank etc
118+
// used extensively with debug::print to display rank etc
116119
HPX_CXX_EXPORT struct mpi_info
117120
{
118121
bool error_handler_initialized_ = false;
@@ -141,28 +144,20 @@ namespace hpx::mpi::experimental {
141144
MPI_Comm*, int* errorcode, ...);
142145

143146
// -----------------------------------------------------------------
144-
// we track requests and callbacks in two vectors even though
145-
// we have the request stored in the request_callback vector already
146-
// the reason for this is because we can use MPI_Testany
147-
// with a vector of requests to save overheads compared
148-
// to testing one by one every item (using a list)
147+
// we track requests and callbacks in two vectors even though we have
148+
// the request stored in the request_callback vector already the reason
149+
// for this is we can use MPI_Testany with a vector of requests to save
150+
// overheads compared to testing one by one every item (using a list)
149151
HPX_CXX_EXPORT HPX_CORE_EXPORT std::vector<MPI_Request>&
150152
get_requests_vector();
151153

152154
// -----------------------------------------------------------------
153155
// define a lockfree queue type to place requests in prior to handling
154156
// this is done only to avoid taking a lock every time a request is
155-
// returned from MPI. Instead the requests are placed into a queue
156-
// and the polling code pops them prior to calling Testany
157+
// returned from MPI. Instead, the requests are placed into a queue
158+
// and the polling code pops them prior to calling Testany.
157159
HPX_CXX_EXPORT using queue_type =
158160
concurrency::ConcurrentQueue<future_data_ptr>;
159-
160-
// -----------------------------------------------------------------
161-
// used internally to query how many requests are 'in flight'
162-
// these are requests that are being polled for actively
163-
// and not the same as the requests enqueued
164-
HPX_CXX_EXPORT HPX_CORE_EXPORT std::size_t
165-
get_number_of_active_requests();
166161
} // namespace detail
167162

168163
// -----------------------------------------------------------------

libs/core/contracts/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ if(HPX_WITH_CXX26_CONTRACTS)
2424
endif()
2525

2626
# Default location is $HPX_ROOT/libs/contracts/include
27-
set(contracts_headers hpx/contracts.hpp hpx/modules/contracts.hpp)
27+
set(contracts_headers hpx/contracts.hpp hpx/contracts/macros.hpp)
28+
set(contracts_macro_headers hpx/contracts/macros.hpp)
2829

2930
# Default location is $HPX_ROOT/libs/contracts/src
3031
set(contracts_sources)
3132

3233
include(HPX_AddModule)
3334
add_hpx_module(
3435
core contracts
35-
GLOBAL_HEADER_GEN OFF
36+
GLOBAL_HEADER_GEN ON
37+
GLOBAL_HEADER_MODULE_GEN ON
3638
SOURCES ${contracts_sources}
3739
HEADERS ${contracts_headers}
40+
MACRO_HEADERS ${contracts_macro_headers}
3841
COMPAT_HEADERS ${contracts_compat_headers}
3942
MODULE_DEPENDENCIES hpx_config hpx_preprocessor hpx_assertion
4043
CMAKE_SUBDIRS examples tests

libs/core/contracts/include/hpx/modules/contracts.hpp renamed to libs/core/contracts/include/hpx/contracts/macros.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#if defined(HPX_CONTRACTS_HAVE_ASSERTS_AS_CONTRACT_ASSERTS)
4040
// Override HPX_ASSERT to use contract assertions
41+
#undef HPX_ASSERT
4142
#define HPX_ASSERT(x) contract_assert(x)
4243
#endif
4344

libs/core/contracts/tests/unit/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ foreach(test ${contract_tests})
2929
add_hpx_unit_test("modules.contracts" ${test})
3030
endforeach()
3131

32+
# Set failure expectation for fallback failure test Fallback only fails in Debug
33+
# mode (HPX_ASSERT or HPX_CONTRACT_ASSERT behavior)
34+
set_tests_properties(
35+
tests.unit.modules.contracts.declaration_contracts_fail_contract_assert
36+
PROPERTIES WILL_FAIL $<$<CONFIG:Debug>:ON>
37+
)
38+
3239
if(HPX_HAVE_CXX26_CONTRACTS)
3340
# Set failure expectations for declaration contract failure tests Native
3441
# contracts should fail when violated
@@ -40,11 +47,6 @@ if(HPX_HAVE_CXX26_CONTRACTS)
4047
tests.unit.modules.contracts.declaration_contracts_fail_post
4148
PROPERTIES WILL_FAIL ON
4249
)
43-
set_tests_properties(
44-
tests.unit.modules.contracts.declaration_contracts_fail_contract_assert
45-
PROPERTIES WILL_FAIL $<$<CONFIG:Debug>:ON>
46-
)
47-
4850
else()
4951
# Set failure expectation for fallback failure test Fallback only fails in
5052
# Debug mode (HPX_ASSERT behavior)

libs/core/contracts/tests/unit/declaration_contracts_fail_post.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ int get_positive_number(int) HPX_POST(r : r > 0)
2020

2121
int main()
2222
{
23-
// This should trigger postcondition violation when __cpp_contracts is available
24-
return get_positive_number(5);
23+
// This should trigger postcondition violation when __cpp_contracts is
24+
// available
25+
[[maybe_unused]] int result = get_positive_number(5);
26+
return 0;
2527
}

libs/core/contracts/tests/unit/declaration_contracts_fail_pre.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ int multiply_positive(int const x) HPX_PRE(x > 0)
2020

2121
int main()
2222
{
23-
// This should trigger precondition violation when __cpp_contracts is available
24-
return multiply_positive(-5); // Violates x > 0
23+
// This should trigger precondition violation when __cpp_contracts is
24+
// available
25+
[[maybe_unused]] int result = multiply_positive(-5); // Violates x > 0
26+
return 0;
2527
}

0 commit comments

Comments
 (0)