1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 //                             Kokkos
6 //         Manycore Performance-Portable Multidimensional Arrays
7 //
8 //              Copyright (2012) Sandia Corporation
9 //
10 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
11 // the U.S. Government retains certain rights in this software.
12 //
13 // Redistribution and use in source and binary forms, with or without
14 // modification, are permitted provided that the following conditions are
15 // met:
16 //
17 // 1. Redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. Redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the name of the Corporation nor the names of the
25 // contributors may be used to endorse or promote products derived from
26 // this software without specific prior written permission.
27 //
28 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
29 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
32 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
35 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 //
40 // Questions?  Contact  H. Carter Edwards (hcedwar@sandia.gov)
41 //
42 // ************************************************************************
43 //@HEADER
44 */
45 
46 #ifndef KOKKOSCOMPAT_VIEW_DEF_HPP
47 #define KOKKOSCOMPAT_VIEW_DEF_HPP
48 
49 #include "KokkosCompat_View.hpp"
50 
51 namespace Kokkos {
52   namespace Compat {
53 
54     // template <typename D, typename T>
55     // Kokkos::View<T*,D>
56     // getKokkosViewDeepCopy(const Teuchos::ArrayView<T>& a) {
57     //   typedef typename Kokkos::Impl::if_c<
58     //         Impl::VerifyExecutionCanAccessMemorySpace< D, Kokkos::HostSpace>::value,
59     //         typename D::execution_space, Kokkos::HostSpace>::type
60     //       HostDevice;
61     //   typedef Kokkos::View<T*,D>  view_type;
62     //   typedef Kokkos::View<T*,typename view_type::array_layout,HostDevice,Kokkos::MemoryUnmanaged> unmanaged_host_view_type;
63     //   if (a.size() == 0)
64     //     return view_type();
65     //   view_type v("", a.size());
66     //   unmanaged_host_view_type hv(a.getRawPtr(), a.size());
67     //   Kokkos::deep_copy(v,hv);
68     //   return v;
69     // }
70 
71     // template <typename D, typename T>
72     // Kokkos::View<const T*,D>
73     // getKokkosViewDeepCopy(const Teuchos::ArrayView<const T>& a) {
74     //   typedef typename Kokkos::Impl::if_c<
75     //         Impl::VerifyExecutionCanAccessMemorySpace< D, Kokkos::HostSpace>::value,
76     //         typename D::execution_space, Kokkos::HostSpace>::type
77     //       HostDevice;
78     //   typedef Kokkos::View<T*,D>  view_type;
79     //   typedef Kokkos::View<const T*,typename view_type::array_layout,HostDevice,Kokkos::MemoryUnmanaged> unmanaged_host_view_type;
80     //   if (a.size() == 0)
81     //     return view_type();
82     //   view_type v("", a.size());
83     //   unmanaged_host_view_type hv(a.getRawPtr(), a.size());
84     //   Kokkos::deep_copy(v,hv);
85     //   return v;
86     // }
87 
88     // template <typename T, typename D>
89     // void
90     // realloc(Kokkos::View<T*,D>& v, const typename D::size_type size) {
91     //   Kokkos::realloc(v,size);
92     // }
93 
94     // template <typename T, typename L, typename D, typename M>
95     // Kokkos::View<T*,L,D,M>
96     // create_view(const std::string& label, size_t size) {
97     //   return Kokkos::View<T*,L,D,M>(label, size);
98     // }
99 
100     // #define COMPAT_INSTANT(T,D)
101 
102     // template Kokkos::View<T*,D> getKokkosViewDeepCopy<D,T>(const Teuchos::ArrayView<T>& a);
103     //template Kokkos::View<const T*,D> getKokkosViewDeepCopy<D,T>(const Teuchos::ArrayView<const T>& a);
104     // template void realloc<T,D>(Kokkos::View<T*,D>& v, const D::size_type size);
105     // template Kokkos::View<T*,Kokkos::LayoutLeft,D,void> create_view<T,Kokkos::LayoutLeft,D,void>(const std::string& label, size_t size);
106     // template Kokkos::View<T*,Kokkos::LayoutRight,D,void> create_view<T,Kokkos::LayoutRight,D,void>(const std::string& label, size_t size);
107     // template Kokkos::View<T*,D,void,void> create_view<T,D,void,void>(const std::string& label, size_t size);
108 
109   } // namespace Compat
110 } // namespace Kokkos
111 
112 #endif // KOKKOSCOMPAT_VIEW_DEF_HPP
113