-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathupon_stopped.cpp
38 lines (28 loc) · 1.05 KB
/
upon_stopped.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <catch2/catch.hpp>
#include <stdexec/execution.hpp>
#include "nvexec/stream_context.cuh"
#include "common.cuh"
namespace ex = stdexec;
using nvexec::is_on_gpu;
namespace {
TEST_CASE("nvexec upon_stopped returns a sender", "[cuda][stream][adaptors][upon_stopped]") {
nvexec::stream_context stream_ctx{};
auto snd = ex::just_stopped() | ex::continues_on(stream_ctx.get_scheduler())
| ex::upon_stopped([] { return ex::just(); });
STATIC_REQUIRE(ex::sender<decltype(snd)>);
(void) snd;
}
TEST_CASE("nvexec upon_stopped executes on GPU", "[cuda][stream][adaptors][upon_stopped]") {
nvexec::stream_context stream_ctx{};
flags_storage_t flags_storage{};
auto flags = flags_storage.get();
auto snd = ex::just_stopped() //
| ex::continues_on(stream_ctx.get_scheduler()) | ex::upon_stopped([=] {
if (is_on_gpu()) {
flags.set();
}
});
stdexec::sync_wait(std::move(snd));
REQUIRE(flags_storage.all_set_once());
}
} // namespace