• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2013 Alain Miniussi <alain.miniussi@oca.eu>
2 
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 // test mpi version
8 
9 #include <boost/mpi/environment.hpp>
10 #include <boost/mpi/communicator.hpp>
11 #include <iostream>
12 
13 #define BOOST_TEST_MODULE mpi_version
14 #include <boost/test/included/unit_test.hpp>
15 
16 namespace mpi = boost::mpi;
17 
18 void
test_version(mpi::communicator const & comm)19 test_version(mpi::communicator const& comm) {
20 #if defined(MPI_VERSION)
21   int mpi_version    = MPI_VERSION;
22   int mpi_subversion = MPI_SUBVERSION;
23 #else
24   int mpi_version = 0;
25   int mpi_subversion = 0;
26 #endif
27 
28   std::pair<int,int> version = mpi::environment::version();
29   if (comm.rank() == 0) {
30     std::cout << "MPI Version: " << version.first << ',' << version.second << '\n';
31   }
32   BOOST_CHECK(version.first == mpi_version);
33   BOOST_CHECK(version.second == mpi_subversion);
34 }
35 
36 std::string
yesno(bool b)37 yesno(bool b) {
38   return b ? std::string("yes") : std::string("no");
39 }
40 
41 void
report_features(mpi::communicator const & comm)42 report_features(mpi::communicator const& comm) {
43   if (comm.rank() == 0) {
44     std::cout << "Assuming working MPI_Improbe:" <<
45 #if defined(BOOST_MPI_USE_IMPROBE)
46       "yes" << '\n';
47 #else
48       "no"  << '\n';
49 #endif
50   }
51 }
52 
BOOST_AUTO_TEST_CASE(version)53 BOOST_AUTO_TEST_CASE(version)
54 {
55   mpi::environment env;
56   mpi::communicator world;
57 
58   test_version(world);
59   report_features(world);
60 }
61