Adds the possibility to compute a parallel inner product.

This commit is contained in:
Markus Blatt
2015-05-22 20:47:02 +02:00
parent 3fb7af1719
commit a4e28119a3
2 changed files with 44 additions and 3 deletions

View File

@@ -48,16 +48,20 @@ void runSumMaxMinTest(const int offset)
assert(comm.indexSet()->size()==x.size());
for(auto i=comm.indexSet()->begin(), iend=comm.indexSet()->end(); i!=iend; ++i)
x[i->local()]=i->global()+offset;
auto containers = std::make_tuple(x, x, x);
auto containers = std::make_tuple(x, x, x, x);
auto operators = std::make_tuple(Opm::Reduction::makeGlobalSumFunctor<int>(),
Opm::Reduction::makeGlobalMaxFunctor<int>(),
Opm::Reduction::makeGlobalMinFunctor<int>());
auto values = std::make_tuple(0,0,100000);
Opm::Reduction::makeGlobalMinFunctor<int>(),
Opm::Reduction::makeInnerProductFunctor<int>());
auto values = std::make_tuple(0,0,100000, 0);
auto oldvalues = values;
start = offset;
end = start+N;
comm.computeReduction(containers,operators,values);
BOOST_CHECK(std::get<0>(values)==std::get<0>(oldvalues)+((N-1+2*offset)*N)/2);
BOOST_CHECK(std::get<1>(values)==std::max(N+offset-1, std::get<1>(oldvalues)));
BOOST_CHECK(std::get<2>(values)==std::min(offset, std::get<2>(oldvalues)));
BOOST_CHECK(std::get<3>(values)==((end-1)*end*(2*end-1)-(start-1)*start*(2*start-1))/6+std::get<3>(oldvalues));
}
BOOST_AUTO_TEST_CASE(tupleReductionTest)