1 #if COMPILATION// -*- indent-tabs-mode:t;c-basic-offset:4;tab-width:4; -*- 2 $CXXX `mpicxx -showme:compile|sed 's/-pthread/ /g'` -std=c++14 $0 -o $0x `mpicxx -showme:link|sed 's/-pthread/ /g'`&&mpirun -n 4 $0x&&rm $0x;exit 3 #endif 4 // © Alfredo A. Correa 2018-2020 5 6 #ifndef BOOST_MPI3_CORE_HPP 7 #define BOOST_MPI3_CORE_HPP 8 9 #define OMPI_SKIP_MPICXX 1 // https://github.com/open-mpi/ompi/issues/5157 10 #include<mpi.h> 11 12 #include<stdexcept> 13 14 namespace boost{ 15 namespace mpi3{ 16 initialized()17inline bool initialized(){ 18 int flag = -1; 19 int s = MPI_Initialized(&flag); 20 if(s != MPI_SUCCESS) throw std::runtime_error{"cannot probe initialization"}; 21 return flag; 22 } 23 finalized()24inline bool finalized(){ 25 int flag = -1; 26 int s = MPI_Finalized(&flag); 27 if(s != MPI_SUCCESS) throw std::runtime_error{"cannot probe finalization"}; 28 return flag; 29 } 30 31 }} 32 33 #if not __INCLUDE_LEVEL__ // _TEST_BOOST_MPI3_ENVIRONMENT 34 35 #include<cassert> 36 37 namespace mpi3 = boost::mpi3; 38 main()39int main(){ 40 assert(not mpi3::initialized() ); 41 } 42 43 #endif 44 #endif 45 46