kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
context.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CONTEXT_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_CONTEXT_HPP
3
4
#include "gtest/gtest.h"
5
6
#include "
kokkos-execution/stdexec.hpp
"
7
8
#include "Kokkos_Macros.hpp"
9
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
10
import
kokkos.core;
11
#else
12
# include "Kokkos_Core.hpp"
13
#endif
14
15
#if defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
16
# include "plog/Formatters/TxtFormatter.h"
17
# include "plog/Initializers/ConsoleInitializer.h"
18
# include "plog/Log.h"
19
#endif
20
21
#include "
kokkos-utils/tests/scoped/ExecutionSpace.hpp
"
22
23
#include "
tests/utils/functors/throws_when_copied.hpp
"
24
#include "
tests/utils/kokkos.hpp
"
25
26
namespace
Tests::Utils
{
27
28
template
<
template
<
typename
>
typename
ContextType, Kokkos::ExecutionSpace Exec>
29
struct
ContextTest
30
:
public
virtual
testing::Test
31
,
public
Kokkos::utils::tests::scoped::ExecutionSpace
<Exec> {
32
public
:
33
using
context_t
= ContextType<Exec>;
34
using
scheduler_t
=
decltype
(std::declval<const context_t>().get_scheduler());
35
using
schedule_sender_t
=
decltype
(stdexec::schedule(std::declval<scheduler_t>()));
36
37
using
value_t
= int;
38
using
view_s_t
= Kokkos::View<value_t, Kokkos::SharedSpace>;
39
using
view_um_s_t
= Kokkos::View<value_t, Kokkos::SharedSpace, Kokkos::MemoryUnmanaged>;
40
41
static
constexpr
bool
on_device
=
Tests::Utils::on_device<Exec>
();
42
43
public
:
44
#if defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
45
static
void
SetUpTestSuite() {
46
plog::init<plog::TxtFormatter>(plog::debug, plog::streamStdOut);
47
}
48
#endif
49
};
50
51
#if defined(KOKKOS_ENABLE_THREADS)
64
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT(_sndr_) \
65
ASSERT_THAT( \
66
Tests::Utils::Functors::MutableMoveToSyncWait{.sndr = std::move(_sndr_)}, \
67
::testing::ThrowsMessage<std::runtime_error>( \
68
::testing::HasSubstr("Called by a worker thread, can only be called by the master process.")));
69
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_) \
70
if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::Threads>) { \
71
KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT(_sndr_) \
72
GTEST_SKIP() \
73
<< "Kokkos::Threads parallel regions must be launched from the thread that initialized " "Kokkos."; \
74
}
75
#else
76
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_)
77
#endif
78
79
}
// namespace Tests::Utils
80
81
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_CONTEXT_HPP
ExecutionSpace.hpp
stdexec.hpp
kokkos.hpp
Tests::Utils
Definition
test_sync_wait.cpp:20
Tests::Utils::on_device
constexpr bool on_device()
Definition
kokkos.hpp:27
Kokkos::utils::tests::scoped::ExecutionSpace
Tests::Utils::ContextTest
Definition
context.hpp:31
Tests::Utils::ContextTest::scheduler_t
decltype(std::declval< const context_t >().get_scheduler()) scheduler_t
Definition
context.hpp:34
Tests::Utils::ContextTest::schedule_sender_t
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Definition
context.hpp:35
Tests::Utils::ContextTest::view_um_s_t
Kokkos::View< value_t, Kokkos::SharedSpace, Kokkos::MemoryUnmanaged > view_um_s_t
Definition
context.hpp:39
Tests::Utils::ContextTest::value_t
int value_t
Definition
context.hpp:37
Tests::Utils::ContextTest::view_s_t
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Definition
context.hpp:38
Tests::Utils::ContextTest::context_t
ContextType< Exec > context_t
Definition
context.hpp:33
Tests::Utils::ContextTest::on_device
static constexpr bool on_device
Definition
context.hpp:41
throws_when_copied.hpp
tests
utils
context.hpp
Generated on
for kokkos-execution by
1.18.0