kokkos-execution 0.0.1
Loading...
Searching...
No Matches
dispatch_label.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL_HPP
2#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL_HPP
3
4#include <algorithm>
5#include <array>
6#if defined(__cpp_impl_reflection)
7# include <meta>
8#endif
9#include <ranges>
10#include <string_view>
11
12#include "stdexec/__detail/__config.hpp"
13
14#include "Kokkos_Macros.hpp"
15#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
16import kokkos.core;
17# if !defined(__cpp_impl_reflection)
18# include "Kokkos_TypeInfo.hpp"
19# endif
20#else
21# include "Kokkos_Core.hpp"
22#endif
23
25
27
28#if !defined(__cpp_impl_reflection)
29namespace detail {
30
31template <Kokkos::ExecutionSpace Exec, FixedString Suffix>
32consteval auto dispatch_label() {
33 constexpr std::string_view prefix = Kokkos::Impl::TypeInfo<Exec>::name();
34 std::array<char, prefix.size() + Suffix.size()> buf{};
35 std::ranges::copy(Suffix, std::ranges::copy(prefix, buf.begin()).out);
36 return buf;
37}
38
39} // namespace detail
40
42template <Kokkos::ExecutionSpace Exec, FixedString Suffix>
44
46template <Kokkos::ExecutionSpace Exec, FixedString Suffix>
47consteval auto dispatch_label()
48 STDEXEC_AUTO_RETURN(std::string_view{dispatch_label_v<Exec, Suffix>.data(), dispatch_label_v<Exec, Suffix>.size()})
49
50// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
51# define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_) \
52 Kokkos::Execution::Impl::dispatch_label<KOKKOS_IMPL_STRIP_PARENS(_exec_), _suffix_>()
53#else
55template <Kokkos::ExecutionSpace Exec>
56consteval std::string_view dispatch_label(std::string_view suffix) noexcept {
57 return std::define_static_string(std::views::concat(std::meta::display_string_of(^^Exec), suffix));
58}
59
60# define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_) \
61 Kokkos::Execution::Impl::dispatch_label<KOKKOS_IMPL_STRIP_PARENS(_exec_)>(_suffix_)
62#endif
63} // namespace Kokkos::Execution::Impl
64
65#endif // KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL_HPP
constexpr std::string dispatch_label(const Exec &, const std::string_view label)
Get the dispatch label from Exec and label.
#define KOKKOS_EXECUTION_IMPL_DISPATCH_LABEL(_exec_, _suffix_)
consteval auto dispatch_label() noexcept(noexcept(std::string_view{dispatch_label_v< Exec, Suffix >.data(), dispatch_label_v< Exec, Suffix >.size()})) -> decltype(std::string_view{dispatch_label_v< Exec, Suffix >.data(), dispatch_label_v< Exec, Suffix >.size()})
View the dispatch label as a std::string_view.
constexpr auto dispatch_label_v
Get the dispatch label from Exec and Suffix.