24 const char *file,
int line)
26 mfem::err <<
"\n\nHIP error: (" << expr <<
") failed with error:\n --> "
27 << hipGetErrorString(
err)
28 <<
"\n ... in function: " << func
29 <<
"\n ... in file: " << file <<
':' << line <<
'\n';
37#ifdef MFEM_TRACK_HIP_MEM
38 mfem::out <<
"HipMemAlloc(): allocating " << bytes <<
" bytes ... "
41 MFEM_GPU_CHECK(hipMalloc(dptr, bytes));
42#ifdef MFEM_TRACK_HIP_MEM
43 mfem::out <<
"done: " << *dptr << std::endl;
52#ifdef MFEM_TRACK_HIP_MEM
53 mfem::out <<
"HipMallocManaged(): allocating " << bytes <<
" bytes ... "
56 MFEM_GPU_CHECK(hipMallocManaged(dptr, bytes));
57#ifdef MFEM_TRACK_HIP_MEM
58 mfem::out <<
"done: " << *dptr << std::endl;
67#ifdef MFEM_TRACK_HIP_MEM
68 mfem::out <<
"HipMemAllocHostPinned(): allocating " << bytes <<
" bytes ... "
71 MFEM_GPU_CHECK(hipHostMalloc(ptr, bytes, hipHostMallocDefault));
72#ifdef MFEM_TRACK_HIP_MEM
73 mfem::out <<
"done: " << *ptr << std::endl;
82#ifdef MFEM_TRACK_HIP_MEM
83 mfem::out <<
"HipMemFree(): deallocating memory @ " << dptr <<
" ... "
86 MFEM_GPU_CHECK(hipFree(dptr));
87#ifdef MFEM_TRACK_HIP_MEM
97#ifdef MFEM_TRACK_HIP_MEM
98 mfem::out <<
"HipMemFreeHostPinned(): deallocating memory @ " << ptr <<
" ... "
101 MFEM_GPU_CHECK(hipHostFree(ptr));
102#ifdef MFEM_TRACK_HIP_MEM
112#ifdef MFEM_TRACK_HIP_MEM
113 mfem::out <<
"HipMemcpyHtoD(): copying " << bytes <<
" bytes from "
114 << src <<
" to " << dst <<
" ... " << std::flush;
116 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyHostToDevice));
117#ifdef MFEM_TRACK_HIP_MEM
127 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyHostToDevice));
135#ifdef MFEM_TRACK_HIP_MEM
136 mfem::out <<
"HipMemcpyDtoD(): copying " << bytes <<
" bytes from "
137 << src <<
" to " << dst <<
" ... " << std::flush;
139 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyDeviceToDevice));
140#ifdef MFEM_TRACK_HIP_MEM
150 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToDevice));
158#ifdef MFEM_TRACK_HIP_MEM
159 mfem::out <<
"HipMemcpyDtoH(): copying " << bytes <<
" bytes from "
160 << src <<
" to " << dst <<
" ... " << std::flush;
162 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyDeviceToHost));
163#ifdef MFEM_TRACK_HIP_MEM
173 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToHost));
181 MFEM_GPU_CHECK(hipGetLastError());
189 MFEM_GPU_CHECK(hipGetDeviceCount(&num_gpus));
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 mfem_error(const char *msg)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
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)