19#define MFEM_HIP_BLOCKS 256
22#define MFEM_USE_CUDA_OR_HIP
23#define MFEM_DEVICE __device__
24#define MFEM_LAMBDA __host__ __device__
26#define MFEM_DEVICE_SYNC MFEM_GPU_CHECK(hipDeviceSynchronize())
27#define MFEM_STREAM_SYNC MFEM_GPU_CHECK(hipStreamSynchronize(0))
31#define MFEM_GPU_CHECK(x) \
34 hipError_t err = (x); \
35 if (err != hipSuccess) \
37 mfem_hip_error(err, #x, _MFEM_FUNC_NAME, __FILE__, __LINE__); \
44#if defined(MFEM_USE_HIP) && defined(__HIP_DEVICE_COMPILE__)
45#define MFEM_SHARED __shared__
46#define MFEM_SYNC_THREAD __syncthreads()
47#define MFEM_BLOCK_ID(k) hipBlockIdx_ ##k
48#define MFEM_THREAD_ID(k) hipThreadIdx_ ##k
49#define MFEM_THREAD_SIZE(k) hipBlockDim_ ##k
50#define MFEM_FOREACH_THREAD(i,k,N) \
51 for(int i=hipThreadIdx_ ##k; i<N; i+=hipBlockDim_ ##k)
60 const char *file,
int line);
79void*
HipMemcpyHtoD(
void *d_dst,
const void *h_src,
size_t bytes);
85void*
HipMemcpyDtoD(
void *d_dst,
const void *d_src,
size_t bytes);
91void*
HipMemcpyDtoH(
void *h_dst,
const void *d_src,
size_t bytes);
void * HipMemcpyDtoD(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.
void * HipMemcpyDtoDAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.
void * HipMemAllocHostPinned(void **ptr, size_t bytes)
Allocates page-locked (pinned) host memory.
void * HipMemcpyHtoDAsync(void *dst, const void *src, size_t bytes)
Copies memory from Host to Device.
void HipCheckLastError()
Check the error code returned by hipGetLastError(), aborting on error.
void * HipMemcpyHtoD(void *dst, const void *src, size_t bytes)
Copies memory from Host to Device.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void * HipMemFree(void *dptr)
Frees device memory.
int HipGetDeviceCount()
Get the number of HIP devices.
void * HipMemcpyDtoH(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.
void * HipMemFreeHostPinned(void *ptr)
Frees page-locked (pinned) host memory and returns destination ptr.
void * HipMallocManaged(void **dptr, size_t bytes)
Allocates managed device memory.
void * HipMemcpyDtoHAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.
void * HipMemAlloc(void **dptr, size_t bytes)
Allocates device memory.
void mfem_hip_error(hipError_t err, const char *expr, const char *func, const char *file, int line)