17#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18#include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22#ifndef KOKKOS_CORE_CONCEPTS_HPP
23#define KOKKOS_CORE_CONCEPTS_HPP
28#include <Kokkos_Core_fwd.hpp>
30#include <Kokkos_DetectionIdiom.hpp>
44 static_assert(std::is_same_v<T, Static> || std::is_same_v<T, Dynamic>,
45 "Kokkos: Invalid Schedule<> type.");
46 using schedule_type = Schedule;
53 static_assert(std::is_integral_v<T>,
"Kokkos: Invalid IndexType<>.");
54 using index_type = IndexType;
59struct WorkItemProperty {
60 template <
unsigned long Property>
61 struct ImplWorkItemProperty {
62 static const unsigned value = Property;
63 using work_item_property = ImplWorkItemProperty<Property>;
66 constexpr static const ImplWorkItemProperty<0>
None =
67 ImplWorkItemProperty<0>();
68 constexpr static const ImplWorkItemProperty<1> HintLightWeight =
69 ImplWorkItemProperty<1>();
70 constexpr static const ImplWorkItemProperty<2> HintHeavyWeight =
71 ImplWorkItemProperty<2>();
72 constexpr static const ImplWorkItemProperty<4> HintRegular =
73 ImplWorkItemProperty<4>();
74 constexpr static const ImplWorkItemProperty<8> HintIrregular =
75 ImplWorkItemProperty<8>();
76 constexpr static const ImplWorkItemProperty<16> ImplForceGlobalLaunch =
77 ImplWorkItemProperty<16>();
78 using None_t = ImplWorkItemProperty<0>;
79 using HintLightWeight_t = ImplWorkItemProperty<1>;
80 using HintHeavyWeight_t = ImplWorkItemProperty<2>;
81 using HintRegular_t = ImplWorkItemProperty<4>;
82 using HintIrregular_t = ImplWorkItemProperty<8>;
83 using ImplForceGlobalLaunch_t = ImplWorkItemProperty<16>;
86template <
unsigned long pv1,
unsigned long pv2>
87inline constexpr WorkItemProperty::ImplWorkItemProperty<pv1 | pv2> operator|(
88 WorkItemProperty::ImplWorkItemProperty<pv1>,
89 WorkItemProperty::ImplWorkItemProperty<pv2>) {
90 return WorkItemProperty::ImplWorkItemProperty<pv1 | pv2>();
93template <
unsigned long pv1,
unsigned long pv2>
94inline constexpr WorkItemProperty::ImplWorkItemProperty<pv1 & pv2> operator&(
95 WorkItemProperty::ImplWorkItemProperty<pv1>,
96 WorkItemProperty::ImplWorkItemProperty<pv2>) {
97 return WorkItemProperty::ImplWorkItemProperty<pv1 & pv2>();
100template <
unsigned long pv1,
unsigned long pv2>
101inline constexpr bool operator==(WorkItemProperty::ImplWorkItemProperty<pv1>,
102 WorkItemProperty::ImplWorkItemProperty<pv2>) {
112template <
unsigned int maxT = 0
114 unsigned int minB = 0
119 static constexpr unsigned int maxTperB{
maxT};
120 static constexpr unsigned int minBperSM{
minB};
130#define KOKKOS_IMPL_IS_CONCEPT(CONCEPT) \
131 template <typename T> \
132 struct is_##CONCEPT { \
134 template <typename U> \
135 using have_t = typename U::CONCEPT; \
136 template <typename U> \
137 using have_type_t = typename U::CONCEPT##_type; \
140 static constexpr bool value = \
141 std::is_base_of_v<detected_t<have_t, T>, T> || \
142 std::is_base_of_v<detected_t<have_type_t, T>, T>; \
143 constexpr operator bool() const noexcept { return value; } \
145 template <typename T> \
146 inline constexpr bool is_##CONCEPT##_v = is_##CONCEPT<T>::value;
150KOKKOS_IMPL_IS_CONCEPT(memory_space)
151KOKKOS_IMPL_IS_CONCEPT(memory_traits)
152KOKKOS_IMPL_IS_CONCEPT(execution_space)
153KOKKOS_IMPL_IS_CONCEPT(execution_policy)
154KOKKOS_IMPL_IS_CONCEPT(array_layout)
155KOKKOS_IMPL_IS_CONCEPT(reducer)
156KOKKOS_IMPL_IS_CONCEPT(team_handle)
158KOKKOS_IMPL_IS_CONCEPT(work_item_property)
159KOKKOS_IMPL_IS_CONCEPT(hooks_policy)
166KOKKOS_IMPL_IS_CONCEPT(thread_team_member)
167KOKKOS_IMPL_IS_CONCEPT(host_thread_team_member)
168KOKKOS_IMPL_IS_CONCEPT(graph_kernel)
172#undef KOKKOS_IMPL_IS_CONCEPT
179template <
class Object>
180class has_member_team_shmem_size {
181 template <
typename T>
182 static int32_t test_for_member(
decltype(&T::team_shmem_size)) {
185 template <
typename T>
186 static int64_t test_for_member(...) {
191 constexpr static bool value =
192 sizeof(test_for_member<Object>(
nullptr)) ==
sizeof(int32_t);
195template <
class Object>
196class has_member_shmem_size {
197 template <
typename T>
198 static int32_t test_for_member(
decltype(&T::shmem_size_me)) {
201 template <
typename T>
202 static int64_t test_for_member(...) {
207 constexpr static bool value =
208 sizeof(test_for_member<Object>(0)) ==
sizeof(int32_t);
217template <
class ExecutionSpace,
class MemorySpace>
220 "Execution space is not valid");
222 "Memory space is not valid");
223 using execution_space = ExecutionSpace;
224 using memory_space = MemorySpace;
225 using device_type = Device<execution_space, memory_space>;
231struct is_device_helper : std::false_type {};
233template <
typename ExecutionSpace,
typename MemorySpace>
234struct is_device_helper<Device<ExecutionSpace, MemorySpace>> : std::true_type {
240using is_device =
typename Impl::is_device_helper<std::remove_cv_t<T>>::type;
243inline constexpr bool is_device_v = is_device<T>::value;
250 template <
typename,
typename =
void>
251 struct exe : std::false_type {
255 template <
typename,
typename =
void>
256 struct mem : std::false_type {
260 template <
typename,
typename =
void>
261 struct dev : std::false_type {
265 template <
typename U>
266 struct exe<U, std::conditional_t<true, void, typename U::execution_space>>
267 : std::is_same<U, typename U::execution_space>::type {
268 using space =
typename U::execution_space;
271 template <
typename U>
272 struct mem<U, std::conditional_t<true, void, typename U::memory_space>>
273 : std::is_same<U, typename U::memory_space>::type {
274 using space =
typename U::memory_space;
277 template <
typename U>
278 struct dev<U, std::conditional_t<true, void, typename U::device_type>>
279 : std::is_same<U, typename U::device_type>::type {
280 using space =
typename U::device_type;
283 using is_exe =
typename is_space<T>::template exe<std::remove_cv_t<T>>;
284 using is_mem =
typename is_space<T>::template mem<std::remove_cv_t<T>>;
285 using is_dev =
typename is_space<T>::template dev<std::remove_cv_t<T>>;
288 static constexpr bool value = is_exe::value || is_mem::value || is_dev::value;
290 constexpr operator bool() const noexcept {
return value; }
292 using execution_space =
typename is_exe::space;
293 using memory_space =
typename is_mem::space;
308template <
typename DstMemorySpace,
typename SrcMemorySpace>
312 "template arguments must be memory spaces");
321 enum { assignable = std::is_same_v<DstMemorySpace, SrcMemorySpace> };
326 enum { accessible = assignable };
331 enum { deepcopy = assignable };
358template <
typename AccessSpace,
typename MemorySpace>
361 static_assert(Kokkos::is_space<AccessSpace>::value,
362 "template argument #1 must be a Kokkos space");
365 "template argument #2 must be a Kokkos memory space");
370 typename AccessSpace::execution_space::memory_space,
371 typename AccessSpace::memory_space>::accessible,
372 "template argument #1 is an invalid space");
375 typename AccessSpace::execution_space::memory_space,
MemorySpace>;
387 enum { accessible = exe_access::accessible };
399 enum { deepcopy = mem_access::deepcopy };
405 using space = std::conditional_t<
406 std::is_same_v<typename AccessSpace::memory_space, MemorySpace> ||
407 !exe_access::accessible,
A thread safe view to a bitset.
Access relationship between DstMemorySpace and SrcMemorySpace.
Specify Launch Bounds for CUDA execution.
Can AccessSpace access MemorySpace ?