45 #ifndef KOKKOS_CUDA_HPP
46 #define KOKKOS_CUDA_HPP
48 #include <Kokkos_Macros.hpp>
49 #if defined(KOKKOS_ENABLE_CUDA)
51 #include <Kokkos_Core_fwd.hpp>
56 #include <impl/Kokkos_AnalyzePolicy.hpp>
57 #include <Kokkos_CudaSpace.hpp>
60 #include <Kokkos_TaskScheduler.hpp>
62 #include <Kokkos_ScratchSpace.hpp>
63 #include <Kokkos_MemoryTraits.hpp>
64 #include <impl/Kokkos_Tags.hpp>
80 namespace Experimental {
81 enum class CudaLaunchMechanism : unsigned {
88 constexpr
inline CudaLaunchMechanism operator|(CudaLaunchMechanism p1,
89 CudaLaunchMechanism p2) {
90 return static_cast<CudaLaunchMechanism
>(
static_cast<unsigned>(p1) |
91 static_cast<unsigned>(p2));
93 constexpr
inline CudaLaunchMechanism operator&(CudaLaunchMechanism p1,
94 CudaLaunchMechanism p2) {
95 return static_cast<CudaLaunchMechanism
>(
static_cast<unsigned>(p1) &
96 static_cast<unsigned>(p2));
99 template <CudaLaunchMechanism l>
100 struct CudaDispatchProperties {
101 CudaLaunchMechanism launch_mechanism = l;
121 typedef Cuda execution_space;
123 #if defined(KOKKOS_ENABLE_CUDA_UVM)
124 typedef CudaUVMSpace memory_space;
127 typedef CudaSpace memory_space;
132 typedef Kokkos::Device<execution_space, memory_space> device_type;
135 typedef memory_space::size_type size_type;
138 typedef LayoutLeft array_layout;
141 typedef ScratchMemorySpace<Cuda> scratch_memory_space;
150 KOKKOS_INLINE_FUNCTION
static int in_parallel() {
151 #if defined(__CUDA_ARCH__)
184 static void impl_static_fence();
186 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
193 static int concurrency();
206 Cuda(Cuda&&) =
default;
207 Cuda(
const Cuda&) =
default;
208 Cuda& operator=(Cuda&&) =
default;
209 Cuda& operator=(
const Cuda&) =
default;
211 Cuda(cudaStream_t stream);
217 struct SelectDevice {
219 SelectDevice() : cuda_device_id(0) {}
220 explicit SelectDevice(
int id) : cuda_device_id(id) {}
223 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
228 static int is_initialized();
231 static void initialize(
const SelectDevice = SelectDevice(),
232 const size_t num_instances = 1);
234 static void impl_finalize();
238 static int impl_is_initialized();
241 static void impl_initialize(
const SelectDevice = SelectDevice(),
242 const size_t num_instances = 1);
248 static size_type device_arch();
251 static size_type detect_device_count();
256 static std::vector<unsigned> detect_device_arch();
258 cudaStream_t cuda_stream()
const;
259 int cuda_device()
const;
260 const cudaDeviceProp& cuda_device_prop()
const;
265 static const char* name();
267 inline Impl::CudaInternal* impl_internal_space_instance()
const {
268 return m_space_instance;
270 uint32_t impl_instance_id() const noexcept {
return 0; }
273 Impl::CudaInternal* m_space_instance;
276 namespace Profiling {
277 namespace Experimental {
279 struct DeviceTypeTraits<Cuda> {
281 static constexpr DeviceType
id = DeviceType::Cuda;
294 struct MemorySpaceAccess<Kokkos::CudaSpace,
295 Kokkos::Cuda::scratch_memory_space> {
296 enum { assignable =
false };
297 enum { accessible =
true };
298 enum { deepcopy =
false };
301 #if defined(KOKKOS_ENABLE_CUDA_UVM)
310 struct MemorySpaceAccess<Kokkos::CudaUVMSpace,
311 Kokkos::Cuda::scratch_memory_space> {
312 enum { assignable =
false };
313 enum { accessible =
true };
314 enum { deepcopy =
false };
320 struct VerifyExecutionCanAccessMemorySpace<Kokkos::CudaSpace,
321 Kokkos::Cuda::scratch_memory_space> {
322 enum { value =
true };
323 KOKKOS_INLINE_FUNCTION
static void verify(
void) {}
324 KOKKOS_INLINE_FUNCTION
static void verify(
const void*) {}
328 struct VerifyExecutionCanAccessMemorySpace<Kokkos::HostSpace,
329 Kokkos::Cuda::scratch_memory_space> {
330 enum { value =
false };
331 inline static void verify(
void) { CudaSpace::access_error(); }
332 inline static void verify(
const void* p) { CudaSpace::access_error(p); }
341 #include <Cuda/Kokkos_Cuda_KernelLaunch.hpp>
342 #include <Cuda/Kokkos_Cuda_Instance.hpp>
343 #include <Cuda/Kokkos_Cuda_View.hpp>
344 #include <Cuda/Kokkos_Cuda_Team.hpp>
345 #include <Cuda/Kokkos_Cuda_Parallel.hpp>
346 #include <Cuda/Kokkos_Cuda_Task.hpp>
347 #include <Cuda/Kokkos_Cuda_UniqueToken.hpp>
349 #include <KokkosExp_MDRangePolicy.hpp>
void print_configuration(std::ostream &, const bool detail=false)
Print "Bill of Materials".
Declaration of various MemoryLayout options.
Declaration of parallel operators.
void finalize()
Finalize the spaces that were initialized via Kokkos::initialize.