44 #ifndef KOKKOS_CORE_CONCEPTS_HPP
45 #define KOKKOS_CORE_CONCEPTS_HPP
47 #include <type_traits>
50 #include <Kokkos_Core_fwd.hpp>
65 static_assert( std::is_same<T,Static>::value
66 || std::is_same<T,Dynamic>::value
67 ,
"Kokkos: Invalid Schedule<> type."
69 using schedule_type = Schedule ;
77 static_assert(std::is_integral<T>::value,
"Kokkos: Invalid IndexType<>.");
78 using index_type = IndexType ;
86 template<
unsigned int maxT = 0
87 ,
unsigned int minB = 0
93 static unsigned int constexpr maxTperB {maxT};
94 static unsigned int constexpr minBperSM {minB};
104 #define KOKKOS_IMPL_IS_CONCEPT( CONCEPT ) \
105 template< typename T > struct is_ ## CONCEPT { \
107 template< typename , typename = std::true_type > struct have : std::false_type {}; \
108 template< typename U > struct have<U,typename std::is_same< \
109 typename std::remove_cv<U>::type, \
110 typename std::remove_cv<typename U:: CONCEPT>::type \
111 >::type> : std::true_type {}; \
113 enum { value = is_ ## CONCEPT::template have<T>::value }; \
118 KOKKOS_IMPL_IS_CONCEPT( memory_space )
119 KOKKOS_IMPL_IS_CONCEPT( memory_traits )
120 KOKKOS_IMPL_IS_CONCEPT( execution_space )
121 KOKKOS_IMPL_IS_CONCEPT( execution_policy )
122 KOKKOS_IMPL_IS_CONCEPT( array_layout )
123 KOKKOS_IMPL_IS_CONCEPT( reducer )
129 using Kokkos::is_memory_space ;
130 using Kokkos::is_memory_traits ;
131 using Kokkos::is_execution_space ;
132 using Kokkos::is_execution_policy ;
133 using Kokkos::is_array_layout ;
137 KOKKOS_IMPL_IS_CONCEPT( iteration_pattern )
138 KOKKOS_IMPL_IS_CONCEPT( schedule_type )
139 KOKKOS_IMPL_IS_CONCEPT( index_type )
140 KOKKOS_IMPL_IS_CONCEPT( launch_bounds )
144 #undef KOKKOS_IMPL_IS_CONCEPT
152 template<
class ExecutionSpace ,
class MemorySpace >
154 static_assert( Kokkos::is_execution_space<ExecutionSpace>::value
155 ,
"Execution space is not valid" );
156 static_assert( Kokkos::is_memory_space<MemorySpace>::value
157 ,
"Memory space is not valid" );
158 typedef ExecutionSpace execution_space;
159 typedef MemorySpace memory_space;
160 typedef Device<execution_space,memory_space> device_type;
164 template<
typename T >
168 template<
typename ,
typename =
void >
169 struct exe : std::false_type {
typedef void space ; };
171 template<
typename ,
typename =
void >
172 struct mem : std::false_type {
typedef void space ; };
174 template<
typename ,
typename =
void >
175 struct dev : std::false_type {
typedef void space ; };
177 template<
typename U >
178 struct exe<U,typename std::conditional<true,void,typename U::execution_space>::type>
179 : std::is_same<U,typename U::execution_space>::type
180 {
typedef typename U::execution_space space ; };
182 template<
typename U >
183 struct mem<U,typename std::conditional<true,void,typename U::memory_space>::type>
184 : std::is_same<U,typename U::memory_space>::type
185 {
typedef typename U::memory_space space ; };
187 template<
typename U >
188 struct dev<U,typename std::conditional<true,void,typename U::device_type>::type>
189 : std::is_same<U,typename U::device_type>::type
190 {
typedef typename U::device_type space ; };
192 typedef typename is_space::template exe<T> is_exe ;
193 typedef typename is_space::template mem<T> is_mem ;
194 typedef typename is_space::template dev<T> is_dev ;
198 enum { value = is_exe::value || is_mem::value || is_dev::value };
200 typedef typename is_exe::space execution_space ;
201 typedef typename is_mem::space memory_space ;
206 typedef typename std::conditional
207 < std::is_same< memory_space , Kokkos::HostSpace >::value
208 #if defined( KOKKOS_ENABLE_CUDA )
209 || std::is_same< memory_space , Kokkos::CudaUVMSpace >::value
210 || std::is_same< memory_space , Kokkos::CudaHostPinnedSpace >::value
214 >::type host_memory_space ;
216 #if defined( KOKKOS_ENABLE_CUDA )
217 typedef typename std::conditional
218 < std::is_same< execution_space , Kokkos::Cuda >::value
219 , Kokkos::DefaultHostExecutionSpace , execution_space
220 >::type host_execution_space ;
222 #if defined( KOKKOS_ENABLE_OPENMPTARGET )
223 typedef typename std::conditional
224 < std::is_same< execution_space , Kokkos::Experimental::OpenMPTarget >::value
225 , Kokkos::DefaultHostExecutionSpace , execution_space
226 >::type host_execution_space ;
228 typedef execution_space host_execution_space ;
232 typedef typename std::conditional
233 < std::is_same< execution_space , host_execution_space >::value &&
234 std::is_same< memory_space , host_memory_space >::value
235 , T , Kokkos::Device< host_execution_space , host_memory_space >
236 >::type host_mirror_space ;
243 using Kokkos::is_space ;
259 template<
typename DstMemorySpace ,
typename SrcMemorySpace >
262 static_assert( Kokkos::is_memory_space< DstMemorySpace >::value &&
263 Kokkos::is_memory_space< SrcMemorySpace >::value
264 ,
"template arguments must be memory spaces" );
273 enum { assignable = std::is_same<DstMemorySpace,SrcMemorySpace>::value };
278 enum { accessible = assignable };
283 enum { deepcopy = assignable };
309 template<
typename AccessSpace ,
typename MemorySpace >
313 static_assert( Kokkos::is_space< AccessSpace >::value
314 ,
"template argument #1 must be a Kokkos space" );
316 static_assert( Kokkos::is_memory_space< MemorySpace >::value
317 ,
"template argument #2 must be a Kokkos memory space" );
322 <
typename AccessSpace::execution_space::memory_space
323 ,
typename AccessSpace::memory_space
325 ,
"template argument #1 is an invalid space" );
328 <
typename AccessSpace::execution_space::memory_space , MemorySpace >
332 <
typename AccessSpace::memory_space , MemorySpace >
342 enum { accessible = exe_access::accessible };
350 is_memory_space< AccessSpace >::value && mem_access::assignable };
353 enum { deepcopy = mem_access::deepcopy };
359 typedef typename std::conditional
360 < std::is_same<typename AccessSpace::memory_space,MemorySpace>::value ||
361 ! exe_access::accessible
363 , Kokkos::Device< typename AccessSpace::execution_space , MemorySpace >
378 #endif // KOKKOS_CORE_CONCEPTS_HPP
Can AccessSpace access MemorySpace ?
Memory management for host memory.
Specify Launch Bounds for CUDA execution.
Access relationship between DstMemorySpace and SrcMemorySpace.