44 #ifndef KOKKOS_CUDA_HPP
45 #define KOKKOS_CUDA_HPP
47 #include <Kokkos_Macros.hpp>
48 #if defined( KOKKOS_ENABLE_CUDA )
50 #include <Kokkos_Core_fwd.hpp>
55 #include <impl/Kokkos_AnalyzePolicy.hpp>
56 #include <Kokkos_CudaSpace.hpp>
59 #include <Kokkos_TaskScheduler.hpp>
61 #include <Kokkos_ScratchSpace.hpp>
62 #include <Kokkos_MemoryTraits.hpp>
63 #include <impl/Kokkos_Tags.hpp>
80 namespace Experimental {
81 enum class CudaLaunchMechanism:unsigned{Default=0,ConstantMemory=1,GlobalMemory=2,LocalMemory=4};
83 constexpr
inline CudaLaunchMechanism operator | (CudaLaunchMechanism p1, CudaLaunchMechanism p2) {
84 return static_cast<CudaLaunchMechanism
>(
static_cast<unsigned>(p1) | static_cast<unsigned>(p2));
86 constexpr
inline CudaLaunchMechanism operator & (CudaLaunchMechanism p1, CudaLaunchMechanism p2) {
87 return static_cast<CudaLaunchMechanism
>(
static_cast<unsigned>(p1) & static_cast<unsigned>(p2));
90 template<CudaLaunchMechanism l>
91 struct CudaDispatchProperties {
92 CudaLaunchMechanism launch_mechanism = l;
112 typedef Cuda execution_space ;
114 #if defined( KOKKOS_ENABLE_CUDA_UVM )
115 typedef CudaUVMSpace memory_space ;
118 typedef CudaSpace memory_space ;
123 typedef Kokkos::Device<execution_space,memory_space> device_type;
126 typedef memory_space::size_type size_type ;
129 typedef LayoutLeft array_layout ;
132 typedef ScratchMemorySpace< Cuda > scratch_memory_space ;
141 KOKKOS_INLINE_FUNCTION
static int in_parallel() {
142 #if defined( __CUDA_ARCH__ )
175 static void impl_static_fence();
177 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
184 static int concurrency();
193 KOKKOS_INLINE_FUNCTION
198 Cuda( Cuda && ) = default ;
199 Cuda(
const Cuda & ) = default ;
200 Cuda & operator = ( Cuda && ) = default ;
201 Cuda & operator = (
const Cuda & ) = default ;
203 Cuda(cudaStream_t stream);
209 struct SelectDevice {
211 SelectDevice() : cuda_device_id(0) {}
212 explicit SelectDevice(
int id ) : cuda_device_id( id ) {}
215 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
220 static int is_initialized();
223 static void initialize(
const SelectDevice = SelectDevice()
224 ,
const size_t num_instances = 1 );
226 static void impl_finalize();
230 static int impl_is_initialized();
233 static void impl_initialize(
const SelectDevice = SelectDevice()
234 ,
const size_t num_instances = 1 );
240 static size_type device_arch();
243 static size_type detect_device_count();
248 static std::vector<unsigned> detect_device_arch();
250 cudaStream_t cuda_stream()
const;
251 int cuda_device()
const;
256 static const char* name();
258 inline Impl::CudaInternal* impl_internal_space_instance()
const {
return m_space_instance; }
261 Impl::CudaInternal* m_space_instance;
273 struct MemorySpaceAccess
275 , Kokkos::Cuda::scratch_memory_space
278 enum { assignable =
false };
279 enum { accessible =
true };
280 enum { deepcopy =
false };
283 #if defined( KOKKOS_ENABLE_CUDA_UVM )
292 struct MemorySpaceAccess
293 < Kokkos::CudaUVMSpace
294 , Kokkos::Cuda::scratch_memory_space
297 enum { assignable =
false };
298 enum { accessible =
true };
299 enum { deepcopy =
false };
306 struct VerifyExecutionCanAccessMemorySpace
308 , Kokkos::Cuda::scratch_memory_space
311 enum { value =
true };
312 KOKKOS_INLINE_FUNCTION
static void verify(
void ) { }
313 KOKKOS_INLINE_FUNCTION
static void verify(
const void * ) { }
317 struct VerifyExecutionCanAccessMemorySpace
319 , Kokkos::Cuda::scratch_memory_space
322 enum { value =
false };
323 inline static void verify(
void ) { CudaSpace::access_error(); }
324 inline static void verify(
const void * p ) { CudaSpace::access_error(p); }
333 #include <Cuda/Kokkos_Cuda_KernelLaunch.hpp>
334 #include <Cuda/Kokkos_Cuda_Instance.hpp>
335 #include <Cuda/Kokkos_Cuda_View.hpp>
336 #include <Cuda/Kokkos_Cuda_Team.hpp>
337 #include <Cuda/Kokkos_Cuda_Parallel.hpp>
338 #include <Cuda/Kokkos_Cuda_Task.hpp>
339 #include <Cuda/Kokkos_Cuda_UniqueToken.hpp>
341 #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.