www.cemf.ir
KokkosTypes.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __KokkosTypes_hpp__
22 #define __KokkosTypes_hpp__
23 
24 
25 #include <Kokkos_Core.hpp>
26 #include <Kokkos_DualView.hpp>
27 #include <Kokkos_UnorderedMap.hpp>
28 
29 #include "iOstream.hpp"
30 
31 
32 namespace pFlow
33 {
34 
35 class DeviceSide{};
36 class HostSide{};
37 
38 template<typename side>
39 struct selectSide{};
40 
43 
44 #ifdef _OPENMP
45 using OpenMP = Kokkos::OpenMP;
46 #endif
47 
50 
51 
52 
53 template<typename T1, typename T2>
54  using kPair = Kokkos::pair<T1,T2>;
55 
56 template<typename T>
57  using kRange = kPair<T,T>;
58 
60 
62 
63 template<typename T, typename... properties>
64  using ViewTypeScalar = Kokkos::View<T,properties...>;
65 
66 template<typename T, typename... properties>
67  using ViewType1D = Kokkos::View<T*,properties...>;
68 
69 template<typename T, typename... properties>
70  using DualViewType1D = Kokkos::DualView<T*,properties...>;
71 
72 template<typename T, typename... properties>
73  using ViewType3D = Kokkos::View<T***,properties...>;
74 
75 template<typename Key, typename Value, typename... properties>
76  using unorderedMap = Kokkos::UnorderedMap<Key, Value, properties...>;
77 
78 template<typename Key, typename... properties>
79  using unorderedSet = Kokkos::UnorderedMap<Key, void, properties...>;
80 
81 template<typename Key, typename Value>
82  using deviceHashMap= Kokkos::UnorderedMap<Key, Value>;
83 
84 template<typename Key, typename Value>
85  using hostHashMap= Kokkos::UnorderedMap<Key, Value, Kokkos::HostSpace>;
86 
87 template<typename Key>
88  using deviceHashSet= Kokkos::UnorderedMap<Key, void>;
89 
90 template<typename Key>
91  using hostHashSet = Kokkos::UnorderedMap<Key,void, Kokkos::HostSpace>;
92 
93 // a 1D array (vector) with default device (memory space and execution space)
94 template<typename T>
95  using deviceViewTypeScalar = Kokkos::View<T>;
96 
97 template<typename T>
98  using deviceViewType1D = Kokkos::View<T*>;
99 
100 template<typename T, typename Layout=void>
101  using deviceViewType2D = Kokkos::View<T**,Layout, void>;
102 
103 
104 // a 1D array (vector with host memeory space)
105 template<typename T>
106  using hostViewTypeScalar = Kokkos::View<T, Kokkos::HostSpace>;
107 
108 template<typename T>
109  using hostViewType1D = Kokkos::View<T*, Kokkos::HostSpace>;
110 
111 template<typename T, typename Layout=void>
112  using hostViewType2D = Kokkos::View<T**,Layout, Kokkos::HostSpace>;
113 
114 
115 #ifdef __CUDACC__
116 using Cuda = Kokkos::Cuda;
117 template<typename T>
118  using cudaViewTypeScalar = Kokkos::View<T, Kokkos::CudaSpace>;
119 
120 template<typename T>
121  using cudaViewType1D = Kokkos::View<T*, Kokkos::CudaSpace>;
122 
123 template<typename T, typename Layout=void>
124  using cudaViewType2D = Kokkos::View<T*,Layout, Kokkos::CudaSpace>;
125 #endif
126 
127 
128 template<typename T>
129 using deviceAtomicViewType1D =
130  Kokkos::View<
131  T*,
132  Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
133 
134 template<typename T>
136  Kokkos::View<
137  T***,
138  Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
139 
140 template<typename T>
142 {
143  os<<"["<<rng.first<<" "<<rng.second<<")";
144  return os;
145 }
146 
147 
148 } // pFlow
149 
150 #endif //__KokkosTypes_hpp__
pFlow::DefaultHostExecutionSpace
Kokkos::DefaultHostExecutionSpace DefaultHostExecutionSpace
Definition: KokkosTypes.hpp:48
pFlow::DeviceSide
Definition: KokkosTypes.hpp:35
pFlow::range
kRange< int > range
Definition: KokkosTypes.hpp:59
pFlow::Serial
Kokkos::Serial Serial
Definition: KokkosTypes.hpp:42
pFlow::HostSide
Definition: KokkosTypes.hpp:36
pFlow::deviceViewTypeScalar
Kokkos::View< T > deviceViewTypeScalar
Definition: KokkosTypes.hpp:95
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Definition: KokkosTypes.hpp:49
pFlow::deviceAtomicViewType3D
Kokkos::View< T ***, Kokkos::MemoryTraits< std::is_same< DefaultExecutionSpace, Serial >::value?0:Kokkos::Atomic > > deviceAtomicViewType3D
Definition: KokkosTypes.hpp:138
pFlow::HostSpace
Kokkos::HostSpace HostSpace
Definition: KokkosTypes.hpp:41
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:98
pFlow
Definition: demComponent.hpp:28
pFlow::hostHashSet
Kokkos::UnorderedMap< Key, void, Kokkos::HostSpace > hostHashSet
Definition: KokkosTypes.hpp:91
pFlow::unorderedSet
Kokkos::UnorderedMap< Key, void, properties... > unorderedSet
Definition: KokkosTypes.hpp:79
pFlow::range64
kRange< int long > range64
Definition: KokkosTypes.hpp:61
pFlow::unorderedMap
Kokkos::UnorderedMap< Key, Value, properties... > unorderedMap
Definition: KokkosTypes.hpp:76
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::hostViewTypeScalar
Kokkos::View< T, Kokkos::HostSpace > hostViewTypeScalar
Definition: KokkosTypes.hpp:106
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:109
pFlow::hostViewType2D
Kokkos::View< T **, Layout, Kokkos::HostSpace > hostViewType2D
Definition: KokkosTypes.hpp:112
pFlow::selectSide
Definition: KokkosTypes.hpp:39
pFlow::deviceAtomicViewType1D
Kokkos::View< T *, Kokkos::MemoryTraits< std::is_same< DefaultExecutionSpace, Serial >::value?0:Kokkos::Atomic > > deviceAtomicViewType1D
Definition: KokkosTypes.hpp:132
pFlow::deviceHashMap
Kokkos::UnorderedMap< Key, Value > deviceHashMap
Definition: KokkosTypes.hpp:82
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
Definition: KokkosTypes.hpp:67
iOstream.hpp
pFlow::deviceViewType2D
Kokkos::View< T **, Layout, void > deviceViewType2D
Definition: KokkosTypes.hpp:101
pFlow::hostHashMap
Kokkos::UnorderedMap< Key, Value, Kokkos::HostSpace > hostHashMap
Definition: KokkosTypes.hpp:85
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::DualViewType1D
Kokkos::DualView< T *, properties... > DualViewType1D
Definition: KokkosTypes.hpp:70
pFlow::ViewTypeScalar
Kokkos::View< T, properties... > ViewTypeScalar
Definition: KokkosTypes.hpp:64
pFlow::deviceHashSet
Kokkos::UnorderedMap< Key, void > deviceHashSet
Definition: KokkosTypes.hpp:88
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
Definition: KokkosTypes.hpp:73
pFlow::kPair
Kokkos::pair< T1, T2 > kPair
Definition: KokkosTypes.hpp:54
pFlow::kRange
kPair< T, T > kRange
Definition: KokkosTypes.hpp:57