11 #define BOOST_TEST_DYN_LINK
12 #define BOOST_TEST_MODULE "Test module for cf3::common 's parallel environment - part of testing collective communications."
19 #include <boost/test/unit_test.hpp>
20 #include <boost/lambda/lambda.hpp>
21 #include <boost/foreach.hpp>
22 #include <boost/thread/thread.hpp>
49 m_argc = boost::unit_test::framework::master_test_suite().argc;
50 m_argv = boost::unit_test::framework::master_test_suite().argv;
57 double dd (
int idx,
int rank,
int nproc ) {
return rank * 100 +
idx; }
75 CFinfo.setFilterRankZero(
false);
95 BOOST_CHECK_EQUAL( rk_result, sum );
99 std::vector<double>
v (2);
114 BOOST_CHECK_EQUAL( v[0], sum );
126 int rkright = (irank + 1) % nproc;
128 int rkleft = (nproc+irank-1) % nproc;
135 std::vector<double>
v (100);
136 for(
Uint i = 0; i < v.size(); ++i)
137 v[i] = dd(i,irank,nproc);
141 std::vector<int> send_map (10);
142 for(
Uint i = 0; i < send_map.size(); ++i)
143 send_map[i] = 90 + i;
145 std::vector<int> send_num (nproc, 0);
146 send_num[rkright] = 10;
148 BOOST_CHECK_EQUAL( std::accumulate( send_num.begin(), send_num.end(), 0), send_map.size() );
150 std::vector<int> recv_map (10);
151 for(
Uint i = 0; i < recv_map.size(); ++i)
154 std::vector<int> recv_num (nproc, 0);
155 recv_num[rkleft] = 10;
157 BOOST_CHECK_EQUAL( std::accumulate( recv_num.begin(), recv_num.end(), 0), recv_map.size() );
166 for(
Uint i = 0; i < 10; ++i)
167 BOOST_CHECK_EQUAL( v[i], dd(i+90,rkleft,nproc) );
170 for(
Uint i = 10; i < v.size(); ++i)
171 BOOST_CHECK_EQUAL( v[i], dd(i,irank,nproc) );
180 CFinfo.setFilterRankZero(
true);
187 BOOST_AUTO_TEST_SUITE_END()
T * all_reduce(const Op &op, const T *in_values, const int in_n, T *out_values, const int stride=1)
#define CFinfo
these are always defined
double dd(int idx, int rank, int nproc)
Uint rank() const
Return rank, additionally, if is_init==0.
Real max(const Real a, const Real b)
Maximum between two scalars.
BOOST_FIXTURE_TEST_CASE(init, PECollectiveFixture)
Uint size() const
Return the number of processes, or 1 if is_init==0.
void init(int argc=0, char **args=0)
Top-level namespace for coolfluid.
~PECollectiveFixture()
common tear-down for each test case
T * all_reduce(const Communicator &comm, const Op &op, const T *in_values, const int in_n, T *out_values, const int stride=1)
unsigned int Uint
typedef for unsigned int
T * all_to_all(const T *in_values, const int in_n, T *out_values, const int stride=1)
static Comm & instance()
Return a reference to the current PE.
PECollectiveFixture()
common setup for each test case
Most basic kernel library.
#define PEProcessSortedExecute(irank, expression)