kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_check_scheduler_type.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
4PRAGMA_DIAGNOSTIC_PUSH
6#include "exec/split.hpp"
7#include "exec/static_thread_pool.hpp"
8PRAGMA_DIAGNOSTIC_POP
9
11
15
26
27namespace Tests {
28
29using run_loop_scheduler_t = stdexec::run_loop::scheduler;
30using static_thread_pool_scheduler_t = experimental::execution::_pool_::_static_thread_pool::scheduler;
31
33TEST(check_scheduler, default) {
34 std::thread::id tid;
35
36 stdexec::sync_wait(
38 | THEN_STORE_THREAD_ID(&tid));
39
40 ASSERT_EQ(tid, std::this_thread::get_id());
41}
42
44TEST(check_scheduler, static_thread_pool) {
45 std::thread::id tid;
46
47 experimental::execution::static_thread_pool pool{1};
48
49 auto chain = stdexec::schedule(pool.get_scheduler())
52
53 stdexec::sync_wait(std::move(chain)); // NOLINT(performance-move-const-arg)
54
55 ASSERT_NE(tid, std::this_thread::get_id());
56}
57
63TEST(check_scheduler, split_when_all_no_forward) {
64 experimental::execution::static_thread_pool pool{1};
65
66 auto fork = stdexec::schedule(pool.get_scheduler())
68 | THEN_SHOW_THREAD_ID | experimental::execution::split();
69
70 auto chain = stdexec::when_all(
73
74 stdexec::sync_wait(
76}
77
83TEST(check_scheduler, split_transfer_when_all_no_forward) {
84 ::exec::static_thread_pool pool{1};
85
86 auto fork = stdexec::schedule(pool.get_scheduler())
88 | THEN_SHOW_THREAD_ID | experimental::execution::split();
89
90 auto chain = stdexec::transfer_when_all(
91 pool.get_scheduler(),
94
95 stdexec::sync_wait(
97}
98
100TEST(check_scheduler, multiple_splits) {
101 ::exec::static_thread_pool pool{1};
102
103 auto fork_A = stdexec::schedule(pool.get_scheduler())
105 | THEN_SHOW_THREAD_ID | experimental::execution::split();
106
107 auto chain_A_branch_a = fork_A | THEN_SHOW_THREAD_ID;
108 auto chain_A_branch_b = std::move(fork_A) | THEN_SHOW_THREAD_ID;
109
110 auto chain_A = stdexec::when_all(std::move(chain_A_branch_a), std::move(chain_A_branch_b)) | THEN_SHOW_THREAD_ID;
111
112 auto fork_B = std::move(chain_A) | stdexec::continues_on(pool.get_scheduler())
114 | experimental::execution::split();
115
116 auto chain_B_branch_a = fork_B | THEN_SHOW_THREAD_ID
118 auto chain_B_branch_b = std::move(fork_B) | THEN_SHOW_THREAD_ID
120
121 auto chain_B = stdexec::when_all(std::move(chain_B_branch_a), std::move(chain_B_branch_b)) | THEN_SHOW_THREAD_ID
123
124 stdexec::sync_wait(
126}
127
128} // namespace Tests
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
constexpr check_scheduler_type_t< Tag, Schd > check_scheduler_type
experimental::execution::_pool_::_static_thread_pool::scheduler static_thread_pool_scheduler_t
stdexec::run_loop::scheduler run_loop_scheduler_t
#define THEN_SHOW_THREAD_ID
Add a then calling Tests::Utils::Functors::ShowThreadID. // NOLINTNEXTLINE(cppcoreguidelines-macro-us...
#define THEN_STORE_THREAD_ID(__id__)
Add a then calling Tests::Utils::Functors::StoreThreadID. // NOLINTNEXTLINE(cppcoreguidelines-macro-u...