#ifndef KOKKOS_CUDA_HPP
#define KOKKOS_CUDA_HPP
#include <Kokkos_Macros.hpp>
#if defined( KOKKOS_ENABLE_CUDA )
#include <Kokkos_Core_fwd.hpp>
#include <iosfwd>
#include <vector>
#include <impl/Kokkos_AnalyzePolicy.hpp>
#include <Kokkos_CudaSpace.hpp>
#include <Kokkos_Parallel.hpp>
#include <Kokkos_TaskScheduler.hpp>
#include <Kokkos_Layout.hpp>
#include <Kokkos_ScratchSpace.hpp>
#include <Kokkos_MemoryTraits.hpp>
#include <impl/Kokkos_Tags.hpp>
namespace Kokkos {
namespace Impl {
class CudaExec ;
class CudaInternal ;
} }
namespace Kokkos {
namespace Impl {
namespace Experimental {
enum class CudaLaunchMechanism:unsigned{Default=0,ConstantMemory=1,GlobalMemory=2,LocalMemory=4};
constexpr inline CudaLaunchMechanism operator | (CudaLaunchMechanism p1, CudaLaunchMechanism p2) {
return static_cast<CudaLaunchMechanism>(static_cast<unsigned>(p1) | static_cast<unsigned>(p2));
}
constexpr inline CudaLaunchMechanism operator & (CudaLaunchMechanism p1, CudaLaunchMechanism p2) {
return static_cast<CudaLaunchMechanism>(static_cast<unsigned>(p1) & static_cast<unsigned>(p2));
}
template<CudaLaunchMechanism l>
struct CudaDispatchProperties {
CudaLaunchMechanism launch_mechanism = l;
};
}
}
class Cuda {
public:
typedef Cuda execution_space ;
#if defined( KOKKOS_ENABLE_CUDA_UVM )
typedef CudaUVMSpace memory_space ;
#else
typedef CudaSpace memory_space ;
#endif
typedef Kokkos::Device<execution_space,memory_space> device_type;
typedef memory_space::size_type size_type ;
typedef LayoutLeft array_layout ;
typedef ScratchMemorySpace< Cuda > scratch_memory_space ;
KOKKOS_INLINE_FUNCTION static int in_parallel() {
#if defined( __CUDA_ARCH__ )
return true;
#else
return false;
#endif
}
static bool sleep();
static bool wake();
static void impl_static_fence();
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE
static void fence();
#else
void fence() const;
#endif
static int concurrency();
static void print_configuration( std::ostream & , const bool detail = false );
KOKKOS_INLINE_FUNCTION
~Cuda() {}
Cuda();
Cuda( Cuda && ) = default ;
Cuda( const Cuda & ) = default ;
Cuda & operator = ( Cuda && ) = default ;
Cuda & operator = ( const Cuda & ) = default ;
Cuda(cudaStream_t stream);
struct SelectDevice {
int cuda_device_id ;
SelectDevice() : cuda_device_id(0) {}
explicit SelectDevice( int id ) : cuda_device_id( id ) {}
};
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE
static void finalize();
static int is_initialized();
static void initialize( const SelectDevice = SelectDevice()
, const size_t num_instances = 1 );
#else
static void impl_finalize();
static int impl_is_initialized();
static void impl_initialize( const SelectDevice = SelectDevice()
, const size_t num_instances = 1 );
#endif
static size_type device_arch();
static size_type detect_device_count();
static std::vector<unsigned> detect_device_arch();
cudaStream_t cuda_stream() const;
int cuda_device() const;
static const char* name();
inline Impl::CudaInternal* impl_internal_space_instance() const { return m_space_instance; }
private:
Impl::CudaInternal* m_space_instance;
};
}
namespace Kokkos {
namespace Impl {
template<>
struct MemorySpaceAccess
< Kokkos::CudaSpace
, Kokkos::Cuda::scratch_memory_space
>
{
enum { assignable = false };
enum { accessible = true };
enum { deepcopy = false };
};
#if defined( KOKKOS_ENABLE_CUDA_UVM )
template<>
struct MemorySpaceAccess
< Kokkos::CudaUVMSpace
, Kokkos::Cuda::scratch_memory_space
>
{
enum { assignable = false };
enum { accessible = true };
enum { deepcopy = false };
};
#endif
template<>
struct VerifyExecutionCanAccessMemorySpace
< Kokkos::CudaSpace
, Kokkos::Cuda::scratch_memory_space
>
{
enum { value = true };
KOKKOS_INLINE_FUNCTION static void verify( void ) { }
KOKKOS_INLINE_FUNCTION static void verify( const void * ) { }
};
template<>
struct VerifyExecutionCanAccessMemorySpace
< Kokkos::HostSpace
, Kokkos::Cuda::scratch_memory_space
>
{
enum { value = false };
inline static void verify( void ) { CudaSpace::access_error(); }
inline static void verify( const void * p ) { CudaSpace::access_error(p); }
};
} }
#include <Cuda/Kokkos_Cuda_KernelLaunch.hpp>
#include <Cuda/Kokkos_Cuda_Instance.hpp>
#include <Cuda/Kokkos_Cuda_View.hpp>
#include <Cuda/Kokkos_Cuda_Team.hpp>
#include <Cuda/Kokkos_Cuda_Parallel.hpp>
#include <Cuda/Kokkos_Cuda_Task.hpp>
#include <Cuda/Kokkos_Cuda_UniqueToken.hpp>
#include <KokkosExp_MDRangePolicy.hpp>
#endif
#endif