• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2017 Alain Miniussi & Vincent Chabannes
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 #include <string>
8 #include <iostream>
9 #include <sstream>
10 #include <vector>
11 
12 #include <boost/mpi.hpp>
13 #include <boost/mpi/nonblocking.hpp>
14 #include <boost/serialization/string.hpp>
15 
16 #define BOOST_TEST_MODULE mpi_wait_any
17 #include <boost/test/included/unit_test.hpp>
18 
19 namespace mpi = boost::mpi;
20 
BOOST_AUTO_TEST_CASE(wait_any)21 BOOST_AUTO_TEST_CASE(wait_any)
22 {
23   mpi::environment  env;
24   mpi::communicator comm;
25 
26   int rank = comm.rank();
27   int const sz = 10;
28   std::vector<int> data;
29   std::vector< mpi::request> reqs;
30   if ( rank == 0 ) {
31     for ( int i=0; i<sz; ++i ) {
32       data.push_back( i );
33     }
34     reqs.push_back( comm.isend(1, 0, data) );
35   } else if ( rank == 1 ) {
36     reqs.push_back( comm.irecv(0, 0, data) );
37   }
38   mpi::wait_all( reqs.begin(), reqs.end() );
39 
40   if ( rank == 1 ) {
41     BOOST_CHECK(data.size() == sz);
42     for ( int i=0; i<sz; ++i ) {
43       BOOST_CHECK(data[i] == i);
44     }
45   }
46 }
47