19#define MFEM_HIP_BLOCKS 256
22#define MFEM_USE_CUDA_OR_HIP
23#define MFEM_DEVICE __device__
24#define MFEM_HOST __host__
25#define MFEM_LAMBDA __host__ __device__
27#define MFEM_DEVICE_SYNC MFEM_GPU_CHECK(hipDeviceSynchronize())
28#define MFEM_STREAM_SYNC MFEM_GPU_CHECK(hipStreamSynchronize(0))
32#define MFEM_GPU_CHECK(x) \
34 hipError_t mfem_err_internal_var_name = (x); \
35 if (mfem_err_internal_var_name != hipSuccess) { \
36 ::mfem::mfem_hip_error(mfem_err_internal_var_name, #x, _MFEM_FUNC_NAME, \
37 __FILE__, __LINE__); \
43#if defined(MFEM_USE_HIP) && defined(__HIP_DEVICE_COMPILE__)
44#define MFEM_SHARED __shared__
45#define MFEM_SYNC_THREAD __syncthreads()
46#define MFEM_BLOCK_ID(k) hipBlockIdx_ ##k
47#define MFEM_THREAD_ID(k) hipThreadIdx_ ##k
48#define MFEM_THREAD_SIZE(k) hipBlockDim_ ##k
49#define MFEM_FOREACH_THREAD(i,k,N) \
50 for(int i=hipThreadIdx_ ##k; i<N; i+=hipBlockDim_ ##k)
59 const char *file,
int line);
78void*
HipMemcpyHtoD(
void *d_dst,
const void *h_src,
size_t bytes);
84void*
HipMemcpyDtoD(
void *d_dst,
const void *d_src,
size_t bytes);
90void*
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)