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_Core.hpp"
9
10
#if defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
11
# include "plog/Formatters/TxtFormatter.h"
12
# include "plog/Initializers/ConsoleInitializer.h"
13
# include "plog/Log.h"
14
#endif
15
16
#include "
kokkos-utils/tests/scoped/ExecutionSpace.hpp
"
17
18
#include "
tests/utils/kokkos.hpp
"
19
20
namespace
Tests::Utils
{
21
22
template
<
template
<
typename
>
typename
ContextType, Kokkos::ExecutionSpace Exec>
23
struct
ContextTest
24
:
public
virtual
testing::Test
25
,
public
Kokkos::utils::tests::scoped::ExecutionSpace
<Exec> {
26
public
:
27
using
context_t
= ContextType<Exec>;
28
using
scheduler_t
=
decltype
(std::declval<const context_t>().get_scheduler());
29
using
schedule_sender_t
=
decltype
(stdexec::schedule(std::declval<scheduler_t>()));
30
31
using
value_t
= int;
32
using
view_s_t
= Kokkos::View<value_t, Kokkos::SharedSpace>;
33
34
static
constexpr
bool
on_device
=
Tests::Utils::on_device<Exec>
();
35
36
public
:
37
#if defined(KOKKOS_EXECUTION_ENABLE_DEBUG_LOGGING)
38
static
void
SetUpTestSuite() {
39
plog::init<plog::TxtFormatter>(plog::debug, plog::streamStdOut);
40
}
41
#endif
42
};
43
44
#if defined(KOKKOS_ENABLE_THREADS)
57
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT(_sndr_) \
58
ASSERT_THAT( \
59
Tests::Utils::Functors::MutableMoveToSyncWait{.sndr = std::move(_sndr_)}, \
60
::testing::ThrowsMessage<std::runtime_error>( \
61
::testing::HasSubstr("Called by a worker thread, can only be called by the master process.")));
62
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_) \
63
if constexpr (std::same_as<TEST_EXECUTION_SPACE, Kokkos::Threads>) { \
64
KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT(_sndr_) \
65
GTEST_SKIP() \
66
<< "Kokkos::Threads parallel regions must be launched from the thread that initialized " "Kokkos."; \
67
}
68
#else
69
# define KOKKOS_EXECUTION_THREADS_THROWS_ON_SYNC_WAIT_ASSERT_AND_SKIP(_sndr_)
70
#endif
71
72
}
// namespace Tests::Utils
73
74
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_CONTEXT_HPP
ExecutionSpace.hpp
stdexec.hpp
kokkos.hpp
Tests::Utils
Definition
atomic.hpp:59
Tests::Utils::on_device
constexpr bool on_device()
Definition
kokkos.hpp:22
Kokkos::utils::tests::scoped::ExecutionSpace
Tests::Utils::ContextTest
Definition
context.hpp:25
Tests::Utils::ContextTest::scheduler_t
decltype(std::declval< const context_t >().get_scheduler()) scheduler_t
Definition
context.hpp:28
Tests::Utils::ContextTest::schedule_sender_t
decltype(stdexec::schedule(std::declval< scheduler_t >())) schedule_sender_t
Definition
context.hpp:29
Tests::Utils::ContextTest::value_t
int value_t
Definition
context.hpp:31
Tests::Utils::ContextTest::view_s_t
Kokkos::View< value_t, Kokkos::SharedSpace > view_s_t
Definition
context.hpp:32
Tests::Utils::ContextTest::context_t
ContextType< Exec > context_t
Definition
context.hpp:27
Tests::Utils::ContextTest::on_device
static constexpr bool on_device
Definition
context.hpp:34
tests
utils
context.hpp
Generated on
for kokkos-execution by
1.18.0