kokkos-execution
0.0.1
Loading...
Searching...
No Matches
test_sync_wait.cpp
Go to the documentation of this file.
1
#include "
kokkos-utils/callbacks/RecorderListener.hpp
"
2
#include "
kokkos-utils/tests/scoped/callbacks/Manager.hpp
"
3
4
#include "
tests/utils/callback_matchers.hpp
"
5
#include "
tests/utils/check_sync_wait.hpp
"
6
#include "
tests/utils/execution_space_context.hpp
"
7
#include "
tests/utils/functors/throws_when_copied.hpp
"
8
#include "
tests/utils/stdexec.hpp
"
9
21
22
namespace
Tests::ExecutionSpaceImpl
{
23
24
using namespace
Kokkos::utils::callbacks;
25
26
class
SyncWaitTest
27
:
public
Tests::Utils::ExecutionSpaceContextTest
<TEST_EXECUTION_SPACE>
28
,
public
Kokkos::utils::tests::scoped::callbacks::Manager
{
29
public
:
30
using
recorder_listener_t
=
RecorderListener
<
31
EventDiscardMatcher<TEST_EXECUTION_SPACE>
,
32
BeginFenceEvent
,
33
Kokkos::Execution::Impl::RecordEvent
,
34
Kokkos::Execution::Impl::WaitEvent
35
>;
36
};
37
39
static_assert
(
Tests::Utils::check_nothrow_apply_sender
<
40
Kokkos::Execution::ExecutionSpaceImpl::Domain
,
41
typename
SyncWaitTest::schedule_sender_t
42
>());
43
45
TEST_F(
SyncWaitTest
, sync_wait) {
46
const
context_t
esc{
exec
};
47
48
auto
sndr = stdexec::schedule(esc.
get_scheduler
());
49
50
ASSERT_THAT(
51
recorder_listener_t::record([sndr = std::move(sndr)]()
mutable
{
// NOLINT(performance-move-const-arg)
52
const
auto
value = stdexec::sync_wait(std::move(sndr));
// NOLINT(performance-move-const-arg)
53
static_assert
(std::same_as<
decltype
(value),
const
std::optional<std::tuple<>>>);
54
ASSERT_TRUE(value.has_value());
55
}),
56
testing::IsEmpty());
57
}
58
60
TEST_F(
SyncWaitTest
, rethrows) {
61
const
context_t
esc{
exec
};
62
63
auto
sndr = stdexec::schedule(esc.
get_scheduler
()) | stdexec::then(
Tests::Utils::Functors::ThrowsWhenCopied
{});
64
65
ASSERT_THAT(
66
Tests::Utils::Functors::MutableMoveToSyncWait
{.sndr = std::move(sndr)},
67
testing::ThrowsMessage<std::runtime_error>(testing::StrEq(
"ThrowsWhenCopied: Throwing in copy constructor!"
)));
68
}
69
70
}
// namespace Tests::ExecutionSpaceImpl
RecorderListener.hpp
callback_matchers.hpp
check_sync_wait.hpp
Kokkos::utils::callbacks::RecorderListener
Tests::ExecutionSpaceImpl::SyncWaitTest
Definition
test_sync_wait.cpp:28
Tests::ExecutionSpaceImpl::SyncWaitTest::recorder_listener_t
RecorderListener< EventDiscardMatcher< TEST_EXECUTION_SPACE >, BeginFenceEvent, Kokkos::Execution::Impl::RecordEvent, Kokkos::Execution::Impl::WaitEvent > recorder_listener_t
Definition
test_sync_wait.cpp:30
execution_space_context.hpp
Tests::ExecutionSpaceImpl
Definition
test_any_sender.cpp:39
Tests::Utils::check_nothrow_apply_sender
consteval bool check_nothrow_apply_sender()
Definition
check_sync_wait.hpp:10
EventDiscardMatcher
Matcher to filter out events that are just noise for tests.
Definition
callback_matchers.hpp:83
Kokkos::Execution::ExecutionSpaceContext::get_scheduler
auto get_scheduler() const noexcept -> ExecutionSpaceImpl::Scheduler< Exec >
Definition
execution_space.hpp:133
Kokkos::Execution::ExecutionSpaceImpl::Domain
Definition
domain.hpp:13
Kokkos::Execution::Impl::RecordEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling record.
Definition
event.hpp:52
Kokkos::Execution::Impl::WaitEvent
Event to be sent to Kokkos::utils::callbacks::dispatch when calling wait.
Definition
event.hpp:73
Kokkos::utils::callbacks::BeginFenceEvent
Kokkos::utils::tests::scoped::ExecutionSpace< Exec >::exec
Exec exec
Kokkos::utils::tests::scoped::callbacks::Manager
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::schedule_sender_t
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Definition
context.hpp:29
Tests::Utils::ContextTest< Kokkos::Execution::ExecutionSpaceContext, Exec >::context_t
Kokkos::Execution::ExecutionSpaceContext< Exec > context_t
Definition
context.hpp:27
Tests::Utils::ExecutionSpaceContextTest
Definition
execution_space_context.hpp:12
Tests::Utils::Functors::MutableMoveToSyncWait
Definition
throws_when_copied.hpp:16
Tests::Utils::Functors::ThrowsWhenCopied
This helper struct throws when copy constructed.
Definition
throws_when_copied.hpp:30
Manager.hpp
stdexec.hpp
throws_when_copied.hpp
tests
execution_space
test_sync_wait.cpp
Generated on
for kokkos-execution by
1.15.0