From 2c3d08ec2a5d50ddd18743c8c5035bbcb9bbbb13 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 16 Jun 2012 12:03:36 +0000 Subject: [PATCH] mpi - table exchange --- libsrc/general/mpi_interface.hpp | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/libsrc/general/mpi_interface.hpp b/libsrc/general/mpi_interface.hpp index 53f22579..bb414131 100644 --- a/libsrc/general/mpi_interface.hpp +++ b/libsrc/general/mpi_interface.hpp @@ -178,6 +178,42 @@ namespace netgen } */ + + + /* + send a table entry to each of the prcesses in the group ... + receive-table entries will be set + */ + template + inline void MyMPI_ExchangeTable (TABLE & send_verts, + TABLE & recv_verts, int tag, + MPI_Comm comm = MPI_COMM_WORLD) + { + int ntasks, rank; + MPI_Comm_size(comm, &ntasks); + MPI_Comm_rank(comm, &rank); + + Array requests; + for (int dest = 0; dest < ntasks; dest++) + if (dest != rank) + requests.Append (MyMPI_ISend (send_verts[dest], dest, tag, comm)); + + for (int i = 0; i < ntasks-1; i++) + { + MPI_Status status; + MPI_Probe (MPI_ANY_SOURCE, tag, comm, &status); + int size, src = status.MPI_SOURCE; + MPI_Get_count (&status, MPI_INT, &size); + recv_verts.SetEntrySize (src, size, sizeof(int)); + requests.Append (MyMPI_IRecv (recv_verts[src], src, tag, comm)); + } + MPI_Waitall (requests.Size(), &requests[0], MPI_STATUS_IGNORE); + } + + + + + inline void MyMPI_SendCmd (const char * cmd) { char buf[100];