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 
30 namespace pFlow
31 {
32 
33 class DeviceSide{};
34 class HostSide{};
35 
36 template<typename side>
37 struct selectSide{};
38 
41 
42 #ifdef _OPENMP
43 using OpenMP = Kokkos::OpenMP;
44 #endif
45 
48 
49 
50 
51 template<typename T1, typename T2>
52  using kPair = Kokkos::pair<T1,T2>;
53 
55 
57 
58 template<typename T, typename... properties>
59  using ViewTypeScalar = Kokkos::View<T,properties...>;
60 
61 template<typename T, typename... properties>
62  using ViewType1D = Kokkos::View<T*,properties...>;
63 
64 template<typename T, typename... properties>
65  using DualViewType1D = Kokkos::DualView<T*,properties...>;
66 
67 template<typename T, typename... properties>
68  using ViewType3D = Kokkos::View<T***,properties...>;
69 
70 template<typename Key, typename Value, typename... properties>
71  using unorderedMap = Kokkos::UnorderedMap<Key, Value, properties...>;
72 
73 template<typename Key, typename... properties>
74  using unorderedSet = Kokkos::UnorderedMap<Key, void, properties...>;
75 
76 template<typename Key, typename Value>
77  using deviceHashMap= Kokkos::UnorderedMap<Key, Value>;
78 
79 template<typename Key, typename Value>
80  using hostHashMap= Kokkos::UnorderedMap<Key, Value, Kokkos::HostSpace>;
81 
82 template<typename Key>
83  using deviceHashSet= Kokkos::UnorderedMap<Key, void>;
84 
85 template<typename Key>
86  using hostHashSet = Kokkos::UnorderedMap<Key,void, Kokkos::HostSpace>;
87 
88 // a 1D array (vector) with default device (memory space and execution space)
89 template<typename T>
90  using deviceViewTypeScalar = Kokkos::View<T>;
91 
92 template<typename T>
93  using deviceViewType1D = Kokkos::View<T*>;
94 
95 template<typename T, typename Layout=void>
96  using deviceViewType2D = Kokkos::View<T**,Layout, void>;
97 
98 
99 // a 1D array (vector with host memeory space)
100 template<typename T>
101  using hostViewTypeScalar = Kokkos::View<T, Kokkos::HostSpace>;
102 
103 template<typename T>
104  using hostViewType1D = Kokkos::View<T*, Kokkos::HostSpace>;
105 
106 template<typename T, typename Layout=void>
107  using hostViewType2D = Kokkos::View<T**,Layout, Kokkos::HostSpace>;
108 
109 
110 #ifdef __CUDACC__
111 using Cuda = Kokkos::Cuda;
112 template<typename T>
113  using cudaViewTypeScalar = Kokkos::View<T, Kokkos::CudaSpace>;
114 
115 template<typename T>
116  using cudaViewType1D = Kokkos::View<T*, Kokkos::CudaSpace>;
117 
118 template<typename T, typename Layout=void>
119  using cudaViewType2D = Kokkos::View<T*,Layout, Kokkos::CudaSpace>;
120 #endif
121 
122 
123 template<typename T>
124 using deviceAtomicViewType1D =
125  Kokkos::View<
126  T*,
127  Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
128 
129 template<typename T>
131  Kokkos::View<
132  T***,
133  Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
134 
135 
136 } // pFlow
137 
138 #endif //__KokkosTypes_hpp__
pFlow::DefaultHostExecutionSpace
Kokkos::DefaultHostExecutionSpace DefaultHostExecutionSpace
Definition: KokkosTypes.hpp:46
pFlow::DeviceSide
Definition: KokkosTypes.hpp:33
pFlow::Serial
Kokkos::Serial Serial
Definition: KokkosTypes.hpp:40
pFlow::HostSide
Definition: KokkosTypes.hpp:34
pFlow::deviceViewTypeScalar
Kokkos::View< T > deviceViewTypeScalar
Definition: KokkosTypes.hpp:90
pFlow::DefaultExecutionSpace
Kokkos::DefaultExecutionSpace DefaultExecutionSpace
Definition: KokkosTypes.hpp:47
pFlow::deviceAtomicViewType3D
Kokkos::View< T ***, Kokkos::MemoryTraits< std::is_same< DefaultExecutionSpace, Serial >::value?0:Kokkos::Atomic > > deviceAtomicViewType3D
Definition: KokkosTypes.hpp:133
pFlow::HostSpace
Kokkos::HostSpace HostSpace
Definition: KokkosTypes.hpp:39
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::range64
kPair< int long, int long > range64
Definition: KokkosTypes.hpp:56
pFlow
Definition: demComponent.hpp:28
pFlow::hostHashSet
Kokkos::UnorderedMap< Key, void, Kokkos::HostSpace > hostHashSet
Definition: KokkosTypes.hpp:86
pFlow::unorderedSet
Kokkos::UnorderedMap< Key, void, properties... > unorderedSet
Definition: KokkosTypes.hpp:74
pFlow::unorderedMap
Kokkos::UnorderedMap< Key, Value, properties... > unorderedMap
Definition: KokkosTypes.hpp:71
pFlow::hostViewTypeScalar
Kokkos::View< T, Kokkos::HostSpace > hostViewTypeScalar
Definition: KokkosTypes.hpp:101
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:104
pFlow::hostViewType2D
Kokkos::View< T **, Layout, Kokkos::HostSpace > hostViewType2D
Definition: KokkosTypes.hpp:107
pFlow::selectSide
Definition: KokkosTypes.hpp:37
pFlow::deviceAtomicViewType1D
Kokkos::View< T *, Kokkos::MemoryTraits< std::is_same< DefaultExecutionSpace, Serial >::value?0:Kokkos::Atomic > > deviceAtomicViewType1D
Definition: KokkosTypes.hpp:127
pFlow::deviceHashMap
Kokkos::UnorderedMap< Key, Value > deviceHashMap
Definition: KokkosTypes.hpp:77
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
Definition: KokkosTypes.hpp:62
pFlow::deviceViewType2D
Kokkos::View< T **, Layout, void > deviceViewType2D
Definition: KokkosTypes.hpp:96
pFlow::hostHashMap
Kokkos::UnorderedMap< Key, Value, Kokkos::HostSpace > hostHashMap
Definition: KokkosTypes.hpp:80
pFlow::DualViewType1D
Kokkos::DualView< T *, properties... > DualViewType1D
Definition: KokkosTypes.hpp:65
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::ViewTypeScalar
Kokkos::View< T, properties... > ViewTypeScalar
Definition: KokkosTypes.hpp:59
pFlow::deviceHashSet
Kokkos::UnorderedMap< Key, void > deviceHashSet
Definition: KokkosTypes.hpp:83
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
Definition: KokkosTypes.hpp:68
pFlow::kPair
Kokkos::pair< T1, T2 > kPair
Definition: KokkosTypes.hpp:52