]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpi/test/block_nonblock_test.cpp
2ec0225603261b88de6bfb0038bd048491abde1c
6 #include <boost/mpi.hpp>
7 #include <boost/serialization/vector.hpp>
8 #include <boost/core/demangle.hpp>
10 //#include "debugger.cpp"
12 #define BOOST_TEST_MODULE mpi_nonblocking
13 #include <boost/test/included/unit_test.hpp>
15 namespace mpi
= boost::mpi
;
18 bool test(mpi::communicator
const& comm
, std::vector
<T
> const& ref
, bool iswap
, bool alloc
)
21 int rank
= comm
.rank();
23 std::cout
<< "Testing with type " << boost::core::demangle(typeid(T
).name()) << '\n';
25 std::cout
<< "Blockin send, non blocking receive.\n";
27 std::cout
<< "Non blockin send, blocking receive.\n";
30 std::cout
<< "Explicitly allocate space for the receiver.\n";
32 std::cout
<< "Do not explicitly allocate space for the receiver.\n";
38 data
.resize(ref
.size());
41 mpi::request req
= comm
.irecv(1, 0, data
);
44 comm
.recv(1, 0, data
);
46 std::cout
<< "Process 0 received " << data
.size() << " elements :" << std::endl
;
47 std::copy(data
.begin(), data
.end(), std::ostream_iterator
<T
>(std::cout
, " "));
48 std::cout
<< std::endl
;
49 std::cout
<< "While expecting " << ref
.size() << " elements :" << std::endl
;
50 std::copy(ref
.begin(), ref
.end(), std::ostream_iterator
<T
>(std::cout
, " "));
51 std::cout
<< std::endl
;
55 std::vector
<T
> vec
= ref
;
59 mpi::request req
= comm
.isend(0, 0, vec
);
67 BOOST_AUTO_TEST_CASE(non_blocking
)
70 mpi::communicator world
;
72 BOOST_TEST_REQUIRE(world
.size() > 1);
74 std::vector
<int> integers(13); // don't assume we're lucky
75 for(int i
= 0; i
< int(integers
.size()); ++i
) {
79 std::vector
<std::string
> strings(13); // don't assume we're lucky
80 for(int i
= 0; i
< int(strings
.size()); ++i
) {
81 std::ostringstream fmt
;
83 strings
[i
] = fmt
.str();
86 std::vector
<int> empty
;
88 BOOST_CHECK(test(world
, empty
, false, true));
89 BOOST_CHECK(test(world
, empty
, false, false));
91 BOOST_CHECK(test(world
, integers
, true, true));
92 BOOST_CHECK(test(world
, integers
, true, false));
93 BOOST_CHECK(test(world
, strings
, true, true));
94 BOOST_CHECK(test(world
, strings
, true, false));
96 BOOST_CHECK(test(world
, integers
, false, true));
97 BOOST_CHECK(test(world
, integers
, false, false));
98 BOOST_CHECK(test(world
, strings
, false, true));
99 BOOST_CHECK(test(world
, strings
, false, false));