Skip to content

Commit

Permalink
Merge pull request #1209 from arcaneframework/dev/gg-add-support-for-…
Browse files Browse the repository at this point in the history
…rocm-aware-mpi

Add detection for 'GPU-aware' MPI for HIP/ROCM
  • Loading branch information
grospelliergilles authored Feb 23, 2024
2 parents 0a4c4d6 + 9ee6d6b commit 9e607ab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
29 changes: 27 additions & 2 deletions arcane/src/arcane/parallel/mpi/ArcaneMpi.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ArcaneMpi.cc (C) 2000-2023 */
/* ArcaneMpi.cc (C) 2000-2024 */
/* */
/* Déclarations globales pour la partie MPI de Arcane. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -48,6 +48,31 @@ arcaneIsCudaAwareMPI()
return is_aware;
}

extern "C++" ARCANE_MPI_EXPORT bool
arcaneIsHipAwareMPI()
{
bool is_aware = false;
// OpenMPI définit MPIX_HIP_AWARE_SUPPORT et mpich définit MPIX_GPU_SUPPORT_HIP
// pour indiquer que MPIX_Query_hip_support() est disponible.

// MPICH
#if defined(MPIX_GPU_SUPPORT_HIP)
is_aware = (MPIX_Query_hip_support()==1);
#endif

// OpenMPI:
#if defined(MPIX_ROCM_AWARE_SUPPORT)
is_aware = (MPIX_Query_rocm_support()==1);
#endif
return is_aware;
}

extern "C++" ARCANE_MPI_EXPORT bool
arcaneIsAcceleratorAwareMPI()
{
return arcaneIsCudaAwareMPI() || arcaneIsHipAwareMPI();
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
Expand Down
13 changes: 11 additions & 2 deletions arcane/src/arcane/parallel/mpi/ArcaneMpi.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ArcaneMpi.h (C) 2000-2019 */
/* ArcaneMpi.h (C) 2000-2024 */
/* */
/* Déclarations globales pour la partie MPI de Arcane. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -55,6 +55,15 @@ arcaneAutoDetectMessagePassingServiceMPI();
extern "C++" ARCANE_MPI_EXPORT bool
arcaneIsCudaAwareMPI();

/*!
* \brief Indique si le runtime actuel de MPI a le support des accélérateurs.
*
* Si l'implémentation MPI supporte CUDA ou HIP cela permet à MPI d'accéder
* directement à la mémoire du GPU.
*/
extern "C++" ARCANE_MPI_EXPORT bool
arcaneIsAcceleratorAwareMPI();

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/parallel/mpi/MpiParallelMng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ _internalUtilsFactory() const
bool MpiParallelMng::
_isAcceleratorAware() const
{
return arcaneIsCudaAwareMPI();
return arcaneIsAcceleratorAwareMPI();
}

/*---------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/parallel/mpi/MpiParallelSuperMng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ build()
if (rank==0){
tm->info() << "MPI has non blocking collective";
tm->info() << "MPI: sizeof(MPI_Count)=" << sizeof(MPI_Count);
tm->info() << "MPI: is Cuda Aware?=" << arcaneIsCudaAwareMPI();
tm->info() << "MPI: is GPU Aware?=" << arcaneIsAcceleratorAwareMPI();
tm->info() << "MPI: init_time (seconds)=" << (end_time-start_time);
}

Expand Down

0 comments on commit 9e607ab

Please sign in to comment.