2 Copyright 2013 Karsten Ahnert
3 Copyright 2013 Mario Mulansky
4 Copyright 2013 Pascal Germroth
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE_1_0.txt or
8 copy at http://www.boost.org/LICENSE_1_0.txt)
15 #define BOOST_TEST_MODULE odeint_mpi
16 #include <boost/test/unit_test.hpp>
18 #include <boost/numeric/odeint/external/mpi/mpi.hpp>
20 using namespace boost::numeric::odeint;
22 boost::mpi::environment env;
24 BOOST_AUTO_TEST_SUITE( norm_test_suite )
26 BOOST_AUTO_TEST_CASE( norm_test )
28 boost::mpi::communicator world;
31 std::vector<int> in_data;
32 mpi_state< std::vector<int> > state(world);
34 // generate data and reference value on master
35 if(world.rank() == 0) {
36 for(size_t i = 0 ; i < 400 ; i++)
37 in_data.push_back( rand() % 10000 );
38 ref_value = *std::max_element(in_data.begin(), in_data.end());
40 boost::mpi::broadcast(world, ref_value, 0);
43 split( in_data, state );
45 int value = mpi_nested_algebra< range_algebra >::norm_inf( state );
48 std::ostringstream ss;
49 ss << "state[" << world.rank() << "]"
50 << " local:" << range_algebra::norm_inf( state() )
51 << " global:" << value
52 << " ref:" << ref_value << "\n";
53 std::clog << ss.str() << std::flush;
56 BOOST_REQUIRE_EQUAL( value, ref_value );
60 BOOST_AUTO_TEST_SUITE_END()