From ce71ffca4e154d8ac87b4d9bd6d3e96f03952ed7 Mon Sep 17 00:00:00 2001 From: David Wells Date: Mon, 17 Jul 2023 15:35:28 -0400 Subject: [PATCH] Remove local copies from Schedule. --- source/toolbox/parallel/Schedule.C | 61 +++++++++--------------------- source/toolbox/parallel/Schedule.h | 17 ++------- 2 files changed, 22 insertions(+), 56 deletions(-) diff --git a/source/toolbox/parallel/Schedule.C b/source/toolbox/parallel/Schedule.C index f68d970..043e680 100644 --- a/source/toolbox/parallel/Schedule.C +++ b/source/toolbox/parallel/Schedule.C @@ -77,14 +77,14 @@ void Schedule::addTransaction( const int src_id = transaction->getSourceProcessor(); const int dst_id = transaction->getDestinationProcessor(); - if ((my_id == src_id) && (my_id == dst_id)) { - d_local_set.addItem(transaction); - } else { - if (my_id == dst_id) { - d_recv_set[src_id].addItem(transaction); - } else if (my_id == src_id) { - d_send_set[dst_id].addItem(transaction); - } + TBOX_ASSERT(my_id == src_id || my_id == dst_id); + + // A local transaction is added twice + if (my_id == dst_id) { + d_recv_set[src_id].addItem(transaction); + } + if (my_id == src_id) { + d_send_set[dst_id].addItem(transaction); } } @@ -105,14 +105,14 @@ void Schedule::appendTransaction( const int src_id = transaction->getSourceProcessor(); const int dst_id = transaction->getDestinationProcessor(); - if ((my_id == src_id) && (my_id == dst_id)) { - d_local_set.appendItem(transaction); - } else { - if (my_id == dst_id) { - d_recv_set[src_id].appendItem(transaction); - } else if (my_id == src_id) { - d_send_set[dst_id].appendItem(transaction); - } + TBOX_ASSERT(my_id == src_id || my_id == dst_id); + + // A local transaction is added twice + if (my_id == dst_id) { + d_recv_set[src_id].appendItem(transaction); + } + if (my_id == src_id) { + d_send_set[dst_id].appendItem(transaction); } } @@ -156,7 +156,7 @@ void Schedule::beginCommunication() /* ************************************************************************* * * -* Perform the local data copies, deliver the messages into their * +* Perform the data copies, deliver the messages into their * * destinations, and deallocate the send buffers. * * * ************************************************************************* @@ -164,8 +164,6 @@ void Schedule::beginCommunication() void Schedule::finalizeCommunication() { - performLocalCopies(); - #ifdef HAVE_MPI std::vector requests; // Wait for both sends and recvs to complete @@ -218,10 +216,7 @@ void Schedule::calculateSendSizes() * information, then receive the number of bytes from the other * * processor. We need to be careful here since a global communication * * may not work, since not all processors may need size information, * -* so not all processors may enter the global exchange. Since each * -* processor will usually communicate with a small number of other * -* processors, local communication is also probably more efficient * -* than a global synchronization. * +* so not all processors may enter the global exchange. * * * * The general outline of the algorithm is as follows: * * * @@ -386,21 +381,6 @@ void Schedule::sendMessages() } } -/* -************************************************************************* -* * -* Perform all of the local memory-to-memory copies for this processor. * -* * -************************************************************************* -*/ - -void Schedule::performLocalCopies() -{ - for (ITERATOR local(d_local_set); local; local++) { - local()->copyLocalData(); - } -} - /* ************************************************************************* * * @@ -485,11 +465,6 @@ void Schedule::printClassData(std::ostream& stream) const recv()->printClassData(stream); } } - - stream << "Local Set" << std::endl; - for (ITERATOR local(d_local_set); local; local++) { - local()->printClassData(stream); - } } diff --git a/source/toolbox/parallel/Schedule.h b/source/toolbox/parallel/Schedule.h index db92486..d80143e 100644 --- a/source/toolbox/parallel/Schedule.h +++ b/source/toolbox/parallel/Schedule.h @@ -31,8 +31,8 @@ namespace SAMRAI { /*! * @brief Class Schedule is used to construct and execute a set of * data communication transactions. Each transaction represents some - * data dependency and exchange between two processors, or locally involving - * a single processor. Once a communication schedule is constructed, transactions + * data dependency and exchange between two processors. Once a communication + * schedule is constructed, transactions * are provided to the schedule, using either the addTransaction() method or * the appendTransaction() method. The schedule is then executed forcing * the communication, either interprocessor or local to occur. The basic idea @@ -68,9 +68,7 @@ class Schedule : public DescribedClass /*! * Add a data transaction to the head of the list of transactions already * assembled in the schedule. The transaction must involve the local - * processor as either a source or destination or both. If the transaction - * does not include the local processor, then the transaction - * is not placed on the schedule. + * processor as either a source or destination or both. * * @param transaction Pointer to transaction added to the schedule. */ @@ -79,9 +77,7 @@ class Schedule : public DescribedClass /*! * Append a data transaction to the tail of the list of transactions already * assembled in the schedule. The transaction must involve the local - * processor as either a source or destination or both. If the transaction - * does not include the local processor, then the transaction - * is not placed on the schedule. + * processor as either a source or destination or both. * * @param transaction Pointer to transaction appended to the schedule. */ @@ -144,7 +140,6 @@ class Schedule : public DescribedClass void calculateReceiveSizes(); void postMessageReceives(); void sendMessages(); - void performLocalCopies(); void processIncomingMessages(); void deallocateSendBuffers(); @@ -163,10 +158,6 @@ class Schedule : public DescribedClass Array< List< Pointer< Transaction > > > d_send_set; Array< List< Pointer< Transaction > > > d_recv_set; - - - List< Pointer< Transaction > > d_local_set; - };