Skip to content

Commit

Permalink
Conditionally disable S/R algorithm unit tests
Browse files Browse the repository at this point in the history
The unit tests for the S/R versions of the parallel algorithms are only configured
if HPX_WITH_STDEXEC is enabled. Additionally, the tests cases that are in headers
shared with the non-S/R tests are surrounded with macro guards checking if stdexec
is available.
  • Loading branch information
zhekemist committed Aug 17, 2024
1 parent f8b1d95 commit 0fdc740
Show file tree
Hide file tree
Showing 37 changed files with 193 additions and 115 deletions.
122 changes: 64 additions & 58 deletions libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,44 @@ endforeach()
# add tests
set(tests
adjacentdifference
adjacentdifference_sender
adjacentfind
adjacentfind_binary
adjacentfind_sender
all_of
all_of_sender
any_of
any_of_sender
copy
copy_sender
copyif_random
copyif_forward
copyif_exception
copyif_bad_alloc
copyn
copyn_sender
count
count_sender
countif
countif_sender
destroy
destroy_sender
destroyn
destroyn_sender
distance
ends_with
ends_with_sender
equal
equal_binary
equal_sender
equal_binary_sender
exclusive_scan
exclusive_scan2
exclusive_scan_exception
exclusive_scan_bad_alloc
exclusive_scan_validate
fill
fill_sender
filln
filln_sender
find
find_sender
findend
findend_sender
findfirstof
findfirstof_binary
findfirstof_sender
findif
findif_sender
findifnot
findifnot_sender
foreach
foreach_executors
foreach_prefetching
foreach_sender
foreach_scheduler
foreachn
foreachn_exception
foreachn_bad_alloc
foreachn_sender
for_loop
for_loop_exception
for_loop_induction
Expand All @@ -88,78 +66,50 @@ set(tests
for_loop_reduction_async
for_loop_strided
generate
generate_sender
generaten
generaten_sender
is_heap
is_heap_sender
is_heap_until
is_heap_until_sender
includes
includes_sender
inclusive_scan
inclusive_scan_exception
inplace_merge
is_partitioned
is_partitioned_sender
is_sorted
is_sorted_sender
is_sorted_until
is_sorted_until_sender
lexicographical_compare
lexicographical_compare_sender
make_heap
max_element
max_element_sender
merge
min_element
min_element_sender
minmax_element
minmax_element_sender
mismatch
mismatch_binary
mismatch_sender
mismatch_binary_sender
move
move_sender
nth_element
none_of
none_of_sender
parallel_sort
partial_sort
partial_sort_copy
partition
partition_copy
reduce_
reduce_sender
reduce_by_key
remove
remove_sender
remove1
remove2
remove_if
remove_if_sender
remove_if1
remove_copy
remove_copy_if
replace
replace_sender
replace_if
replace_if_sender
replace_copy
replace_copy_sender
replace_copy_if
replace_copy_if_sender
reverse
reverse_copy
reverse_sender
reverse_copy_sender
rotate
rotate_copy
rotate_sender
rotate_copy_sender
search
search_sender
searchn
set_difference
set_intersection
Expand All @@ -174,23 +124,16 @@ set(tests
stable_sort
stable_sort_exceptions
starts_with
starts_with_sender
swapranges
swapranges_sender
transform
transform_sender
transform_binary
transform_binary_sender
transform_binary2
transform_binary2_sender
transform_exclusive_scan
transform_inclusive_scan
transform_reduce
transform_reduce_binary
transform_reduce_binary_exception
transform_reduce_binary_bad_alloc
transform_reduce_sender
transform_reduce_binary_sender
uninitialized_copy
uninitialized_copyn
uninitialized_default_construct
Expand All @@ -205,14 +148,77 @@ set(tests
uninitialized_value_construct
uninitialized_value_constructn
unique
unique_sender
unique_copy
)

if(HPX_WITH_CXX17_STD_EXECUTION_POLICES)
set(tests ${tests} foreach_std_policies)
endif()

if(HPX_WITH_STDEXEC)
set(tests
${tests}
adjacentdifference_sender
adjacentfind_sender
all_of_sender
any_of_sender
copy_sender
copyn_sender
count_sender
countif_sender
destroy_sender
destroyn_sender
ends_with_sender
equal_sender
equal_binary_sender
fill_sender
filln_sender
find_sender
findend_sender
findfirstof_sender
findif_sender
findifnot_sender
foreach_sender
foreachn_sender
generate_sender
generaten_sender
is_heap_sender
is_heap_until_sender
includes_sender
is_partitioned_sender
is_sorted_sender
is_sorted_until_sender
lexicographical_compare_sender
max_element_sender
min_element_sender
minmax_element_sender
mismatch_sender
mismatch_binary_sender
move_sender
none_of_sender
reduce_sender
remove_sender
remove_if_sender
replace_sender
replace_if_sender
replace_copy_sender
replace_copy_if_sender
reverse_sender
reverse_copy_sender
rotate_sender
rotate_copy_sender
search_sender
starts_with_sender
swapranges_sender
transform_sender
transform_binary_sender
transform_binary2_sender
transform_reduce_sender
transform_reduce_binary_sender
unique_sender
)
endif()

foreach(test ${tests})
set(sources ${test}.cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include <hpx/algorithm.hpp>
#include <hpx/config.hpp>
#include <hpx/execution.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/numeric.hpp>
Expand Down Expand Up @@ -68,6 +69,7 @@ void test_adjacent_difference_direct(Policy l, ExPolicy policy)
HPX_TEST(std::end(d) == it);
}

#if defined(HPX_HAVE_STDEXEC)
template <typename Policy, typename ExPolicy>
void test_adjacent_difference_sender(Policy l, ExPolicy&& policy)
{
Expand Down Expand Up @@ -117,6 +119,7 @@ void test_adjacent_difference_sender(Policy l, ExPolicy&& policy)
[](auto lhs, auto rhs) { return lhs == rhs; }));
HPX_TEST(++std::begin(d) == hpx::get<0>(*result));
}
#endif

template <typename ExPolicy>
void test_adjacent_difference_async(ExPolicy&& p)
Expand Down Expand Up @@ -155,14 +158,10 @@ void test_adjacent_difference_async_direct(Policy l, ExPolicy&& p)
using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;

auto exec = ex::explicit_scheduler_executor(scheduler_t(l));
#ifdef HPX_HAVE_STDEXEC

auto result = tt::sync_wait(hpx::adjacent_difference(
p.on(exec), std::begin(c), std::end(c), std::begin(d)));
#else
auto result = hpx::adjacent_difference(
p.on(exec), std::begin(c), std::end(c), std::begin(d)) |
tt::sync_wait();
#endif

std::adjacent_difference(std::begin(c), std::end(c), std::begin(d_ans));

HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <hpx/algorithm.hpp>
#include <hpx/config.hpp>
#include <hpx/init.hpp>
#include <hpx/modules/testing.hpp>

Expand Down Expand Up @@ -52,6 +53,7 @@ void test_adjacent_find(ExPolicy policy, IteratorTag)
HPX_TEST(index == iterator(test_index));
}

#if defined(HPX_HAVE_STDEXEC)
template <typename LnPolicy, typename ExPolicy, typename IteratorTag>
void test_adjacent_find_sender(
LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
Expand Down Expand Up @@ -93,6 +95,7 @@ void test_adjacent_find_sender(

HPX_TEST(iterator(std::begin(c)) == hpx::get<0>(*snd_result));
}
#endif

template <typename ExPolicy, typename IteratorTag>
void test_adjacent_find_async(ExPolicy p, IteratorTag)
Expand Down
3 changes: 3 additions & 0 deletions libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#pragma once

#include <hpx/config.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/parallel/algorithms/all_any_none.hpp>
#include <hpx/parallel/container_algorithms/all_any_none.hpp>
Expand Down Expand Up @@ -67,6 +68,7 @@ void test_all_of(ExPolicy&& policy, IteratorTag)
}
}

#if defined(HPX_HAVE_STDEXEC)
template <typename LnPolicy, typename ExPolicy, typename IteratorTag>
void test_all_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
{
Expand Down Expand Up @@ -101,6 +103,7 @@ void test_all_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
HPX_TEST_EQ(result, expected);
}
}
#endif

template <typename IteratorTag, typename Proj = hpx::identity>
void test_all_of_ranges_seq(IteratorTag, Proj proj = Proj())
Expand Down
3 changes: 3 additions & 0 deletions libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <hpx/algorithm.hpp>
#include <hpx/config.hpp>
#include <hpx/init.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/type_support/identity.hpp>
Expand Down Expand Up @@ -67,6 +68,7 @@ void test_any_of(ExPolicy&& policy, IteratorTag)
}
}

#if defined(HPX_HAVE_STDEXEC)
template <typename LnPolicy, typename ExPolicy, typename IteratorTag>
void test_any_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
{
Expand Down Expand Up @@ -102,6 +104,7 @@ void test_any_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
HPX_TEST_EQ(result, expected);
}
}
#endif

template <typename IteratorTag, typename Proj = hpx::identity>
void test_any_of_ranges_seq(IteratorTag, Proj proj = Proj())
Expand Down
3 changes: 3 additions & 0 deletions libs/core/algorithms/tests/unit/algorithms/copy_tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include <hpx/config.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/parallel/algorithms/copy.hpp>

Expand Down Expand Up @@ -70,6 +71,7 @@ void test_copy(ExPolicy&& policy, IteratorTag)
HPX_TEST_EQ(count, d.size());
}

#if defined(HPX_HAVE_STDEXEC)
template <typename LnPolicy, typename ExPolicy, typename IteratorTag>
void test_copy_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
{
Expand Down Expand Up @@ -103,6 +105,7 @@ void test_copy_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag)
}));
HPX_TEST_EQ(count, d.size());
}
#endif

template <typename ExPolicy, typename IteratorTag>
void test_copy_async(ExPolicy&& p, IteratorTag)
Expand Down
Loading

0 comments on commit 0fdc740

Please sign in to comment.