XGC1
 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 // Unmanaged views
43 // 3D to 1D
44 template<class Device, typename T>
45 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){
46  return Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, j, Kokkos::ALL());
47 }
48 
49 // 2D to 1D
50 template<class Device, typename T>
51 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){
52  return Kokkos::View<T*,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, Kokkos::ALL());
53 }
54 
55 // 4D to 2D
56 template<class Device, typename T>
57 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){
58  return Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, j, Kokkos::ALL(), Kokkos::ALL());
59 }
60 
61 // 3D to 2D
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){
64  return Kokkos::View<T**,Kokkos::LayoutRight,Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>(view, i, Kokkos::ALL(), Kokkos::ALL());
65 }
66 
67 // 4D to 3D
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(), Kokkos::ALL(), Kokkos::ALL());
71 }
72 
73 #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