XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
my_subview.hpp
Go to the documentation of this file.
1 #ifndef MY_SUBVIEW_HPP
2 #define MY_SUBVIEW_HPP
3 
4 #include "space_settings.hpp"
5 
6 // 4D to 1D
7 template<class Device, typename T>
8 Kokkos::View<T*,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T****,Kokkos::LayoutRight,Device>& view, int i, int j, int k){
9  return Kokkos::View<T*,Kokkos::LayoutRight,Device>(view, i, j, k, Kokkos::ALL());
10 }
11 
12 // 3D to 1D
13 template<class Device, typename T>
14 Kokkos::View<T*,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T***,Kokkos::LayoutRight,Device>& view, int i, int j){
15  return Kokkos::View<T*,Kokkos::LayoutRight,Device>(view, i, j, Kokkos::ALL());
16 }
17 
18 // 2D to 1D
19 template<class Device, typename T>
20 Kokkos::View<T*,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T**,Kokkos::LayoutRight,Device>& view, int i){
21  return Kokkos::View<T*,Kokkos::LayoutRight,Device>(view, i, Kokkos::ALL());
22 }
23 
24 // 4D to 2D
25 template<class Device, typename T>
26 Kokkos::View<T**,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T****,Kokkos::LayoutRight,Device>& view, int i, int j){
27  return Kokkos::View<T**,Kokkos::LayoutRight,Device>(view, i, j, Kokkos::ALL(), Kokkos::ALL());
28 }
29 
30 // 3D to 2D
31 template<class Device, typename T>
32 Kokkos::View<T**,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T***,Kokkos::LayoutRight,Device>& view, int i){
33  return Kokkos::View<T**,Kokkos::LayoutRight,Device>(view, i, Kokkos::ALL(), Kokkos::ALL());
34 }
35 
36 // 4D to 3D
37 template<class Device, typename T>
38 Kokkos::View<T***,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T****,Kokkos::LayoutRight,Device>& view, int i){
39  return Kokkos::View<T***,Kokkos::LayoutRight,Device>(view, i, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
40 }
41 
42 // 5D to 4D
43 template<class Device, typename T>
44 Kokkos::View<T****,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T*****,Kokkos::LayoutRight,Device>& view, int i){
45  return Kokkos::View<T****,Kokkos::LayoutRight,Device>(view, i, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
46 }
47 
48 // 5D to 3D
49 template<class Device, typename T>
50 Kokkos::View<T***,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T*****,Kokkos::LayoutRight,Device>& view, int i, int j){
51  return Kokkos::View<T***,Kokkos::LayoutRight,Device>(view, i, j, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
52 }
53 
54 // 6D to 5D
55 template<class Device, typename T>
56 Kokkos::View<T*****,Kokkos::LayoutRight,Device> my_subview(const Kokkos::View<T******,Kokkos::LayoutRight,Device>& view, int i){
57  return Kokkos::View<T*****,Kokkos::LayoutRight,Device>(view, i, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
58 }
59 
60 // Unmanaged views
61 // 3D to 1D
62 template<class Device, typename T>
63 Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> my_subview(const Kokkos::View<T***,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& view, int i, int j){
64  return Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, j, Kokkos::ALL());
65 }
66 
67 // 2D to 1D
68 template<class Device, typename T>
69 Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> my_subview(const Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& view, int i){
70  return Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, Kokkos::ALL());
71 }
72 
73 // 4D to 2D
74 template<class Device, typename T>
75 Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> my_subview(const Kokkos::View<T****,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& view, int i, int j){
76  return Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, j, Kokkos::ALL(), Kokkos::ALL());
77 }
78 
79 // 3D to 2D
80 template<class Device, typename T>
81 Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> my_subview(const Kokkos::View<T***,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& view, int i){
82  return Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, Kokkos::ALL(), Kokkos::ALL());
83 }
84 
85 // 4D to 3D
86 template<class Device, typename T>
87 Kokkos::View<T***,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> my_subview(const Kokkos::View<T****,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>& view, int i){
88  return Kokkos::View<T***,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
89 }
90 
91 #endif
Kokkos::View< T *, Kokkos::LayoutRight, Device > my_subview(const Kokkos::View< T ****, Kokkos::LayoutRight, Device > &view, int i, int j, int k)
Definition: my_subview.hpp:8