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>(
265 #ifdef KOKKOS_COMPILER_INTEL
267 void fence(
const std::string &name);
269 void fence(
const std::string &name =
"Kokkos::fence: Unnamed Global Fence");
277 template <
class DataType,
class... Properties>
282 template <
class DstSpace,
class SrcSpace,
283 class ExecutionSpace =
typename DstSpace::execution_space,
287 template <
class ViewType,
class Layout =
typename ViewType::array_layout,
288 class ExecSpace =
typename ViewType::execution_space,
289 int Rank = ViewType::rank,
typename iType = int64_t>
292 template <
class ViewTypeA,
class ViewTypeB,
class Layout,
class ExecSpace,
293 int Rank,
typename iType>
296 template <
class Functor,
class Policy>
306 template <
class FunctorType,
class ExecPolicy,
308 FunctorType, ExecPolicy>::execution_space>
316 template <
typename CombinedFunctorReducerType,
typename PolicyType,
317 typename ExecutionSpaceType>
320 template <
typename FunctorType,
typename FunctorAnalysisReducerType,
321 typename Enable =
void>
322 class CombinedFunctorReducer;
330 template <
class FunctorType,
class ExecPolicy,
332 FunctorType, ExecPolicy>::execution_space>
335 template <
class FunctorType,
class ExecPolicy,
class ReturnType = InvalidType,
337 FunctorType, ExecPolicy>::execution_space>
338 class ParallelScanWithTotal;
342 template <
class ScalarType,
class Space = HostSpace>
344 template <
class ScalarType,
class Space = HostSpace>
346 template <
class ScalarType,
class Space = HostSpace>
348 template <
class ScalarType,
class Space = HostSpace>
350 template <
class ScalarType,
class Space = HostSpace>
352 template <
class ScalarType,
class Index,
class Space = HostSpace>
354 template <
class ScalarType,
class Index,
class Space = HostSpace>
356 template <
class ScalarType,
class Index,
class Space = HostSpace>
358 template <
class ScalarType,
class Space = HostSpace>
360 template <
class ScalarType,
class Space = HostSpace>
362 template <
class ScalarType,
class Space = HostSpace>
364 template <
class ScalarType,
class Space = HostSpace>
367 template <
class Scalar,
class Index,
class Space = HostSpace>
369 template <
class Scalar,
class Index,
class ComparatorType,
371 struct MaxFirstLocCustomComparator;
373 template <
class Scalar,
class Index,
class Space = HostSpace>
375 template <
class Scalar,
class Index,
class ComparatorType,
377 struct MinFirstLocCustomComparator;
379 template <
class Scalar,
class Index,
class Space = HostSpace>
380 struct MinMaxFirstLastLoc;
381 template <
class Scalar,
class Index,
class ComparatorType,
383 struct MinMaxFirstLastLocCustomComparator;
385 template <
class Index,
class Space = HostSpace>
387 template <
class Index,
class Space = HostSpace>
389 template <
class Index,
class Space = HostSpace>
390 struct StdIsPartitioned;
391 template <
class Index,
class Space = HostSpace>
392 struct StdPartitionPoint;
395 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE_FWD
396 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
397 #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.