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") ...@@ -94,6 +94,8 @@ elseif(PASTIS_ENABLE_MPI STREQUAL "ON")
message(FATAL_ERROR "Could not find MPI library while requested") message(FATAL_ERROR "Could not find MPI library while requested")
endif() endif()
set(PASTIS_HAS_MPI ${MPI_FOUND})
#------------------------------------------------------ #------------------------------------------------------
# setting Kokkos defaults to OpenMP when available # setting Kokkos defaults to OpenMP when available
......
...@@ -13,10 +13,14 @@ ...@@ -13,10 +13,14 @@
#include <ConsoleManager.hpp> #include <ConsoleManager.hpp>
#include <CLI/CLI.hpp> #include <CLI/CLI.hpp>
#ifdef PASTIS_HAS_MPI
#include <mpi.h> #include <mpi.h>
#endif // PASTIS_HAS_MPI
std::string initialize(int& argc, char* argv[]) std::string initialize(int& argc, char* argv[])
{ {
#ifdef PASTIS_HAS_MPI
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
{ {
...@@ -30,6 +34,7 @@ std::string initialize(int& argc, char* argv[]) ...@@ -30,6 +34,7 @@ std::string initialize(int& argc, char* argv[])
pout.setOutput(null_stream); pout.setOutput(null_stream);
} }
} }
#endif // PASTIS_HAS_MPI
long unsigned number = 10; long unsigned number = 10;
std::string filename; std::string filename;
...@@ -115,6 +120,7 @@ std::string initialize(int& argc, char* argv[]) ...@@ -115,6 +120,7 @@ std::string initialize(int& argc, char* argv[])
void finalize() void finalize()
{ {
#ifdef PASTIS_HAS_MPI
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
const int mpi_rank const int mpi_rank
=[](){ =[](){
...@@ -133,7 +139,11 @@ void finalize() ...@@ -133,7 +139,11 @@ void finalize()
pout() << rang::fgB::green << "Terminating process " << rang::fg::reset pout() << rang::fgB::green << "Terminating process " << rang::fg::reset
<< rang::fgB::yellow << mpi_rank << rang::fg::reset << " of " << rang::fgB::yellow << mpi_rank << rang::fg::reset << " of "
<< rang::style::bold << mpi_size << rang::style::reset << '\n';; << rang::style::bold << mpi_size << rang::style::reset << '\n';;
#endif // PASTIS_HAS_MPI
Kokkos::finalize(); Kokkos::finalize();
#ifdef PASTIS_HAS_MPI
MPI_Finalize(); MPI_Finalize();
#endif // PASTIS_HAS_MPI
} }
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#define PASTIS_CONFIG_HPP #define PASTIS_CONFIG_HPP
#cmakedefine PASTIS_HAS_FENV_H #cmakedefine PASTIS_HAS_FENV_H
#cmakedefine PASTIS_HAS_MPI
#cmakedefine SYSTEM_IS_LINUX #cmakedefine SYSTEM_IS_LINUX
#cmakedefine SYSTEM_IS_DARWIN #cmakedefine SYSTEM_IS_DARWIN
#cmakedefine SYSTEM_IS_WINDOWS #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