kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_inline_scheduler.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
3#include <thread>
4
6PRAGMA_DIAGNOSTIC_PUSH
8#include "exec/completion_behavior.hpp"
9#include "exec/static_thread_pool.hpp"
10PRAGMA_DIAGNOSTIC_POP
11
13
16
27
28namespace Tests {
29
31consteval bool test_completion_behavior() {
32 static_assert(
33 exec::get_completion_behavior<stdexec::set_value_t, stdexec::schedule_result_t<stdexec::inline_scheduler>>()
34 == exec::completion_behavior::inline_completion);
35
36 return true;
37}
38
39static_assert(test_completion_behavior());
40
42TEST(inline_scheduler, main_thread) {
43 std::thread::id tid;
44
45 stdexec::sync_wait(stdexec::schedule(stdexec::inline_scheduler{}) | THEN_STORE_THREAD_ID(&tid));
46
47 ASSERT_EQ(tid, std::this_thread::get_id());
48}
49
51TEST(inline_scheduler, pool_thread) {
52 experimental::execution::static_thread_pool pool{1};
53
54 const auto [tid_pool] = stdexec::sync_wait(stdexec::schedule(pool.get_scheduler()) | THEN_RETURN_THREAD_ID).value();
55
56 ASSERT_NE(tid_pool, std::this_thread::get_id());
57
58 std::thread::id tid;
59
60 stdexec::sync_wait(
61 stdexec::schedule(pool.get_scheduler()) | stdexec::continues_on(stdexec::inline_scheduler{})
62 | THEN_STORE_THREAD_ID(&tid));
63
64 ASSERT_EQ(tid, tid_pool);
65}
66
67} // namespace Tests
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
consteval bool test_completion_behavior()
#define THEN_RETURN_THREAD_ID
Return the thread ID.
#define THEN_STORE_THREAD_ID(__id__)
Add a stdexec::then calling Tests::Utils::Functors::StoreThreadID. // NOLINTNEXTLINE(cppcoreguideline...