Skip to content
Snippets Groups Projects
Commit 088af030 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Define PASTIS_HAS_MPI when MPI is found and used

Use the macro in a crappy way to allow non MPI builds to compile
parent 2c903e7f
No related branches found
No related tags found
1 merge request!11Feature/mpi
......@@ -94,6 +94,8 @@ elseif(PASTIS_ENABLE_MPI STREQUAL "ON")
message(FATAL_ERROR "Could not find MPI library while requested")
endif()
set(PASTIS_HAS_MPI ${MPI_FOUND})
#------------------------------------------------------
# setting Kokkos defaults to OpenMP when available
......
......@@ -13,10 +13,14 @@
#include <ConsoleManager.hpp>
#include <CLI/CLI.hpp>
#ifdef PASTIS_HAS_MPI
#include <mpi.h>
#endif // PASTIS_HAS_MPI
std::string initialize(int& argc, char* argv[])
{
#ifdef PASTIS_HAS_MPI
MPI_Init(&argc, &argv);
{
......@@ -30,6 +34,7 @@ std::string initialize(int& argc, char* argv[])
pout.setOutput(null_stream);
}
}
#endif // PASTIS_HAS_MPI
long unsigned number = 10;
std::string filename;
......@@ -115,6 +120,7 @@ std::string initialize(int& argc, char* argv[])
void finalize()
{
#ifdef PASTIS_HAS_MPI
MPI_Barrier(MPI_COMM_WORLD);
const int mpi_rank
=[](){
......@@ -133,7 +139,11 @@ void finalize()
pout() << rang::fgB::green << "Terminating process " << rang::fg::reset
<< rang::fgB::yellow << mpi_rank << rang::fg::reset << " of "
<< rang::style::bold << mpi_size << rang::style::reset << '\n';;
#endif // PASTIS_HAS_MPI
Kokkos::finalize();
#ifdef PASTIS_HAS_MPI
MPI_Finalize();
#endif // PASTIS_HAS_MPI
}
......@@ -2,6 +2,8 @@
#define PASTIS_CONFIG_HPP
#cmakedefine PASTIS_HAS_FENV_H
#cmakedefine PASTIS_HAS_MPI
#cmakedefine SYSTEM_IS_LINUX
#cmakedefine SYSTEM_IS_DARWIN
#cmakedefine SYSTEM_IS_WINDOWS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment