10#ifndef TPETRA_DETAILS_TEMPVIEWUTILS_HPP
11#define TPETRA_DETAILS_TEMPVIEWUTILS_HPP
13#include "Kokkos_Core.hpp"
23template<
typename MemorySpace>
26 enum :
bool {value =
false};
30struct AlwaysMPISafe<Kokkos::HostSpace>
32 enum :
bool {value =
true};
35#ifdef KOKKOS_ENABLE_CUDA
37struct AlwaysMPISafe<Kokkos::CudaHostPinnedSpace>
39 enum :
bool {value =
true};
43#ifdef KOKKOS_ENABLE_HIP
45struct AlwaysMPISafe<Kokkos::HIPHostPinnedSpace>
47 enum :
bool {value =
true};
52template<
typename View1,
typename View2>
55 using L1 =
typename View1::array_layout;
56 using L2 =
typename View2::array_layout;
57 enum :
bool {EitherLeft = std::is_same<L1, Kokkos::LayoutLeft>::value || std::is_same<L2, Kokkos::LayoutLeft>::value};
58enum :
bool {BothStride = std::is_same<L1, Kokkos::LayoutStride>::value && std::is_same<L2, Kokkos::LayoutStride>::value};
59 using type =
typename std::conditional<EitherLeft || BothStride, Kokkos::LayoutLeft, Kokkos::LayoutRight>::type;
64Kokkos::View<typename SrcView::data_type, Layout, typename SrcView::device_type>
67 static_assert(!std::is_same<Kokkos::LayoutStride, Layout>::value,
68 "TempView::toLayout: Layout must be contiguous (not LayoutStride)");
70 Kokkos::View<typename SrcView::non_const_data_type, Layout, typename SrcView::device_type> dst(Kokkos::ViewAllocateWithoutInitializing(src.label()),
layout);
71 Kokkos::deep_copy(dst, src);
76Kokkos::View<typename SrcView::data_type, Layout, typename SrcView::device_type>
79 if(src.span_is_contiguous())
87 Kokkos::View<typename SrcView::non_const_data_type, Layout, typename SrcView::device_type>
88 result(Kokkos::ViewAllocateWithoutInitializing(src.label()),
layout);
89 Kokkos::deep_copy(
result, src);
97template<typename SrcView, bool AssumeGPUAware, typename = typename std::enable_if<AssumeGPUAware || AlwaysMPISafe<typename SrcView::memory_space>::value>::type>
99toMPISafe(
const SrcView& src)
101 using SrcLayout =
typename SrcView::array_layout;
102 static_assert(!std::is_same<SrcLayout, Kokkos::LayoutStride>::value,
"toMPISafe requires that SrcView is contiguous");
103 return toLayout<SrcView, SrcLayout>(src);
106template<
typename SrcView,
bool AssumeGPUAware,
typename =
typename std::enable_if<!(AssumeGPUAware || AlwaysMPISafe<
typename SrcView::memory_space>::value)>::type>
107decltype(Kokkos::create_mirror_view_and_copy(std::declval<Kokkos::HostSpace>(), std::declval<SrcView>()))
108toMPISafe(
const SrcView& src)
110 using SrcLayout =
typename SrcView::array_layout;
111 static_assert(!std::is_same<SrcLayout, Kokkos::LayoutStride>::value,
"toMPISafe requires that SrcView is contiguous");
112 auto srcContig = toLayout<SrcView, SrcLayout>(src);
113 return Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), srcContig);
Declaration of Tpetra::Details::isInterComm.
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Get the contiguous layout that matches as many of the given views as possible. If neither or both arg...