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 <<
"HipMemFree(): deallocating memory @ " << dptr <<
" ... "
71 MFEM_GPU_CHECK(hipFree(dptr));
72 #ifdef MFEM_TRACK_HIP_MEM
82 #ifdef MFEM_TRACK_HIP_MEM
83 mfem::out <<
"HipMemcpyHtoD(): copying " << bytes <<
" bytes from "
84 << src <<
" to " << dst <<
" ... " << std::flush;
86 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyHostToDevice));
87 #ifdef MFEM_TRACK_HIP_MEM
97 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyHostToDevice));
105 #ifdef MFEM_TRACK_HIP_MEM
106 mfem::out <<
"HipMemcpyDtoD(): copying " << bytes <<
" bytes from "
107 << src <<
" to " << dst <<
" ... " << std::flush;
109 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyDeviceToDevice));
110 #ifdef MFEM_TRACK_HIP_MEM
120 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToDevice));
128 #ifdef MFEM_TRACK_HPI_MEM
129 mfem::out <<
"HipMemcpyDtoH(): copying " << bytes <<
" bytes from "
130 << src <<
" to " << dst <<
" ... " << std::flush;
132 MFEM_GPU_CHECK(hipMemcpy(dst, src, bytes, hipMemcpyDeviceToHost));
133 #ifdef MFEM_TRACK_HIP_MEM
143 MFEM_GPU_CHECK(hipMemcpyAsync(dst, src, bytes, hipMemcpyDeviceToHost));
151 MFEM_GPU_CHECK(hipGetLastError());
159 MFEM_GPU_CHECK(hipGetDeviceCount(&num_gpus));
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 mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
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.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...