kokkos-execution
0.0.1
Toggle main menu visibility
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
5
#include "
kokkos-execution/utils/ignore_warnings.hpp
"
6
PRAGMA_DIAGNOSTIC_PUSH
7
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
8
#include "exec/completion_behavior.hpp"
9
#include "exec/static_thread_pool.hpp"
10
PRAGMA_DIAGNOSTIC_POP
11
12
#include "
kokkos-execution/stdexec.hpp
"
13
14
#include "
tests/utils/functors/store_thread_id.hpp
"
15
#include "
tests/utils/return_thread_id.hpp
"
16
27
28
namespace
Tests
{
29
31
consteval
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
39
static_assert
(
test_completion_behavior
());
40
42
TEST(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
51
TEST(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
ignore_warnings.hpp
KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
Definition
ignore_warnings.hpp:44
stdexec.hpp
Tests
Definition
test_any_sender.cpp:39
Tests::test_completion_behavior
consteval bool test_completion_behavior()
Definition
test_inline_scheduler.cpp:31
return_thread_id.hpp
THEN_RETURN_THREAD_ID
#define THEN_RETURN_THREAD_ID
Return the thread ID.
Definition
return_thread_id.hpp:9
store_thread_id.hpp
THEN_STORE_THREAD_ID
#define THEN_STORE_THREAD_ID(__id__)
Add a stdexec::then calling Tests::Utils::Functors::StoreThreadID. // NOLINTNEXTLINE(cppcoreguideline...
Definition
store_thread_id.hpp:20
tests
stdexec
test_inline_scheduler.cpp
Generated on
for kokkos-execution by
1.18.0