diff --git a/pfsimulator/amps/cuda/amps.h b/pfsimulator/amps/cuda/amps.h index 23e15996e..96ef6456a 100644 --- a/pfsimulator/amps/cuda/amps.h +++ b/pfsimulator/amps/cuda/amps.h @@ -1060,23 +1060,7 @@ static inline void amps_cuda_error(cudaError_t err, const char *file, int line) } #ifdef PARFLOW_HAVE_RMM -#include -/** - * @brief RMM error handling. - * - * If error detected, print error message and exit. - * - * @param expr RMM error (of type rmmError_t) [IN] - */ -#define RMM_ERRCHK(err) (amps_rmm_error(err, __FILE__, __LINE__)) -static inline void amps_rmm_error(rmmError_t err, const char *file, int line) -{ - if (err != RMM_SUCCESS) - { - printf("\n\n%s in %s at line %d\n", rmmGetErrorString(err), file, line); - exit(1); - } -} +#include "rmm_wrapper.h" #endif /*-------------------------------------------------------------------------- @@ -1171,7 +1155,7 @@ static inline void *_amps_talloc_cuda(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #else CUDA_ERRCHK(cudaMallocManaged((void**)&ptr, size, cudaMemAttachGlobal)); // CUDA_ERRCHK(cudaHostAlloc((void**)&ptr, size, cudaHostAllocMapped)); @@ -1195,7 +1179,7 @@ static inline void *_amps_ctalloc_cuda(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(ptr); #else CUDA_ERRCHK(cudaMallocManaged((void**)&ptr, size, cudaMemAttachGlobal)); // CUDA_ERRCHK(cudaHostAlloc((void**)&ptr, size, cudaHostAllocMapped)); @@ -1216,7 +1200,7 @@ static inline void *_amps_ctalloc_cuda(size_t size) static inline void _amps_tfree_cuda(void *ptr) { #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmFree(ptr, 0, __FILE__, __LINE__)); + rmmFree(ptr); #else CUDA_ERRCHK(cudaFree(ptr)); // CUDA_ERRCHK(cudaFreeHost(ptr)); diff --git a/pfsimulator/amps/mpi1/amps.h b/pfsimulator/amps/mpi1/amps.h index 7040058a2..15ae193a4 100644 --- a/pfsimulator/amps/mpi1/amps.h +++ b/pfsimulator/amps/mpi1/amps.h @@ -56,7 +56,7 @@ #include #endif #ifdef PARFLOW_HAVE_RMM -#include +#include "rmm_wrapper.h" #endif /* @@ -1081,24 +1081,6 @@ static inline void amps_cuda_error(cudaError_t err, const char *file, int line) } #endif // PARFLOW_HAVE_CUDA -#ifdef PARFLOW_HAVE_RMM -/** - * @brief RMM error handling - * - * If error detected, print error message and exit. - * - * @param expr RMM error (of type rmmError_t) [IN] - */ -#define RMM_ERRCHK(err) (amps_rmm_error(err, __FILE__, __LINE__)) -static inline void amps_rmm_error(rmmError_t err, const char *file, int line) -{ - if (err != RMM_SUCCESS) - { - printf("\n\n%s in %s at line %d\n", rmmGetErrorString(err), file, line); - exit(1); - } -} -#endif // PARFLOW_HAVE_RMM /*-------------------------------------------------------------------------- * Define static unified memory allocation routines for devices @@ -1139,7 +1121,7 @@ static inline void *_amps_talloc_device(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #elif defined(PARFLOW_HAVE_KOKKOS) ptr = kokkosUVMAlloc(size); #elif defined(PARFLOW_HAVE_CUDA) @@ -1165,7 +1147,7 @@ static inline void *_amps_ctalloc_device(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #elif defined(PARFLOW_HAVE_KOKKOS) ptr = kokkosUVMAlloc(size); #elif defined(PARFLOW_HAVE_CUDA) @@ -1193,7 +1175,7 @@ static inline void *_amps_ctalloc_device(size_t size) static inline void _amps_tfree_device(void *ptr) { #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmFree(ptr, 0, __FILE__, __LINE__)); + rmmFree(ptr); #elif defined(PARFLOW_HAVE_KOKKOS) kokkosUVMFree(ptr); #elif defined(PARFLOW_HAVE_CUDA) diff --git a/pfsimulator/amps/oas3/amps.h b/pfsimulator/amps/oas3/amps.h index ff7d6a284..a38275d52 100644 --- a/pfsimulator/amps/oas3/amps.h +++ b/pfsimulator/amps/oas3/amps.h @@ -56,7 +56,7 @@ #include #endif #ifdef PARFLOW_HAVE_RMM -#include +#include "rmm_wrapper.h" #endif /* @@ -1112,25 +1112,6 @@ static inline void amps_cuda_error(cudaError_t err, const char *file, int line) } #endif // PARFLOW_HAVE_CUDA -#ifdef PARFLOW_HAVE_RMM -/** - * @brief RMM error handling - * - * If error detected, print error message and exit. - * - * @param expr RMM error (of type rmmError_t) [IN] - */ -#define RMM_ERRCHK(err) (amps_rmm_error(err, __FILE__, __LINE__)) -static inline void amps_rmm_error(rmmError_t err, const char *file, int line) -{ - if (err != RMM_SUCCESS) - { - printf("\n\n%s in %s at line %d\n", rmmGetErrorString(err), file, line); - exit(1); - } -} -#endif // PARFLOW_HAVE_RMM - /*-------------------------------------------------------------------------- * Define static unified memory allocation routines for devices *--------------------------------------------------------------------------*/ @@ -1170,7 +1151,7 @@ static inline void *_amps_talloc_device(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #elif defined(PARFLOW_HAVE_KOKKOS) ptr = kokkosUVMAlloc(size); #elif defined(PARFLOW_HAVE_CUDA) @@ -1196,7 +1177,7 @@ static inline void *_amps_ctalloc_device(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #elif defined(PARFLOW_HAVE_KOKKOS) ptr = kokkosUVMAlloc(size); #elif defined(PARFLOW_HAVE_CUDA) @@ -1224,7 +1205,7 @@ static inline void *_amps_ctalloc_device(size_t size) static inline void _amps_tfree_device(void *ptr) { #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmFree(ptr, 0, __FILE__, __LINE__)); + rmmFree(ptr); #elif defined(PARFLOW_HAVE_KOKKOS) kokkosUVMFree(ptr); #elif defined(PARFLOW_HAVE_CUDA) diff --git a/pfsimulator/amps/smpi/amps.h b/pfsimulator/amps/smpi/amps.h index 38ec55a5c..2aa511d8f 100644 --- a/pfsimulator/amps/smpi/amps.h +++ b/pfsimulator/amps/smpi/amps.h @@ -51,7 +51,7 @@ #include #include #ifdef PARFLOW_HAVE_RMM -#include +#include "rmm_wrapper.h" #endif #endif @@ -1088,25 +1088,6 @@ static inline void amps_cuda_error(cudaError_t err, const char *file, int line) } } -#ifdef PARFLOW_HAVE_RMM -/** - * @brief RMM error handling. - * - * If error detected, print error message and exit. - * - * @param expr RMM error (of type rmmError_t) [IN] - */ -#define RMM_ERRCHK(err) (amps_rmm_error(err, __FILE__, __LINE__)) -static inline void amps_rmm_error(rmmError_t err, const char *file, int line) -{ - if (err != RMM_SUCCESS) - { - printf("\n\n%s in %s at line %d\n", rmmGetErrorString(err), file, line); - exit(1); - } -} -#endif - /*-------------------------------------------------------------------------- * Define static unified memory allocation routines for CUDA *--------------------------------------------------------------------------*/ @@ -1126,7 +1107,7 @@ static inline void *_amps_talloc_cuda(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #else CUDA_ERRCHK(cudaMallocManaged((void**)&ptr, size, cudaMemAttachGlobal)); // CUDA_ERRCHK(cudaHostAlloc((void**)&ptr, size, cudaHostAllocMapped)); @@ -1150,7 +1131,7 @@ static inline void *_amps_ctalloc_cuda(size_t size) void *ptr = NULL; #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmAlloc(&ptr, size, 0, __FILE__, __LINE__)); + ptr = rmmAlloc(size); #else CUDA_ERRCHK(cudaMallocManaged((void**)&ptr, size, cudaMemAttachGlobal)); // CUDA_ERRCHK(cudaHostAlloc((void**)&ptr, size, cudaHostAllocMapped)); @@ -1171,7 +1152,7 @@ static inline void *_amps_ctalloc_cuda(size_t size) static inline void _amps_tfree_cuda(void *ptr) { #ifdef PARFLOW_HAVE_RMM - RMM_ERRCHK(rmmFree(ptr, 0, __FILE__, __LINE__)); + rmmFree(ptr); #else CUDA_ERRCHK(cudaFree(ptr)); // CUDA_ERRCHK(cudaFreeHost(ptr)); diff --git a/pfsimulator/parflow_exe/main.c b/pfsimulator/parflow_exe/main.c index 81bb4bb27..91c89f55e 100644 --- a/pfsimulator/parflow_exe/main.c +++ b/pfsimulator/parflow_exe/main.c @@ -176,14 +176,15 @@ int main(int argc, char *argv []) /*----------------------------------------------------------------------- * Initialize RMM pool allocator *-----------------------------------------------------------------------*/ -#ifdef PARFLOW_HAVE_RMM + //#ifdef PARFLOW_HAVE_RMM // RMM - rmmOptions_t rmmOptions; - rmmOptions.allocation_mode = (rmmAllocationMode_t)(PoolAllocation | CudaManagedMemory); - rmmOptions.initial_pool_size = 1; // size = 0 initializes half the device memory - rmmOptions.enable_logging = false; - RMM_ERR(rmmInitialize(&rmmOptions)); -#endif // PARFLOW_HAVE_RMM + // rmmOptions_t rmmOptions; + // rmmOptions.allocation_mode = (rmmAllocationMode_t)(PoolAllocation | CudaManagedMemory); + // rmmOptions.initial_pool_size = 1; // size = 0 initializes half the device memory + // rmmOptions.enable_logging = false; + // RMM_ERR(rmmInitialize(&rmmOptions)); + rmmInit(); + //#endif // PARFLOW_HAVE_RMM wall_clock_time = amps_Clock();