Squashed 'boost/' content from commit b4feb19f2

git-subtree-dir: boost
git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
Bill Somerville
2018-06-09 21:48:32 +01:00
commit 4ebe6417a5
12444 changed files with 2327021 additions and 0 deletions
@@ -0,0 +1,27 @@
# Copyright 2012 Karsten Ahnert
# Copyright 2012-2013 Mario Mulansky
# Copyright 2013 Pascal Germroth
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import testing ;
import mpi : mpi-test ;
use-project boost : $(BOOST_ROOT) ;
project
: requirements
<library>/boost/test//boost_unit_test_framework
<library>/boost//mpi
<link>static
<define>BOOST_ALL_NO_LIB=1
;
# mpi-test name : source : req : np=1 2 3 4 7 8 13 17
test-suite "odeint-mpi"
:
[ mpi-test split_test ]
[ mpi-test state_test ]
[ mpi-test norm_test ]
;
@@ -0,0 +1,62 @@
/*
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <sstream>
#include <cstdlib>
#define BOOST_TEST_MODULE odeint_mpi
#include <boost/test/unit_test.hpp>
#include <boost/numeric/odeint/external/mpi/mpi.hpp>
using namespace boost::numeric::odeint;
boost::mpi::environment env;
BOOST_AUTO_TEST_SUITE( norm_test_suite )
BOOST_AUTO_TEST_CASE( norm_test )
{
boost::mpi::communicator world;
int ref_value = 0;
std::vector<int> in_data;
mpi_state< std::vector<int> > state(world);
// generate data and reference value on master
if(world.rank() == 0) {
for(size_t i = 0 ; i < 400 ; i++)
in_data.push_back( rand() % 10000 );
ref_value = *std::max_element(in_data.begin(), in_data.end());
}
boost::mpi::broadcast(world, ref_value, 0);
// copy to nodes
split( in_data, state );
int value = mpi_nested_algebra< range_algebra >::norm_inf( state );
{
std::ostringstream ss;
ss << "state[" << world.rank() << "]"
<< " local:" << range_algebra::norm_inf( state() )
<< " global:" << value
<< " ref:" << ref_value << "\n";
std::clog << ss.str() << std::flush;
}
BOOST_REQUIRE_EQUAL( value, ref_value );
}
BOOST_AUTO_TEST_SUITE_END()
@@ -0,0 +1,61 @@
/*
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <sstream>
#define BOOST_TEST_MODULE odeint_mpi
#include <boost/test/unit_test.hpp>
#include <boost/numeric/odeint/external/mpi/mpi.hpp>
using namespace boost::numeric::odeint;
boost::mpi::environment env;
BOOST_AUTO_TEST_SUITE( split_test_suite )
BOOST_AUTO_TEST_CASE( split_test )
{
boost::mpi::communicator world;
const size_t total_size = 31;
std::vector<size_t> in_data, out_data;
mpi_state< std::vector<size_t> > state(world);
// generate data on master
if(world.rank() == 0)
for(size_t i = 0 ; i < total_size ; i++) in_data.push_back(i);
// copy to nodes
split( in_data, state );
BOOST_REQUIRE((state().size() == total_size / world.size())
|| (state().size() == total_size / world.size() + 1));
{
std::ostringstream ss;
ss << "state[" << world.rank() << "].data = {";
std::copy(state().begin(), state().end(), std::ostream_iterator<size_t>(ss, ", "));
ss << "}\n";
std::clog << ss.str() << std::flush;
}
// copy back to master
if(world.rank() == 0) out_data.resize(in_data.size());
unsplit( state, out_data );
if(world.rank() == 0)
BOOST_REQUIRE_EQUAL_COLLECTIONS(in_data.begin(), in_data.end(), out_data.begin(), out_data.end());
}
BOOST_AUTO_TEST_SUITE_END()
@@ -0,0 +1,78 @@
/*
Copyright 2013 Karsten Ahnert
Copyright 2013 Mario Mulansky
Copyright 2013 Pascal Germroth
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <sstream>
#define BOOST_TEST_MODULE odeint_mpi
#include <boost/test/unit_test.hpp>
#include <boost/numeric/odeint/external/mpi/mpi.hpp>
using namespace boost::numeric::odeint;
boost::mpi::environment env;
BOOST_AUTO_TEST_SUITE( state_test_suite )
BOOST_AUTO_TEST_CASE( state_test )
{
boost::mpi::communicator world;
std::vector<size_t> in_data1, in_data2;
mpi_state< std::vector<size_t> > state1(world), state2(world);
// generate data on master
if(world.rank() == 0) {
in_data1.resize(31);
in_data2.resize(33);
for(size_t i = 0 ; i < in_data2.size() ; i++)
in_data2[i] = i;
}
// copy to nodes
split( in_data1, state1 );
split( in_data2, state2 );
{
std::ostringstream ss;
ss << "state[" << world.rank() << "] {"
<< state1().size() << ", "
<< state2().size() << "}\n";
std::clog << ss.str() << std::flush;
}
// compare size
BOOST_REQUIRE( !same_size( state1, state2 ) );
// resize state1 to match state2.
resize( state1, state2 );
{
std::ostringstream ss;
ss << "state[" << world.rank() << "] 1:"
<< state1().size() << " 2:"
<< state2().size() << "\n";
std::clog << ss.str() << std::flush;
}
// compare size
BOOST_REQUIRE( same_size( state1, state2 ) );
// copy state2 to state1
copy( state2, state1 );
BOOST_REQUIRE_EQUAL_COLLECTIONS(state1().begin(), state1().end(),
state2().begin(), state2().end());
}
BOOST_AUTO_TEST_SUITE_END()