15 #include "../config/config.hpp"
19 #define MFEM_HIP_BLOCKS 256
22 #define MFEM_DEVICE __device__
23 #define MFEM_LAMBDA __host__ __device__
24 #define MFEM_HOST_DEVICE __host__ __device__
25 #define MFEM_DEVICE_SYNC MFEM_GPU_CHECK(hipDeviceSynchronize())
26 #define MFEM_STREAM_SYNC MFEM_GPU_CHECK(hipStreamSynchronize(0))
30 #define MFEM_GPU_CHECK(x) \
33 hipError_t err = (x); \
34 if (err != hipSuccess) \
36 mfem_hip_error(err, #x, _MFEM_FUNC_NAME, __FILE__, __LINE__); \
40 #endif // MFEM_USE_HIP
43 #if defined(MFEM_USE_HIP) && defined(__HIP_DEVICE_COMPILE__)
44 #define MFEM_SHARED __shared__
45 #define MFEM_SYNC_THREAD __syncthreads()
46 #define MFEM_THREAD_ID(k) hipThreadIdx_ ##k
47 #define MFEM_THREAD_SIZE(k) hipBlockDim_ ##k
48 #define MFEM_FOREACH_THREAD(i,k,N) \
49 for(int i=hipThreadIdx_ ##k; i<N; i+=hipBlockDim_ ##k)
58 const char *file,
int line);
71 void*
HipMemcpyHtoD(
void *d_dst,
const void *h_src,
size_t bytes);
77 void*
HipMemcpyDtoD(
void *d_dst,
const void *d_src,
size_t bytes);
83 void*
HipMemcpyDtoH(
void *h_dst,
const void *d_src,
size_t bytes);
96 #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.