diff --git a/BaseLib/MPI.h b/BaseLib/MPI.h index 3b37773e3e976ab5298ee9f83304dd86f1bfce68..9a3b8b48ce071650250580c76a42155f75858863 100644 --- a/BaseLib/MPI.h +++ b/BaseLib/MPI.h @@ -5,28 +5,28 @@ * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license - * */ #pragma once +#ifdef USE_PETSC +#include <mpi.h> +#endif + namespace BaseLib::MPI { -#ifdef USE_PETSC -// Reduce operations for interprocess communications while using Petsc -static inline int reduceMin(int val) +static inline int reduceMin(int const val) { +#ifdef USE_PETSC + // Reduce operations for interprocess communications while using Petsc int result; MPI_Allreduce(&val, &result, 1, MPI_INTEGER, MPI_MIN, PETSC_COMM_WORLD); return result; -} #else -// Reduce operations for interprocess communications without using Petsc -static inline int reduceMin(int val) -{ + // Reduce operations for interprocess communications without using Petsc return val; -} #endif +} } // namespace BaseLib::MPI