Skip to content

Commit

Permalink
check for GPU-aware support
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWibking committed Jan 29, 2025
1 parent 73ead89 commit cc4ea66
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Src/Base/AMReX_ParallelDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

#ifdef BL_USE_MPI
#include <AMReX_ccse-mpi.H>
#if __has_include(<mpi-ext.h>) && defined(OPEN_MPI)
# include <mpi-ext.h>
#endif
#endif

#ifdef AMREX_PMI
Expand Down Expand Up @@ -57,7 +60,7 @@ namespace amrex::ParallelDescriptor {
#endif

#ifdef AMREX_USE_GPU
bool use_gpu_aware_mpi = true;
bool use_gpu_aware_mpi = false;
#else
bool use_gpu_aware_mpi = false;
#endif
Expand Down Expand Up @@ -1510,6 +1513,28 @@ ReadAndBcastFile (const std::string& filename, Vector<char>& charBuf,
void
Initialize ()
{
#if defined(AMREX_USE_CUDA)

#if (defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA) || (defined(MPICH) && defined(MPIX_GPU_SUPPORT_CUDA))
use_gpu_aware_mpi = (bool) MPIX_Query_cuda_support();
#endif

#elif defined(AMREX_USE_HIP)

#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
use_gpu_aware_mpi = (bool) MPIX_Query_rocm_support();
#elif defined(MPICH) && defined(MPIX_GPU_SUPPORT_HIP)
use_gpu_aware_mpi = (bool) MPIX_Query_hip_support();
#endif

#elif defined(AMREX_USE_SYCL)

#if defined(MPICH) && defined(MPIX_GPU_SUPPORT_ZE)
use_gpu_aware_mpi = (bool) MPIX_Query_ze_support();
#endif

#endif

#ifndef BL_AMRPROF
ParmParse pp("amrex");
pp.queryAdd("use_gpu_aware_mpi", use_gpu_aware_mpi);
Expand Down

0 comments on commit cc4ea66

Please sign in to comment.