Skip to content

Commit 779df09

Browse files
Enable GPU-aware MPI by default (#4318)
## Summary This turns on GPU-aware MPI by default. ## Additional background On all current machines, simulations run faster with GPU-aware MPI enabled. Two technical issues that prevented this are now resolved: AMReX now has the communication arena, which does not use managed memory, and SLURM no longer uses cgroup isolation for GPU bindings by default. Closes #2967. --------- Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
1 parent a208ef8 commit 779df09

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

Docs/sphinx_documentation/source/GPU.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ Finally, the parallel communication of particle data has been ported and optimiz
16431643
platforms. This includes :cpp:`Redistribute()`, which moves particles back to the proper grids after their positions
16441644
have changed, as well as :cpp:`fillNeighbors()` and :cpp:`updateNeighbors()`, which are used to exchange halo particles.
16451645
As with :cpp:`MultiFab` data, these have been designed to minimize host / device traffic as much as possible, and can
1646-
take advantage of the Cuda-aware MPI implementations available on platforms such as ORNL's Summit.
1646+
take advantage of the GPU-aware MPI implementations available on platforms such as ORNL's Frontier.
16471647

16481648

16491649
Profiling with GPUs
@@ -1742,17 +1742,18 @@ Inputs Parameters
17421742
The following inputs parameters control the behavior of amrex when running on GPUs. They should be prefaced
17431743
by "amrex" in your :cpp:`inputs` file.
17441744

1745-
+----------------------------+-----------------------------------------------------------------------+-------------+----------+
1746-
| | Description | Type | Default |
1747-
+============================+=======================================================================+=============+==========+
1748-
| use_gpu_aware_mpi | Whether to use GPU memory for communication buffers during MPI calls. | Bool | 0 |
1749-
| | If true, the buffers will use device memory. If false (i.e., 0), they | | |
1750-
| | will use pinned memory. In practice, we find it is not always worth | | |
1751-
| | it to use GPU aware MPI. | | |
1752-
+----------------------------+-----------------------------------------------------------------------+-------------+----------+
1753-
| abort_on_out_of_gpu_memory | If the size of free memory on the GPU is less than the size of a | Bool | 0 |
1754-
| | requested allocation, AMReX will call AMReX::Abort() with an error | | |
1755-
| | describing how much free memory there is and what was requested. | | |
1756-
+----------------------------+-----------------------------------------------------------------------+-------------+----------+
1757-
| the_arena_is_managed | Whether :cpp:`The_Arena()` allocates managed memory. | Bool | 0 |
1758-
+----------------------------+-----------------------------------------------------------------------+-------------+----------+
1745+
+----------------------------+-----------------------------------------------------------------------+-------------+----------------+
1746+
| | Description | Type | Default |
1747+
+============================+=======================================================================+=============+================+
1748+
| use_gpu_aware_mpi | Whether to use GPU memory for communication buffers during MPI calls. | Bool | MPI-dependent |
1749+
| | If true, the buffers will use device memory. If false (i.e., 0), they | | |
1750+
| | will use pinned memory. It will be activated if AMReX detects that | | |
1751+
| | GPU-aware MPI is supported by the MPI library (MPICH, OpenMPI, and | | |
1752+
| | derivative implementations). | | |
1753+
+----------------------------+-----------------------------------------------------------------------+-------------+----------------+
1754+
| abort_on_out_of_gpu_memory | If the size of free memory on the GPU is less than the size of a | Bool | 0 |
1755+
| | requested allocation, AMReX will call AMReX::Abort() with an error | | |
1756+
| | describing how much free memory there is and what was requested. | | |
1757+
+----------------------------+-----------------------------------------------------------------------+-------------+----------------+
1758+
| the_arena_is_managed | Whether :cpp:`The_Arena()` allocates managed memory. | Bool | 0 |
1759+
+----------------------------+-----------------------------------------------------------------------+-------------+----------------+

Src/Base/AMReX_ParallelDescriptor.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
#ifdef BL_USE_MPI
1212
#include <AMReX_ccse-mpi.H>
13+
#if __has_include(<mpi-ext.h>) && defined(OPEN_MPI)
14+
# include <mpi-ext.h>
15+
#endif
1316
#endif
1417

1518
#ifdef AMREX_PMI
@@ -1510,6 +1513,34 @@ ReadAndBcastFile (const std::string& filename, Vector<char>& charBuf,
15101513
void
15111514
Initialize ()
15121515
{
1516+
#if defined(AMREX_USE_CUDA)
1517+
1518+
#if (defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA) || (defined(MPICH) && defined(MPIX_GPU_SUPPORT_CUDA))
1519+
use_gpu_aware_mpi = (bool) MPIX_Query_cuda_support();
1520+
#endif
1521+
1522+
#elif defined(AMREX_USE_HIP)
1523+
1524+
#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
1525+
use_gpu_aware_mpi = (bool) MPIX_Query_rocm_support();
1526+
#elif defined(MPICH) && defined(MPIX_GPU_SUPPORT_HIP)
1527+
int is_supported = 0;
1528+
if (MPIX_GPU_query_support(MPIX_GPU_SUPPORT_HIP, &is_supported) == MPI_SUCCESS) {
1529+
use_gpu_aware_mpi = (bool) is_supported;
1530+
}
1531+
#endif
1532+
1533+
#elif defined(AMREX_USE_SYCL)
1534+
1535+
#if defined(MPICH) && defined(MPIX_GPU_SUPPORT_ZE)
1536+
int is_supported = 0;
1537+
if (MPIX_GPU_query_support(MPIX_GPU_SUPPORT_ZE, &is_supported) == MPI_SUCCESS) {
1538+
use_gpu_aware_mpi = (bool) is_supported;
1539+
}
1540+
#endif
1541+
1542+
#endif
1543+
15131544
#ifndef BL_AMRPROF
15141545
ParmParse pp("amrex");
15151546
pp.queryAdd("use_gpu_aware_mpi", use_gpu_aware_mpi);

0 commit comments

Comments
 (0)