| 1 |
//@HEADER |
| 2 |
// ************************************************************************ |
| 3 |
// |
| 4 |
// Kokkos v. 4.0 |
| 5 |
// Copyright (2022) National Technology & Engineering |
| 6 |
// Solutions of Sandia, LLC (NTESS). |
| 7 |
// |
| 8 |
// Under the terms of Contract DE-NA0003525 with NTESS, |
| 9 |
// the U.S. Government retains certain rights in this software. |
| 10 |
// |
| 11 |
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
// See https://kokkos.org/LICENSE for license information. |
| 13 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 14 |
// |
| 15 |
//@HEADER |
| 16 |
|
| 17 |
#ifndef KOKKOSCOMPAT_TMM_HPP |
| 18 |
#define KOKKOSCOMPAT_TMM_HPP |
| 19 |
|
| 20 |
/// \file KokkosCompat_TMM.hpp |
| 21 |
/// \brief Compatibility between Kokkos Array View and Teuchos memory management classes. |
| 22 |
/// |
| 23 |
/// \warning This file and everything in it should be considered an |
| 24 |
/// implementation detail of Tpetra. We make no promises of |
| 25 |
/// backwards compatibility for any interface in this file, nor do |
| 26 |
/// we even promise that this header file will continue to exist. |
| 27 |
|
| 28 |
#include <TeuchosKokkosCompat_config.h> |
| 29 |
#include <Kokkos_Core.hpp> |
| 30 |
#include <Teuchos_ArrayView.hpp> |
| 31 |
|
| 32 |
#if 0 |
| 33 |
|
| 34 |
namespace Kokkos { |
| 35 |
namespace Impl { |
| 36 |
|
| 37 |
// template<class DestViewType> |
| 38 |
// struct ViewAssignment<DestViewType, Teuchos::ArrayView<typename DestViewType::value_type> {}; // ??? |
| 39 |
|
| 40 |
template< class DT , class DL , class DD , class DM , |
| 41 |
class ST , class SL , class SD , class SM > |
| 42 |
template<class ValueType> |
| 43 |
struct ViewAssignment<View<ValueType, Threads>, Teuchos::ArrayView<const ValueType> > { |
| 44 |
ViewAssignment (View<ValueType, Threads>& dst, |
| 45 |
const Teuchos::ArrayView<const ValueType>& src, |
| 46 |
typename enable_if< ( |
| 47 |
is_same< typename ViewTraits<DT,DL,DD,DM>::array_layout , |
| 48 |
typename ViewTraits<ST,SL,SD,SM>::array_layout >::value |
| 49 |
&& |
| 50 |
( unsigned(ViewTraits<DT,DL,DD,DM>::rank) == unsigned(ViewTraits<ST,SL,SD,SM>::rank) ) |
| 51 |
&& |
| 52 |
( unsigned(ViewTraits<DT,DL,DD,DM>::rank_dynamic) >= unsigned(ViewTraits<ST,SL,SD,SM>::rank_dynamic) ) |
| 53 |
) >::type * = 0 ) |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
View<ValueType, LayoutRight, Threads, MemoryUnmanaged> srcView; // (src.getRawPtr (), src.size ()); |
| 58 |
srcView.m_shape.N0 = src.size (); |
| 59 |
|
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
static void deep_copy (const DestViewType& dst, const Teuchos::ArrayView<const ValueType>& src); |
| 64 |
}; |
| 65 |
|
| 66 |
|
| 67 |
} // namespace Impl |
| 68 |
} // namespace Kokkos |
| 69 |
|
| 70 |
namespace Kokkos { |
| 71 |
namespace Compat { |
| 72 |
|
| 73 |
template<class ViewType> |
| 74 |
inline void |
| 75 |
deep_copy (const ViewType& dst, const Teuchos::ArrayView<DT>& src); |
| 76 |
|
| 77 |
template<class ValueType> |
| 78 |
inline void |
| 79 |
deep_copy (const Kokkos::View<ValueType, Kokkos::Threads>& dst, |
| 80 |
const Teuchos::ArrayView<ValueType>& src) |
| 81 |
{ |
| 82 |
using Kokkos::LayoutRight; |
| 83 |
using Kokkos::Threads; |
| 84 |
using Kokkos::MemoryUnmanaged; |
| 85 |
using Kokkos::View; |
| 86 |
|
| 87 |
View<ValueType, LayoutRight, Threads, MemoryUnmanaged> srcView (src.getRawPtr (), src.size ()); |
| 88 |
Kokkos::deep_copy (dst, srcView); |
| 89 |
} |
| 90 |
|
| 91 |
} // namespace Compat |
| 92 |
} // namespace Kokkos |
| 93 |
|
| 94 |
#endif // 0 |
| 95 |
|
| 96 |
#endif // KOKKOSCOMPAT_TMM_HPP |