Skip to content
Snippets Groups Projects
Commit 6b042b7d authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

check program for mpicollectivecommunication.

[[Imported from SVN: r4775]]
parent e551716a
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
TESTPROGS = parsetest test-stack arraylisttest smartpointertest \
sllisttest iteratorfacadetest tuplestest fmatrixtest \
poolallocatortest settest gcdlcdtest streamtest \
bigunsignedinttest mpihelpertest singletontest
bigunsignedinttest mpihelpertest singletontest mpicollcomm
# which tests to run
TESTS = $(TESTPROGS)
......@@ -59,6 +59,10 @@ mpihelpertest_SOURCES = mpihelpertest.cc
mpihelpertest_CXXFLAGS = $(MPI_CPPFLAGS)
mpihelpertest_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
mpicollcomm_SOURCES = mpicollectivecommunication.cc
mpicollcomm_CXXFLAGS = $(MPI_CPPFLAGS)
mpicollcomm_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
singletontest_SOURCES = singletontest.cc
singletontest_LDFLAGS = $(LOCAL_LIBS)
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include "config.h"
#include <dune/common/mpihelper.hh>
#include <dune/common/mpicollectivecommunication.hh>
#include <iostream>
int main(int argc, char** argv)
{
typedef Dune::MPIHelper Helper;
{
Helper& mpi = Helper::instance(argc, argv);
Dune::CollectiveCommunication<MPI_Comm> comm(mpi.getCommunicator());
enum { length = 5 };
double values[5];
for(int i=0; i<length; ++i) values[i] = 1.0;
double * commBuff = ((double *) &values[0]);
// calculate global sum
comm.sum( commBuff , length );
double val[length];
for(int i=0; i<length; ++i) val[i] = 1.0;
// calculate global sum by calling sum for each component
for(int i=0; i<length; ++i)
{
// this method works
val[i] = comm.sum( val[i] );
}
// result from above should be size of job
double sum = mpi.size();
for(int i=0; i<length; ++i)
{
assert( std::abs( values[i] - sum ) < 1e-8 );
assert( std::abs( val[i] - sum ) < 1e-8 );
}
}
std::cout << "We are at the end!"<<std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment