30#ifdef ESPRESSO_WALBERLA
34#include <Cabana_Core.hpp>
35#include <Kokkos_Core.hpp>
41#include <boost/mpi.hpp>
42#include <boost/mpi/communicator.hpp>
43#include <boost/mpi/environment.hpp>
70 char const *
const value = std::getenv(name);
71 std::optional<std::string> result{std::nullopt};
73 result = std::string(value);
80 char **argv =
nullptr;
81 return std::make_shared<boost::mpi::environment>(argc, argv);
88 std::shared_ptr<boost::mpi::environment> mpi_env)
89 : m_mpi_env{
std::move(mpi_env)} {
91 if (not num_threads_env or num_threads_env->empty()) {
92 omp_set_num_threads(1);
95 m_is_mpi_gpu_aware =
false;
98#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
99 m_is_mpi_gpu_aware |=
static_cast<bool>(MPIX_Query_rocm_support());
101#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
102 m_is_mpi_gpu_aware |=
static_cast<bool>(MPIX_Query_cuda_support());
108 m_is_mpi_gpu_aware |= (mpich_gpu_env and *mpich_gpu_env ==
"1");
111#if defined(_CRAYC) or defined(__cray__)
112 auto const cray_mpich_gpu_env =
get_env_variable(
"MPICH_GPU_SUPPORT_ENABLED");
113 m_is_mpi_gpu_aware |= (cray_mpich_gpu_env and *cray_mpich_gpu_env ==
"1");
116#ifdef ESPRESSO_WALBERLA
123 std::make_shared<Communication::MpiCallbacks>(
comm_cart, m_mpi_env);
142#ifdef ESPRESSO_WALBERLA
152 locked_for_checkpointing{false} {}
155 auto constexpr reorder =
false;
159 std::ignore = Utils::Mpi::cart_neighbors<3>(
comm);
160#ifdef ESPRESSO_WALBERLA
168 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.
DEVICE_QUALIFIER constexpr pointer data() noexcept
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_reinit(int const *cart_topol)
Re-initialize waLBerla's MPI Cartesian communicator.
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.
bool locked_for_checkpointing
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.