version_test.cpp 1.4 KB

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