17 #ifndef KOKKOS_CORE_EXP_INTEROP_HPP
18 #define KOKKOS_CORE_EXP_INTEROP_HPP
19 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE
21 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_INTEROP
24 #include <Kokkos_Core_fwd.hpp>
26 #include <Kokkos_MemoryTraits.hpp>
27 #include <Kokkos_View.hpp>
28 #include <impl/Kokkos_Utilities.hpp>
29 #include <type_traits>
38 template <
typename Tp>
39 struct device_memory_space {
43 template <
typename ExecT,
typename MemT>
44 struct device_memory_space<Kokkos::Device<ExecT, MemT>> {
48 template <
typename Tp>
49 using device_memory_space_t =
typename device_memory_space<Tp>::type;
55 template <
typename,
typename...>
56 struct python_view_type_impl;
58 template <
template <
typename...>
class ViewT,
typename ValueT,
60 struct python_view_type_impl<ViewT<ValueT>, type_list<Types...>> {
61 using type = ViewT<ValueT, device_memory_space_t<Types>...>;
64 template <
template <
typename...>
class ViewT,
typename ValueT,
66 struct python_view_type_impl<ViewT<ValueT, Types...>>
67 : python_view_type_impl<ViewT<ValueT>,
68 filter_type_list_t<is_default_memory_trait,
69 type_list<Types...>, false>> {};
71 template <
typename... T>
72 using python_view_type_impl_t =
typename python_view_type_impl<T...>::type;
79 template <
typename DataType,
class... Properties>
87 struct is_dyn_rank_view_dup :
public std::false_type {};
89 template <
class D,
class... P>
90 struct is_dyn_rank_view_dup<Kokkos::DynRankView<D, P...>>
91 :
public std::true_type {};
95 namespace Experimental {
100 template <
typename ViewT>
101 struct python_view_type {
103 Kokkos::is_view<std::decay_t<ViewT>>::value ||
104 Kokkos::Impl::is_dyn_rank_view_dup<std::decay_t<ViewT>>::value,
105 "Error! python_view_type only supports Kokkos::View and "
106 "Kokkos::DynRankView");
109 Kokkos::Impl::python_view_type_impl_t<typename ViewT::array_type>;
112 template <
typename ViewT>
113 using python_view_type_t =
typename python_view_type<ViewT>::type;
115 template <
typename Tp>
116 auto as_python_type(Tp&& _v) {
117 using cast_type = python_view_type_t<Tp>;
118 return static_cast<cast_type
>(std::forward<Tp>(_v));
123 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_INTEROP
124 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
125 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_INTEROP
Declaration of various MemoryLayout options.