kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_dispatch_label.cpp
Go to the documentation of this file.
1
#include "gtest/gtest.h"
2
3
#include "
kokkos-execution/impl/dispatch_label.hpp
"
4
#include "
kokkos-execution/impl/type_info.hpp
"
5
16
17
namespace
Tests::Impl
{
18
19
constexpr
char
suffix
[] =
" with the given suffix"
;
20
21
constexpr
std::string_view
label_of_exec
=
Kokkos::Execution::Impl::display_string_of<TEST_EXECUTION_SPACE>
();
22
23
constexpr
std::string_view
label_as_view
=
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(TEST_EXECUTION_SPACE,
suffix
);
24
25
#if !defined(__cpp_impl_reflection)
27
consteval
bool
test_dispatch_label_v
() {
28
constexpr
auto
label_as_array =
Kokkos::Execution::Impl::dispatch_label_v<TEST_EXECUTION_SPACE, suffix>
;
29
30
static_assert
(
31
std::same_as<
decltype
(label_as_array),
const
std::array<char,
label_of_exec
.size() +
sizeof
(
suffix
) - 1>>);
32
33
return
true
;
34
}
35
36
static_assert
(
test_dispatch_label_v
());
37
#endif
38
40
consteval
bool
test_dispatch_label
() {
41
static_assert
(
42
std::same_as<
decltype
(
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(TEST_EXECUTION_SPACE,
suffix
)), std::string_view>);
43
static_assert
(std::same_as<
decltype
(
label_as_view
),
const
std::string_view>);
44
static_assert
(
label_as_view
.starts_with(
label_of_exec
));
45
static_assert
(
label_as_view
.ends_with(
suffix
));
46
static_assert
(
label_as_view
.size() ==
label_of_exec
.size() +
sizeof
(
suffix
) - 1);
47
48
return
true
;
49
}
50
51
static_assert
(
test_dispatch_label
());
52
54
consteval
bool
test_dispatch_label_noexcept
() {
55
static_assert
(
noexcept
(
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(TEST_EXECUTION_SPACE,
suffix
)));
56
57
return
true
;
58
}
59
60
static_assert
(
test_dispatch_label_noexcept
());
61
62
constexpr
std::string_view
view_a
=
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(TEST_EXECUTION_SPACE,
suffix
);
63
constexpr
std::string_view
view_b
=
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
(TEST_EXECUTION_SPACE,
suffix
);
64
72
TEST(DispatchLabelTest, deduplicate) {
73
static_assert
(
static_cast<
const
void
*
>
(
view_a
.data()) ==
static_cast<
const
void
*
>
(
view_b
.data()));
74
75
ASSERT_EQ(
static_cast<
const
void
*
>
(
view_a
.data()),
static_cast<
const
void
*
>
(
view_b
.data()));
76
}
77
78
}
// namespace Tests::Impl
dispatch_label.hpp
KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
Definition
dispatch_label.hpp:51
Kokkos::Execution::Impl::dispatch_label_v
constexpr auto dispatch_label_v
Get the dispatch label from Exec and Suffix.
Definition
dispatch_label.hpp:43
Kokkos::Execution::Impl::display_string_of
constexpr auto display_string_of() noexcept -> std::string_view
Definition
type_info.hpp:20
Tests::Impl
Definition
test_compile_time_optional.cpp:16
Tests::Impl::view_a
constexpr std::string_view view_a
Definition
test_dispatch_label.cpp:62
Tests::Impl::test_dispatch_label_v
consteval bool test_dispatch_label_v()
Definition
test_dispatch_label.cpp:27
Tests::Impl::label_as_view
constexpr std::string_view label_as_view
Definition
test_dispatch_label.cpp:23
Tests::Impl::view_b
constexpr std::string_view view_b
Definition
test_dispatch_label.cpp:63
Tests::Impl::test_dispatch_label_noexcept
consteval bool test_dispatch_label_noexcept()
Definition
test_dispatch_label.cpp:54
Tests::Impl::label_of_exec
constexpr std::string_view label_of_exec
Definition
test_dispatch_label.cpp:21
Tests::Impl::test_dispatch_label
consteval bool test_dispatch_label()
Definition
test_dispatch_label.cpp:40
Tests::Impl::suffix
constexpr char suffix[]
Definition
test_dispatch_label.cpp:19
type_info.hpp
tests
impl
test_dispatch_label.cpp
Generated on
for kokkos-execution by
1.18.0