17 #ifndef KOKKOS_CORE_FWD_HPP
18 #define KOKKOS_CORE_FWD_HPP
19 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE
21 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD
28 #include <Kokkos_Macros.hpp>
29 #include <Kokkos_Printf.hpp>
30 #include <impl/Kokkos_Error.hpp>
31 #include <impl/Kokkos_Utilities.hpp>
36 #ifdef KOKKOS_IMPL_32BIT
37 static_assert(
sizeof(
void *) == 4,
38 "Kokkos assumes 64-bit build; i.e., 4-byte pointers");
40 static_assert(
sizeof(
void *) == 8,
41 "Kokkos assumes 64-bit build; i.e., 8-byte pointers");
48 KOKKOS_INLINE_FUNCTION
49 constexpr
const AUTO_t &operator()()
const {
return *
this; }
55 constexpr AUTO_t AUTO = Kokkos::AUTO_t();
58 struct InvalidType {};
70 template <
class ExecutionSpace,
class MemorySpace>
74 class InitializationSettings;
79 #include <KokkosCore_Config_FwdBackend.hpp>
89 #if defined(__clang_analyzer__)
90 #define KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION \
91 [[clang::annotate("DefaultExecutionSpace")]]
92 #define KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION \
93 [[clang::annotate("DefaultHostExecutionSpace")]]
95 #define KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION
96 #define KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION
101 #if defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_CUDA)
102 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Cuda;
103 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMPTARGET)
104 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
105 Experimental::OpenMPTarget;
106 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HIP)
107 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = HIP;
108 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SYCL)
109 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = SYCL;
110 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENACC)
111 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
112 Experimental::OpenACC;
113 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP)
114 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = OpenMP;
115 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS)
116 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Threads;
117 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HPX)
118 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
119 Kokkos::Experimental::HPX;
120 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SERIAL)
121 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Serial;
124 "At least one of the following execution spaces must be defined in order to use Kokkos: Kokkos::Cuda, Kokkos::HIP, Kokkos::SYCL, Kokkos::Experimental::OpenMPTarget, Kokkos::Experimental::OpenACC, Kokkos::OpenMP, Kokkos::Threads, Kokkos::Experimental::HPX, or Kokkos::Serial."
127 #if defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP)
128 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
130 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS)
131 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
133 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HPX)
134 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
135 Kokkos::Experimental::HPX;
136 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SERIAL)
137 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
139 #elif defined(KOKKOS_ENABLE_OPENMP)
140 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
142 #elif defined(KOKKOS_ENABLE_THREADS)
143 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
145 #elif defined(KOKKOS_ENABLE_HPX)
146 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
147 Kokkos::Experimental::HPX;
148 #elif defined(KOKKOS_ENABLE_SERIAL)
149 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
153 "At least one of the following execution spaces must be defined in order to use Kokkos: Kokkos::OpenMP, Kokkos::Threads, Kokkos::Experimental::HPX, or Kokkos::Serial."
157 #if defined(KOKKOS_ENABLE_CUDA)
158 using SharedSpace = CudaUVMSpace;
159 #define KOKKOS_HAS_SHARED_SPACE
160 #elif defined(KOKKOS_ENABLE_HIP)
161 using SharedSpace = HIPManagedSpace;
162 #define KOKKOS_HAS_SHARED_SPACE
163 #elif defined(KOKKOS_ENABLE_SYCL)
164 using SharedSpace = SYCLSharedUSMSpace;
165 #define KOKKOS_HAS_SHARED_SPACE
167 #elif !defined(KOKKOS_ENABLE_OPENACC) && !defined(KOKKOS_ENABLE_OPENMPTARGET)
168 using SharedSpace = HostSpace;
169 #define KOKKOS_HAS_SHARED_SPACE
172 inline constexpr
bool has_shared_space =
173 #if defined KOKKOS_HAS_SHARED_SPACE
179 #if defined(KOKKOS_ENABLE_CUDA)
180 using SharedHostPinnedSpace = CudaHostPinnedSpace;
181 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
182 #elif defined(KOKKOS_ENABLE_HIP)
183 using SharedHostPinnedSpace = HIPHostPinnedSpace;
184 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
185 #elif defined(KOKKOS_ENABLE_SYCL)
186 using SharedHostPinnedSpace = SYCLHostUSMSpace;
187 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
188 #elif !defined(KOKKOS_ENABLE_OPENACC) && !defined(KOKKOS_ENABLE_OPENMPTARGET)
189 using SharedHostPinnedSpace = HostSpace;
190 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
193 inline constexpr
bool has_shared_host_pinned_space =
194 #if defined KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
209 template <
class AccessSpace,
class MemorySpace>
210 struct SpaceAccessibility;
215 template <
class MemorySpace,
class AccessSpace,
216 bool = SpaceAccessibility<AccessSpace, MemorySpace>::accessible>
217 struct RuntimeCheckMemoryAccessViolation {
218 KOKKOS_FUNCTION RuntimeCheckMemoryAccessViolation(
char const *
const) {}
223 template <
class MemorySpace,
class AccessSpace>
224 struct RuntimeCheckMemoryAccessViolation<MemorySpace, AccessSpace, false> {
225 KOKKOS_FUNCTION RuntimeCheckMemoryAccessViolation(
char const *
const msg) {
232 template <
class MemorySpace>
233 KOKKOS_FUNCTION
void runtime_check_memory_access_violation() {
235 RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultHostExecutionSpace>(
236 "ERROR: attempt to access inaccessible memory space");))
238 (RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultExecutionSpace>(
239 "ERROR: attempt to access inaccessible memory space");))
244 template <class MemorySpace>
245 KOKKOS_FUNCTION
void runtime_check_memory_access_violation(
246 char const *const msg) {
248 (
void)RuntimeCheckMemoryAccessViolation<MemorySpace,
249 DefaultHostExecutionSpace>(msg);))
250 KOKKOS_IF_ON_DEVICE((
252 RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultExecutionSpace>(
262 void fence(
const std::string &name =
"Kokkos::fence: Unnamed Global Fence");
269 template <
class DataType,
class... Properties>
274 template <
class DstSpace,
class SrcSpace,
275 class ExecutionSpace =
typename DstSpace::execution_space,
279 template <
class ViewType,
class Layout =
typename ViewType::array_layout,
280 class ExecSpace =
typename ViewType::execution_space,
281 int Rank = ViewType::rank,
typename iType = int64_t>
284 template <
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
285 int Rank,
typename iType>
288 template <
class Functor,
class Policy>
289 struct FunctorPolicyExecutionSpace;
298 template <
class FunctorType,
class ExecPolicy,
299 class ExecutionSpace =
typename Impl::FunctorPolicyExecutionSpace<
300 FunctorType, ExecPolicy>::execution_space>
308 template <
typename CombinedFunctorReducerType,
typename PolicyType,
309 typename ExecutionSpaceType>
310 class ParallelReduce;
312 template <
typename FunctorType,
typename FunctorAnalysisReducerType,
313 typename Enable =
void>
314 class CombinedFunctorReducer;
322 template <
class FunctorType,
class ExecPolicy,
323 class ExecutionSpace =
typename Impl::FunctorPolicyExecutionSpace<
324 FunctorType, ExecPolicy>::execution_space>
327 template <
class FunctorType,
class ExecPolicy,
class ReturnType = InvalidType,
328 class ExecutionSpace =
typename Impl::FunctorPolicyExecutionSpace<
329 FunctorType, ExecPolicy>::execution_space>
330 class ParallelScanWithTotal;
334 template <
class ScalarType,
class Space = HostSpace>
336 template <
class ScalarType,
class Space = HostSpace>
338 template <
class ScalarType,
class Space = HostSpace>
340 template <
class ScalarType,
class Space = HostSpace>
342 template <
class ScalarType,
class Space = HostSpace>
344 template <
class ScalarType,
class Index,
class Space = HostSpace>
346 template <
class ScalarType,
class Index,
class Space = HostSpace>
348 template <
class ScalarType,
class Index,
class Space = HostSpace>
350 template <
class ScalarType,
class Space = HostSpace>
352 template <
class ScalarType,
class Space = HostSpace>
354 template <
class ScalarType,
class Space = HostSpace>
356 template <
class ScalarType,
class Space = HostSpace>
359 template <
class Scalar,
class Index,
class Space = HostSpace>
361 template <
class Scalar,
class Index,
class ComparatorType,
362 class Space = HostSpace>
363 struct MaxFirstLocCustomComparator;
365 template <
class Scalar,
class Index,
class Space = HostSpace>
367 template <
class Scalar,
class Index,
class ComparatorType,
368 class Space = HostSpace>
369 struct MinFirstLocCustomComparator;
371 template <
class Scalar,
class Index,
class Space = HostSpace>
372 struct MinMaxFirstLastLoc;
373 template <
class Scalar,
class Index,
class ComparatorType,
374 class Space = HostSpace>
375 struct MinMaxFirstLastLocCustomComparator;
377 template <
class Index,
class Space = HostSpace>
379 template <
class Index,
class Space = HostSpace>
381 template <
class Index,
class Space = HostSpace>
382 struct StdIsPartitioned;
383 template <
class Index,
class Space = HostSpace>
384 struct StdPartitionPoint;
387 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD
388 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
389 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD