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; }
54 inline constexpr AUTO_t AUTO{};
56 struct InvalidType {};
68 template <
class ExecutionSpace,
class MemorySpace>
72 class InitializationSettings;
77 #include <KokkosCore_Config_FwdBackend.hpp>
87 #if defined(__clang_analyzer__)
88 #define KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION \
89 [[clang::annotate("DefaultExecutionSpace")]]
90 #define KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION \
91 [[clang::annotate("DefaultHostExecutionSpace")]]
93 #define KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION
94 #define KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION
99 #if defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_CUDA)
100 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Cuda;
101 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMPTARGET)
102 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
103 Experimental::OpenMPTarget;
104 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HIP)
105 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = HIP;
106 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SYCL)
107 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = SYCL;
108 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENACC)
109 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
110 Experimental::OpenACC;
111 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP)
112 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = OpenMP;
113 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS)
114 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Threads;
115 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HPX)
116 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION =
117 Kokkos::Experimental::HPX;
118 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SERIAL)
119 using DefaultExecutionSpace KOKKOS_IMPL_DEFAULT_EXEC_SPACE_ANNOTATION = Serial;
122 "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."
125 #if defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP)
126 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
128 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS)
129 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
131 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HPX)
132 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
133 Kokkos::Experimental::HPX;
134 #elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SERIAL)
135 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
137 #elif defined(KOKKOS_ENABLE_OPENMP)
138 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
140 #elif defined(KOKKOS_ENABLE_THREADS)
141 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
143 #elif defined(KOKKOS_ENABLE_HPX)
144 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
145 Kokkos::Experimental::HPX;
146 #elif defined(KOKKOS_ENABLE_SERIAL)
147 using DefaultHostExecutionSpace KOKKOS_IMPL_DEFAULT_HOST_EXEC_SPACE_ANNOTATION =
151 "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."
155 #if defined(KOKKOS_ENABLE_CUDA)
156 using SharedSpace = CudaUVMSpace;
157 #define KOKKOS_HAS_SHARED_SPACE
158 #elif defined(KOKKOS_ENABLE_HIP)
159 using SharedSpace = HIPManagedSpace;
160 #define KOKKOS_HAS_SHARED_SPACE
161 #elif defined(KOKKOS_ENABLE_SYCL)
162 using SharedSpace = SYCLSharedUSMSpace;
163 #define KOKKOS_HAS_SHARED_SPACE
165 #elif !defined(KOKKOS_ENABLE_OPENACC) && !defined(KOKKOS_ENABLE_OPENMPTARGET)
166 using SharedSpace = HostSpace;
167 #define KOKKOS_HAS_SHARED_SPACE
170 inline constexpr
bool has_shared_space =
171 #if defined KOKKOS_HAS_SHARED_SPACE
177 #if defined(KOKKOS_ENABLE_CUDA)
178 using SharedHostPinnedSpace = CudaHostPinnedSpace;
179 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
180 #elif defined(KOKKOS_ENABLE_HIP)
181 using SharedHostPinnedSpace = HIPHostPinnedSpace;
182 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
183 #elif defined(KOKKOS_ENABLE_SYCL)
184 using SharedHostPinnedSpace = SYCLHostUSMSpace;
185 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
186 #elif !defined(KOKKOS_ENABLE_OPENACC) && !defined(KOKKOS_ENABLE_OPENMPTARGET)
187 using SharedHostPinnedSpace = HostSpace;
188 #define KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
191 inline constexpr
bool has_shared_host_pinned_space =
192 #if defined KOKKOS_HAS_SHARED_HOST_PINNED_SPACE
207 template <
class AccessSpace,
class MemorySpace>
208 struct SpaceAccessibility;
213 template <
class MemorySpace,
class AccessSpace,
214 bool = SpaceAccessibility<AccessSpace, MemorySpace>::accessible>
215 struct RuntimeCheckMemoryAccessViolation {
216 KOKKOS_FUNCTION RuntimeCheckMemoryAccessViolation(
char const *
const) {}
221 template <
class MemorySpace,
class AccessSpace>
222 struct RuntimeCheckMemoryAccessViolation<MemorySpace, AccessSpace, false> {
223 KOKKOS_FUNCTION RuntimeCheckMemoryAccessViolation(
char const *
const msg) {
230 template <
class MemorySpace>
231 KOKKOS_FUNCTION
void runtime_check_memory_access_violation() {
233 RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultHostExecutionSpace>(
234 "ERROR: attempt to access inaccessible memory space");))
236 (RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultExecutionSpace>(
237 "ERROR: attempt to access inaccessible memory space");))
242 template <class MemorySpace>
243 KOKKOS_FUNCTION
void runtime_check_memory_access_violation(
244 char const *const msg) {
246 (
void)RuntimeCheckMemoryAccessViolation<MemorySpace,
247 DefaultHostExecutionSpace>(msg);))
248 KOKKOS_IF_ON_DEVICE((
250 RuntimeCheckMemoryAccessViolation<MemorySpace, DefaultExecutionSpace>(
260 void fence(
const std::string &name =
"Kokkos::fence: Unnamed Global Fence");
267 template <
class DataType,
class... Properties>
272 template <
class DstSpace,
class SrcSpace,
273 class ExecutionSpace =
typename DstSpace::execution_space,
277 template <
class ViewType,
class Layout =
typename ViewType::array_layout,
278 class ExecSpace =
typename ViewType::execution_space,
279 int Rank = ViewType::rank,
typename iType = int64_t>
282 template <
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
283 int Rank,
typename iType>
286 template <
class Functor,
class Policy>
296 template <
class FunctorType,
class ExecPolicy,
298 FunctorType, ExecPolicy>::execution_space>
306 template <
typename CombinedFunctorReducerType,
typename PolicyType,
307 typename ExecutionSpaceType>
310 template <
typename FunctorType,
typename FunctorAnalysisReducerType,
311 typename Enable =
void>
312 class CombinedFunctorReducer;
320 template <
class FunctorType,
class ExecPolicy,
322 FunctorType, ExecPolicy>::execution_space>
325 template <
class FunctorType,
class ExecPolicy,
class ReturnType = InvalidType,
327 FunctorType, ExecPolicy>::execution_space>
328 class ParallelScanWithTotal;
332 template <
class ScalarType,
class Space = HostSpace>
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 Index,
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 Space = HostSpace>
350 template <
class ScalarType,
class Space = HostSpace>
352 template <
class ScalarType,
class Space = HostSpace>
354 template <
class ScalarType,
class Space = HostSpace>
357 template <
class Scalar,
class Index,
class Space = HostSpace>
359 template <
class Scalar,
class Index,
class ComparatorType,
361 struct MaxFirstLocCustomComparator;
363 template <
class Scalar,
class Index,
class Space = HostSpace>
365 template <
class Scalar,
class Index,
class ComparatorType,
367 struct MinFirstLocCustomComparator;
369 template <
class Scalar,
class Index,
class Space = HostSpace>
370 struct MinMaxFirstLastLoc;
371 template <
class Scalar,
class Index,
class ComparatorType,
373 struct MinMaxFirstLastLocCustomComparator;
375 template <
class Index,
class Space = HostSpace>
377 template <
class Index,
class Space = HostSpace>
379 template <
class Index,
class Space = HostSpace>
380 struct StdIsPartitioned;
381 template <
class Index,
class Space = HostSpace>
382 struct StdPartitionPoint;
385 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD
386 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
387 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD
Implementation detail of parallel_scan.
Memory management for host memory.
Implementation of the ParallelFor operator that has a partial specialization for the device...
Given a Functor and Execution Policy query an execution space.
Implementation detail of parallel_reduce.