Skip to content

Commit

Permalink
Reenable disabled tests for stdexec that are now working
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed May 9, 2023
1 parent 597de07 commit 4a82ae8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 111 deletions.
4 changes: 0 additions & 4 deletions libs/pika/execution/tests/unit/algorithm_ensure_started.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ int main()
PIKA_TEST(set_value_called);
}

// stdexec still requires copyable senders (see issue
// https://github.com/NVIDIA/stdexec/issues/641).
#if !defined(PIKA_HAVE_STDEXEC)
{
std::atomic<bool> set_value_called{false};
std::atomic<bool> started{false};
Expand Down Expand Up @@ -107,7 +104,6 @@ int main()
ex::start(os);
PIKA_TEST(set_value_called);
}
#endif

// operator| overload
{
Expand Down
3 changes: 0 additions & 3 deletions libs/pika/execution/tests/unit/algorithm_just.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ int main()
PIKA_TEST(set_value_called);
}

// TODO: The reference implementation does not ADL-isolate the just-sender.
#if !defined(PIKA_HAVE_STDEXEC)
test_adl_isolation(ex::just(my_namespace::my_type{}));
#endif

return 0;
}
3 changes: 0 additions & 3 deletions libs/pika/execution/tests/unit/algorithm_start_detached.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ int main()
PIKA_TEST(!tag_invoke_overload_called);
}

// Piping into start_detached is not allowed according to the specification.
#if !defined(PIKA_HAVE_STDEXEC)
// operator| overload
{
std::atomic<bool> start_called{false};
Expand All @@ -89,7 +87,6 @@ int main()
PIKA_TEST(connect_called);
PIKA_TEST(!tag_invoke_overload_called);
}
#endif

// tag_invoke overload
{
Expand Down
6 changes: 4 additions & 2 deletions libs/pika/execution_base/tests/unit/any_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,10 @@ struct wait_globals

void test_globals()
{
// TODO: No ensure_started implementation in reference implementation.
#if !defined(PIKA_HAVE_STDEXEC)
// No implementation of unique_any_sender in stdexec
#if defined(PIKA_HAVE_STDEXEC)
global_any_sender = std::move(global_any_sender) | ex::ensure_started() | ex::split();
#else
global_unique_any_sender = std::move(global_unique_any_sender) | ex::ensure_started();
global_any_sender = std::move(global_any_sender) | ex::ensure_started() | ex::split();
#endif
Expand Down
67 changes: 15 additions & 52 deletions libs/pika/executors/tests/unit/std_thread_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,27 +556,16 @@ void test_when_all_vector()

auto when1 = ex::when_all_vector(std::move(senders));

#if !defined(PIKA_HAVE_STDEXEC)
bool executed{false};
#endif
tt::sync_wait(std::move(when1)
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([parent_id, &executed](std::vector<double> v) {
PIKA_TEST_NEQ(parent_id, std::this_thread::get_id());
PIKA_TEST_EQ(v.size(), std::size_t(3));
PIKA_TEST_EQ(v[0], 42.0);
PIKA_TEST_EQ(v[1], 43.0);
PIKA_TEST_EQ(v[2], 3.14);
executed = true;
})
#endif
);
#if !defined(PIKA_HAVE_STDEXEC)
tt::sync_wait(std::move(when1) | ex::then([parent_id, &executed](std::vector<double> v) {
PIKA_TEST_NEQ(parent_id, std::this_thread::get_id());
PIKA_TEST_EQ(v.size(), std::size_t(3));
PIKA_TEST_EQ(v[0], 42.0);
PIKA_TEST_EQ(v[1], 43.0);
PIKA_TEST_EQ(v[2], 3.14);
executed = true;
}));
PIKA_TEST(executed);
#endif
}

{
Expand All @@ -601,14 +590,8 @@ void test_when_all_vector()

try
{
tt::sync_wait(ex::when_all_vector(std::move(senders))
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([](std::vector<int>) { PIKA_TEST(false); })
#endif
);
tt::sync_wait(ex::when_all_vector(std::move(senders)) |
ex::then([](std::vector<int>) { PIKA_TEST(false); }));
PIKA_TEST(false);
}
catch (std::runtime_error const& e)
Expand Down Expand Up @@ -642,14 +625,8 @@ void test_when_all_vector()

try
{
tt::sync_wait(ex::when_all_vector(std::move(senders))
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([](std::vector<int>) { PIKA_TEST(false); })
#endif
);
tt::sync_wait(ex::when_all_vector(std::move(senders)) |
ex::then([](std::vector<int>) { PIKA_TEST(false); }));
PIKA_TEST(false);
}
catch (std::runtime_error const& e)
Expand Down Expand Up @@ -680,16 +657,13 @@ void test_ensure_started()
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}

// TODO: The split sender in stdexec is not copyable.
#if !defined(PIKA_HAVE_STDEXEC)
{
auto s = ex::transfer_just(sched, 42) | ex::ensure_started() | ex::split();
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}
#endif

// It's allowed to discard the sender from ensure_started
{
Expand All @@ -699,8 +673,6 @@ void test_ensure_started()

void test_ensure_started_when_all()
{
// TODO: The split sender in stdexec is not copyable.
#if !defined(PIKA_HAVE_STDEXEC)
ex::std_thread_scheduler sched{};

{
Expand Down Expand Up @@ -801,13 +773,10 @@ void test_ensure_started_when_all()
PIKA_TEST_EQ(first_task_calls, std::size_t(1));
PIKA_TEST_EQ(successor_task_calls, std::size_t(2));
}
#endif
}

void test_split()
{
// TODO: No default implementation in stdexec.
#if !defined(PIKA_HAVE_STDEXEC)
ex::std_thread_scheduler sched{};

{
Expand All @@ -831,13 +800,10 @@ void test_split()
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}
#endif
}

void test_split_when_all()
{
// TODO: No default implementation in stdexec.
#if !defined(PIKA_HAVE_STDEXEC)
ex::std_thread_scheduler sched{};

{
Expand Down Expand Up @@ -902,7 +868,6 @@ void test_split_when_all()
PIKA_TEST_EQ(first_task_calls, std::size_t(1));
PIKA_TEST_EQ(successor_task_calls, std::size_t(2));
}
#endif
}

void test_let_value()
Expand Down Expand Up @@ -1150,8 +1115,6 @@ void test_detach()

void test_bulk()
{
// TODO: No default implementation in stdexec.
#if !defined(PIKA_HAVE_STDEXEC)
std::vector<int> const ns = {0, 1, 10, 43};

for (int n : ns)
Expand Down Expand Up @@ -1187,6 +1150,8 @@ void test_bulk()
}
}

// The specification only allows integral shapes
#if !defined(PIKA_HAVE_STDEXEC)
{
std::unordered_set<std::string> string_map;
std::vector<std::string> v = {"hello", "brave", "new", "world"};
Expand All @@ -1205,6 +1170,7 @@ void test_bulk()
PIKA_TEST(string_map.find(s) != string_map.end());
}
}
#endif

for (auto n : ns)
{
Expand Down Expand Up @@ -1250,7 +1216,6 @@ void test_bulk()
}
}
}
#endif
}

void test_completion_scheduler()
Expand Down Expand Up @@ -1282,7 +1247,6 @@ void test_completion_scheduler()
"the completion scheduler should be a std_thread_scheduler");
}

#if !defined(PIKA_HAVE_STDEXEC)
{
auto sender = ex::bulk(ex::schedule(ex::std_thread_scheduler{}), 10, [](int) {});
auto completion_scheduler =
Expand Down Expand Up @@ -1313,7 +1277,6 @@ void test_completion_scheduler()
std::is_same_v<std::decay_t<decltype(completion_scheduler)>, ex::std_thread_scheduler>,
"the completion scheduler should be a std_thread_scheduler");
}
#endif
}

void test_scheduler_queries()
Expand Down
59 changes: 12 additions & 47 deletions libs/pika/executors/tests/unit/thread_pool_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,27 +654,16 @@ void test_when_all_vector()

auto when1 = ex::when_all_vector(std::move(senders));

#if !defined(PIKA_HAVE_STDEXEC)
bool executed{false};
#endif
tt::sync_wait(std::move(when1)
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([parent_id, &executed](std::vector<double> v) {
PIKA_TEST_NEQ(parent_id, pika::this_thread::get_id());
PIKA_TEST_EQ(v.size(), std::size_t(3));
PIKA_TEST_EQ(v[0], 42.0);
PIKA_TEST_EQ(v[1], 43.0);
PIKA_TEST_EQ(v[2], 3.14);
executed = true;
})
#endif
);
#if !defined(PIKA_HAVE_STDEXEC)
tt::sync_wait(std::move(when1) | ex::then([parent_id, &executed](std::vector<double> v) {
PIKA_TEST_NEQ(parent_id, pika::this_thread::get_id());
PIKA_TEST_EQ(v.size(), std::size_t(3));
PIKA_TEST_EQ(v[0], 42.0);
PIKA_TEST_EQ(v[1], 43.0);
PIKA_TEST_EQ(v[2], 3.14);
executed = true;
}));
PIKA_TEST(executed);
#endif
}

{
Expand All @@ -699,14 +688,8 @@ void test_when_all_vector()

try
{
tt::sync_wait(ex::when_all_vector(std::move(senders))
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([](std::vector<int>) { PIKA_TEST(false); })
#endif
);
tt::sync_wait(ex::when_all_vector(std::move(senders)) |
ex::then([](std::vector<int>) { PIKA_TEST(false); }));
PIKA_TEST(false);
}
catch (std::runtime_error const& e)
Expand Down Expand Up @@ -740,14 +723,8 @@ void test_when_all_vector()

try
{
tt::sync_wait(ex::when_all_vector(std::move(senders))
// TODO: ADL issues? Uncommenting instantiates set_value with the
// sync_wait_receiver from when_all_vector_receiver, i.e. then is
// "skipped".
#if !defined(PIKA_HAVE_STDEXEC)
| ex::then([](std::vector<int>) { PIKA_TEST(false); })
#endif
);
tt::sync_wait(ex::when_all_vector(std::move(senders)) |
ex::then([](std::vector<int>) { PIKA_TEST(false); }));
PIKA_TEST(false);
}
catch (std::runtime_error const& e)
Expand Down Expand Up @@ -971,16 +948,13 @@ void test_ensure_started()
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}

// TODO: The split sender in the stdexec is not copyable.
#if !defined(PIKA_HAVE_STDEXEC)
{
auto s = ex::transfer_just(sched, 42) | ex::ensure_started() | ex::split();
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}
#endif

// It's allowed to discard the sender from ensure_started
{
Expand All @@ -990,8 +964,6 @@ void test_ensure_started()

void test_ensure_started_when_all()
{
// TODO: The split sender in the stdexec is not copyable.
#if !defined(PIKA_HAVE_STDEXEC)
ex::thread_pool_scheduler sched{};

{
Expand Down Expand Up @@ -1092,13 +1064,10 @@ void test_ensure_started_when_all()
PIKA_TEST_EQ(first_task_calls, std::size_t(1));
PIKA_TEST_EQ(successor_task_calls, std::size_t(2));
}
#endif
}

void test_split()
{
// TODO: No default implementation in stdexec.
#if !defined(PIKA_HAVE_STDEXEC)
ex::thread_pool_scheduler sched{};

{
Expand All @@ -1122,13 +1091,10 @@ void test_split()
PIKA_TEST_EQ(tt::sync_wait(s), 42);
PIKA_TEST_EQ(tt::sync_wait(std::move(s)), 42);
}
#endif
}

void test_split_when_all()
{
// TODO: No default implementation in stdexec.
#if !defined(PIKA_HAVE_STDEXEC)
ex::thread_pool_scheduler sched{};

{
Expand Down Expand Up @@ -1193,7 +1159,6 @@ void test_split_when_all()
PIKA_TEST_EQ(first_task_calls, std::size_t(1));
PIKA_TEST_EQ(successor_task_calls, std::size_t(2));
}
#endif
}

void test_let_value()
Expand Down

0 comments on commit 4a82ae8

Please sign in to comment.