24 const char *file,
int line)
26 mfem::err <<
"\n\nCUDA error: (" << expr <<
") failed with error:\n --> "
27 << cudaGetErrorString(err)
28 <<
"\n ... in function: " << func
29 <<
"\n ... in file: " << file <<
':' << line <<
'\n';
37 #ifdef MFEM_TRACK_CUDA_MEM
38 mfem::out <<
"CuMemAlloc(): allocating " << bytes <<
" bytes ... "
41 MFEM_CUDA_CHECK(cudaMalloc(dptr, bytes));
42 #ifdef MFEM_TRACK_CUDA_MEM
43 mfem::out <<
"done: " << *dptr << std::endl;
52 #ifdef MFEM_TRACK_CUDA_MEM
53 mfem::out <<
"CuMemFree(): deallocating memory @ " << dptr <<
" ... "
56 MFEM_CUDA_CHECK(cudaFree(dptr));
57 #ifdef MFEM_TRACK_CUDA_MEM
67 #ifdef MFEM_TRACK_CUDA_MEM
68 mfem::out <<
"CuMemcpyHtoD(): copying " << bytes <<
" bytes from "
69 << src <<
" to " << dst <<
" ... " << std::flush;
71 MFEM_CUDA_CHECK(cudaMemcpy(dst, src, bytes, cudaMemcpyHostToDevice));
72 #ifdef MFEM_TRACK_CUDA_MEM
82 MFEM_CUDA_CHECK(cudaMemcpyAsync(dst, src, bytes, cudaMemcpyHostToDevice));
90 #ifdef MFEM_TRACK_CUDA_MEM
91 mfem::out <<
"CuMemcpyDtoD(): copying " << bytes <<
" bytes from "
92 << src <<
" to " << dst <<
" ... " << std::flush;
94 MFEM_CUDA_CHECK(cudaMemcpy(dst, src, bytes, cudaMemcpyDeviceToDevice));
95 #ifdef MFEM_TRACK_CUDA_MEM
105 MFEM_CUDA_CHECK(cudaMemcpyAsync(dst, src, bytes, cudaMemcpyDeviceToDevice));
113 #ifdef MFEM_TRACK_CUDA_MEM
114 mfem::out <<
"CuMemcpyDtoH(): copying " << bytes <<
" bytes from "
115 << src <<
" to " << dst <<
" ... " << std::flush;
117 MFEM_CUDA_CHECK(cudaMemcpy(dst, src, bytes, cudaMemcpyDeviceToHost));
118 #ifdef MFEM_TRACK_CUDA_MEM
128 MFEM_CUDA_CHECK(cudaMemcpyAsync(dst, src, bytes, cudaMemcpyDeviceToHost));
void * CuMemcpyHtoD(void *dst, const void *src, size_t bytes)
Copies memory from Host to Device.
void * CuMemFree(void *dptr)
Frees device memory.
void mfem_cuda_error(cudaError_t err, const char *expr, const char *func, const char *file, int line)
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
void * CuMemcpyDtoD(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.
void * CuMemcpyDtoDAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Device.
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
void * CuMemcpyDtoHAsync(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.
void * CuMemcpyHtoDAsync(void *dst, const void *src, size_t bytes)
Copies memory from Host to Device.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void * CuMemAlloc(void **dptr, size_t bytes)
Allocates device memory.
void * CuMemcpyDtoH(void *dst, const void *src, size_t bytes)
Copies memory from Device to Host.