30#ifdef ESPRESSO_WALBERLA
34#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
35#include <Cabana_Core.hpp>
36#include <Kokkos_Core.hpp>
43#include <boost/mpi.hpp>
44#include <boost/mpi/communicator.hpp>
45#include <boost/mpi/environment.hpp>
61#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
71#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
77 char const *
const value = std::getenv(name);
78 std::optional<std::string> result{std::nullopt};
80 result = std::string(value);
87 char **argv =
nullptr;
88 return std::make_shared<boost::mpi::environment>(argc, argv);
95 std::shared_ptr<boost::mpi::environment> mpi_env)
96 : m_mpi_env{
std::move(mpi_env)} {
97#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
99 if (not num_threads_env or num_threads_env->empty()) {
100 omp_set_num_threads(1);
104 m_is_mpi_gpu_aware =
false;
107#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
108 m_is_mpi_gpu_aware |=
static_cast<bool>(MPIX_Query_rocm_support());
110#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
111 m_is_mpi_gpu_aware |=
static_cast<bool>(MPIX_Query_cuda_support());
117 m_is_mpi_gpu_aware |= (mpich_gpu_env and *mpich_gpu_env ==
"1");
120#if defined(_CRAYC) or defined(__cray__)
121 auto const cray_mpich_gpu_env =
get_env_variable(
"MPICH_GPU_SUPPORT_ENABLED");
122 m_is_mpi_gpu_aware |= (cray_mpich_gpu_env and *cray_mpich_gpu_env ==
"1");
128 std::make_shared<Communication::MpiCallbacks>(
comm_cart, m_mpi_env);
132#ifdef ESPRESSO_WALBERLA
144#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
150#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
155#ifdef ESPRESSO_WALBERLA
167 auto constexpr reorder =
false;
171 std::ignore = Utils::Mpi::cart_neighbors<3>(
comm);
177 MPI_Comm_size(MPI_COMM_WORLD, &
size);
Vector implementation and trait types for boost qvm interoperability.
~CommunicationEnvironment()
CommunicationEnvironment()
void loop() const
Start the MPI loop.
void mpi_loop()
Process requests from head node.
std::shared_ptr< KokkosHandle > kokkos_handle
Communicator communicator
static auto get_env_variable(char const *const name)
boost::mpi::communicator comm_cart
The communicator.
static auto make_default_mpi_env()
int this_node
The number of this node.
std::unique_ptr< CommunicationEnvironment > communication_environment
std::shared_ptr< KokkosHandle > kokkos_handle
Communicator communicator
boost::mpi::communicator comm_cart
The communicator.
void cuda_on_program_start()
Called on program start.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
void fft_on_program_start()
MpiCallbacks & mpiCallbacks()
Returns a reference to the global callback class instance.
void init_error_handling(boost::mpi::communicator const &comm)
Initialize the error collection system.
void deinit_error_handling()
boost::mpi::communicator cart_create(boost::mpi::communicator const &comm, Vector< int, dim > const &dims, bool reorder=true, Vector< int, dim > const &periodicity=Vector< int, dim >::broadcast(1))
Wrapper around MPI_Cart_create.
void mpi_deinit()
Release waLBerla's MPI manager and environment.
void mpi_init()
Initialize waLBerla's MPI manager and environment.
boost::mpi::communicator & comm
void full_initialization()
int size
The MPI world size.
int & this_node
The MPI rank.
Utils::Vector3i calc_node_index() const
Calculate the node index in the Cartesian topology.
Utils::Vector3i node_grid
void set_node_grid(Utils::Vector3i const &value)
Set new Cartesian topology.