15 #include "../config/config.hpp"
19 #include <hip/hip_runtime.h>
23 #define MFEM_HIP_BLOCKS 256
26 #define MFEM_DEVICE __device__
27 #define MFEM_HOST_DEVICE __host__ __device__
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__); \
41 #define MFEM_DEVICE_SYNC MFEM_GPU_CHECK(hipDeviceSynchronize())
42 #define MFEM_STREAM_SYNC MFEM_GPU_CHECK(hipStreamSynchronize(0))
43 #endif // MFEM_USE_HIP
46 #if defined(MFEM_USE_HIP) && defined(__ROCM_ARCH__)
47 #define MFEM_SHARED __shared__
48 #define MFEM_SYNC_THREAD __syncthreads()
49 #define MFEM_THREAD_ID(k) hipThreadIdx_ ##k
50 #define MFEM_THREAD_SIZE(k) hipBlockDim_ ##k
51 #define MFEM_FOREACH_THREAD(i,k,N) for(int i=hipThreadIdx_ ##k; i<N; i+=hipBlockDim_ ##k)
60 const char *file,
int line);
73 void*
HipMemcpyHtoD(
void *d_dst,
const void *h_src,
size_t bytes);
79 void*
HipMemcpyDtoD(
void *d_dst,
const void *d_src,
size_t bytes);
85 void*
HipMemcpyDtoH(
void *h_dst,
const void *d_src,
size_t bytes);
98 #endif // MFEM_HIP_HPP
void * HipMallocManaged(void **dptr, size_t bytes)
Allocates managed device 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.
int HipGetDeviceCount()
Get the number of HIP devices.
void * HipMemcpyDtoDAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.
void * HipMemcpyDtoHAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.
void * HipMemFree(void *dptr)
Frees device memory.
void mfem_hip_error(hipError_t err, const char *expr, const char *func, const char *file, int line)
void * HipMemcpyDtoH(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.
void * HipMemAlloc(void **dptr, size_t bytes)
Allocates device memory.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void * HipMemcpyHtoD(void *dst, const void *src, size_t bytes)
Copies memory from Host to Device.
void * HipMemcpyDtoD(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.