kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_dispatch_label.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
5
16
17namespace Tests::Impl {
18
19constexpr char suffix[] = " with the given suffix";
20
22
23constexpr std::string_view label_as_view = KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(TEST_EXECUTION_SPACE, suffix);
24
25#if !defined(__cpp_impl_reflection)
27consteval bool test_dispatch_label_v() {
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
36static_assert(test_dispatch_label_v());
37#endif
38
40consteval 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
51static_assert(test_dispatch_label());
52
55 static_assert(noexcept(KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(TEST_EXECUTION_SPACE, suffix)));
56
57 return true;
58}
59
60static_assert(test_dispatch_label_noexcept());
61
62constexpr std::string_view view_a = KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(TEST_EXECUTION_SPACE, suffix);
63constexpr std::string_view view_b = KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(TEST_EXECUTION_SPACE, suffix);
64
72TEST(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
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
constexpr auto dispatch_label_v
Get the dispatch label from Exec and Suffix.
constexpr auto display_string_of() noexcept -> std::string_view
Definition type_info.hpp:20
constexpr std::string_view view_a
consteval bool test_dispatch_label_v()
constexpr std::string_view label_as_view
constexpr std::string_view view_b
consteval bool test_dispatch_label_noexcept()
constexpr std::string_view label_of_exec
consteval bool test_dispatch_label()
constexpr char suffix[]