7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for parallel fields"
11 #include <boost/test/unit_test.hpp>
25 using namespace boost;
38 m_argc = boost::unit_test::framework::master_test_suite().argc;
39 m_argv = boost::unit_test::framework::master_test_suite().argv;
61 Core::instance().initiate(m_argc,m_argv);
62 PE::Comm::instance().init(m_argc,m_argv);
70 buf << 1u << 2u << 3.0 << 4 <<
true;
76 std::vector<Real> data_array_real;
77 std::string data_string;
78 std::vector<std::string> data_array_string;
81 buf >> data_unsigned; BOOST_CHECK_EQUAL(data_unsigned, 1u );
82 buf >> data_unsigned; BOOST_CHECK_EQUAL(data_unsigned, 2u );
83 buf >> data_real; BOOST_CHECK_EQUAL(data_real, 3.0 );
84 buf >> data_integer; BOOST_CHECK_EQUAL(data_integer, 4 );
85 buf >> data_bool; BOOST_CHECK_EQUAL(data_bool,
true);
89 buf << 5; buf >> data_integer; BOOST_CHECK_EQUAL (data_integer , 5);
92 buf << std::vector<Real>(4,6.);
93 buf >> data_array_real;
95 BOOST_CHECK_EQUAL(data_array_real.size(), 4u);
96 BOOST_CHECK_EQUAL(data_array_real[0], 6.);
97 BOOST_CHECK_EQUAL(data_array_real[1], 6.);
98 BOOST_CHECK_EQUAL(data_array_real[2], 6.);
99 BOOST_CHECK_EQUAL(data_array_real[3], 6.);
102 boost::multi_array<Real,2>
table;
103 table.resize(boost::extents[4][3]);
109 buf >> data_array_real;
110 BOOST_CHECK_EQUAL(data_array_real[0], 1.);
111 BOOST_CHECK_EQUAL(data_array_real[1], 2.);
112 BOOST_CHECK_EQUAL(data_array_real[2], 3.);
115 buf << std::string(
"a nice string");
117 BOOST_CHECK_EQUAL(data_string, std::string(
"a nice string"));
120 buf << std::vector<std::string>(3,
"another nice string");
121 buf >> data_array_string;
122 BOOST_CHECK_EQUAL(data_array_string[0], std::string(
"another nice string"));
123 BOOST_CHECK_EQUAL(data_array_string[1], std::string(
"another nice string"));
124 BOOST_CHECK_EQUAL(data_array_string[2], std::string(
"another nice string"));
136 int first = Comm::instance().rank();
137 Real second = (1+
static_cast<Real
>(Comm::instance().rank()))*1
e-6;
138 bool third = (first == 0);
139 std::string fourth =
"from_proc_" +
to_str(first);
140 std::vector<int> fifth(3,first);
147 +
sizeof(
Uint)+
sizeof(char)*fourth.size()
148 +
sizeof(size_t)+
sizeof(
int)*fifth.size();
150 std::cout <<
"expected size is " << expected_size << std::endl;
160 if (Comm::instance().rank() == root)
161 buffer << first << second << third << fourth << fifth;
167 if (Comm::instance().rank() != root)
168 buffer >> first >> second >> third >> fourth >> fifth;
172 BOOST_CHECK_EQUAL(buffer.
size(), expected_size);
174 if (Comm::instance().rank() !=
root)
180 BOOST_CHECK_EQUAL(first, 0);
181 BOOST_CHECK_EQUAL(second, 1
e-6);
182 BOOST_CHECK_EQUAL(third,
true);
183 BOOST_CHECK_EQUAL(fourth,
"from_proc_0");
184 BOOST_CHECK_EQUAL(fifth[2], 0);
194 std::string str =
"from_proc_" +
to_str(Comm::instance().rank());
216 Comm::instance().finalize();
217 Core::instance().terminate();
222 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
~MPIBufferTests_Fixture()
common tear-down for each test case
external boost library namespace
Real e()
Definition of the Unit charge [C].
void broadcast(const Uint root)
Broadcast the buffer from the root process.
Common_API std::string to_str(const T &v)
Converts to std::string.
BOOST_AUTO_TEST_CASE(init_mpi)
Buffer that can hold multiple data types, useful for MPI communication.
Top-level namespace for coolfluid.
int m_argc
possibly common functions used on the tests below
bool more_to_unpack() const
Tell if everything is unpacked.
MPIBufferTests_Fixture()
common setup for each test case
unsigned int Uint
typedef for unsigned int
Classes offering a MPI interface for COOLFluiD.
void all_gather(Buffer &recv)
All Gather collective operation for buffers.
int size() const
Size of valid parts of buffer.
MPI communication buffer for mixed data types.
Most basic kernel library.