Skip to content
Snippets Groups Projects
Commit dd1e8595 authored by Markus Blatt's avatar Markus Blatt
Browse files

[parallel,release] Adds a new buffered communicator that does not need to know...

[parallel,release] Adds a new buffered communicator that does not need to know the data amount per index when receiving.

During communication of data with a parallel DUNE grid the amount of data items
received at an index is not known at the receiving side. With this communicator
it is possible to build such a communication based on index lists at the sending
and receiving side. With this patch only fixed size of data items per index is
supported.
parent 6c77b159
No related branches found
No related tags found
No related merge requests found
......@@ -15,5 +15,6 @@ install(FILES
plocalindex.hh
remoteindices.hh
selection.hh
variablesizecommunicator.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/common/parallel)
......@@ -16,7 +16,8 @@ parallelinclude_HEADERS = \
mpitraits.hh \
plocalindex.hh \
remoteindices.hh \
selection.hh
selection.hh \
variablesizecommunicator.hh
include $(top_srcdir)/am/global-rules
......
set(MPITESTPROGS indicestest indexsettest syncertest selectiontest)
set(MPITESTPROGS indicestest indexsettest syncertest selectiontest variablesizecommunicatortest)
add_directory_test_target(_test_target)
# We do not want want to build the tests during make all,
......@@ -21,7 +21,12 @@ add_executable("syncertest" syncertest.cc)
target_link_libraries("syncertest" "dunecommon")
add_dune_mpi_flags(syncertest)
add_executable("variablesizecommunicatortest" variablesizecommunicatortest.cc)
target_link_libraries("variablesizecommunicatortest" "dunecommon")
add_dune_mpi_flags(variablesizecommunicatortest)
add_test(indexsettest indexsettest)
add_test(selectiontest selectiontest)
add_test(indicestest indicestest)
add_test(syncertest syncertest)
add_test(variablesizecommunicatortest variablesizecommunicatortest)
# $Id$
MPITESTS = indicestest indexsettest syncertest selectiontest
MPITESTS = indicestest \
indexsettest \
syncertest \
selectiontest \
variablesizecommunicatortest
# which tests where program to build and run are equal
NORMALTESTS =
......@@ -44,6 +48,19 @@ syncertest_LDADD = \
$(DUNEMPILIBS) \
$(LDADD)
variablesizecommunicatortest_SOURCES = variablesizecommunicatortest.cc
variablesizecommunicatortest_CPPFLAGS = $(AM_CPPFLAGS) \
$(DUNEMPICPPFLAGS) \
$(DUNE_COMMON_CPPFLAGS)
variablesizecommunicatortest_LDFLAGS = $(AM_LDFLAGS) \
$(DUNEMPILDFLAGS) \
$(DUNE_COMMON_LDFLAGS)
variablesizecommunicatortest_LDADD = \
$(DUNE_COMMON_LDFLAGS) $(DUNE_COMMON_LIBS) \
$(DUNEMPILIBS) \
$(LDADD)
include $(top_srcdir)/am/global-rules
EXTRA_DIST = CMakeLists.txt
#include"config.h"
#include<iostream>
#include<mpi.h>
struct MyDataHandle
{
typedef std::size_t DataType;
bool fixedsize()
{
return true;
}
template<class B>
void gather(B& buffer, int i)
{
std::cout<<"Gathering "<<i<<std::endl;
buffer.write(i);
buffer.write(i);
buffer.write(i);
}
template<class B>
void scatter(B& buffer, int i, int size)
{
std::cout<<"Scattering "<<size<<" entries for "<<i<<": ";
for(;size>0;--size)
{
std::size_t index;
buffer.read(index);
std::cout<<index<<" ";
}
std::cout<<std::endl;
}
std::size_t size(int i)
{
return 3;
}
};
#include<dune/common/parallel/variablesizecommunicator.hh>
int main(int argc, char** argv)
{
MPI_Init(&argc, &argv);
{
typedef Dune::VariableSizeCommunicator<>::InterfaceMap Interface;
Dune::InterfaceInformation send, recv;
send.reserve(6);
for(std::size_t i=0; i<=10; i+=2)
send.add(i);
recv.reserve(6);
for(std::size_t i=10; i<=10; i-=2)
recv.add(i);
Interface inf;
inf[0]=std::make_pair(send, recv);
Dune::VariableSizeCommunicator<> comm(MPI_COMM_SELF, inf, 6);
MyDataHandle handle;
comm.forward(handle);
std::cout<<"===================== backward ========================="<<std::endl;
comm.backward(handle);
}
MPI_Finalize();
}
This diff is collapsed.
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