#ifndef KOKKOS_ROCM_HPP
#define KOKKOS_ROCM_HPP
#include <Kokkos_Core_fwd.hpp>
#if defined( KOKKOS_ENABLE_ROCM )
class dim3 {
public:
int x,y,z;
dim3(int _x, int _y, int _z):x(_x),y(_y),z(_z) {};
};
#include <ROCm/hc_math_std.hpp>
#include <cstddef>
#include <iosfwd>
#include <Kokkos_HostSpace.hpp>
#include <Kokkos_ROCmSpace.hpp>
#include <ROCm/Kokkos_ROCm_Exec.hpp>
#include <Kokkos_ScratchSpace.hpp>
#include <Kokkos_Parallel.hpp>
#include <Kokkos_Layout.hpp>
#include <impl/Kokkos_Tags.hpp>
#include <hc.hpp>
#include <hc_am.hpp>
#include <amp_math.h>
#if defined( __HCC_ACCELERATOR__ )
using namespace ::Concurrency::precise_math ;
#endif
namespace Kokkos {
namespace Impl {
class ROCmExec ;
} }
namespace Kokkos {
namespace Experimental {
class ROCm {
public:
typedef ROCm execution_space ;
typedef ROCmSpace memory_space ;
typedef Kokkos::Device<execution_space,memory_space> device_type;
typedef LayoutLeft array_layout ;
typedef HostSpace::size_type size_type ;
typedef ScratchMemorySpace< ROCm > scratch_memory_space ;
~ROCm() {}
ROCm();
ROCm( ROCm && ) = default ;
ROCm( const ROCm & ) = default ;
ROCm & operator = ( ROCm && ) = default ;
ROCm & operator = ( const ROCm & ) = default ;
KOKKOS_INLINE_FUNCTION static int in_parallel() {
#if defined( __HCC_ACCELERATOR__ )
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 void print_configuration( std::ostream & , const bool detail = false );
static void finalize() ;
struct SelectDevice {
int rocm_device_id ;
SelectDevice() : rocm_device_id(1) {}
explicit SelectDevice( int id ) : rocm_device_id( id+1 ) {}
};
int rocm_device() const { return m_device ; }
bool isAPU();
bool isAPU(int device);
static void initialize( const SelectDevice = SelectDevice());
static int is_initialized();
static int concurrency() ;
static const char* name();
private:
int m_device ;
};
}
}
namespace Kokkos {
namespace Impl {
template<>
struct MemorySpaceAccess
< Kokkos::Experimental::ROCmSpace
, Kokkos::Experimental::ROCm::scratch_memory_space
>
{
enum { assignable = false };
enum { accessible = true };
enum { deepcopy = false };
};
template<>
struct VerifyExecutionCanAccessMemorySpace
< Kokkos::Experimental::ROCm::memory_space
, Kokkos::Experimental::ROCm::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::Experimental::ROCm::scratch_memory_space
>
{
enum { value = false };
inline static void verify( void ) { Kokkos::Experimental::ROCmSpace::access_error(); }
inline static void verify( const void * p ) { Kokkos::Experimental::ROCmSpace::access_error(p); }
};
} }
#define threadIdx_x (hc_get_workitem_id(0))
#define threadIdx_y (hc_get_workitem_id(1))
#define threadIdx_z (hc_get_workitem_id(2))
#define blockIdx_x (hc_get_group_id(0))
#define blockIdx_y (hc_get_group_id(1))
#define blockIdx_z (hc_get_group_id(2))
#define blockDim_x (hc_get_group_size(0))
#define blockDim_y (hc_get_group_size(1))
#define blockDim_z (hc_get_group_size(2))
#define gridDim_x (hc_get_num_groups(0))
#define gridDim_y (hc_get_num_groups(1))
#define gridDim_z (hc_get_num_groups(2))
#include <ROCm/Kokkos_ROCm_Parallel.hpp>
#include <ROCm/Kokkos_ROCm_Task.hpp>
#endif
#endif