Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove local copies from Schedule. #11

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 18 additions & 43 deletions source/toolbox/parallel/Schedule.C
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -156,16 +156,14 @@ 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. *
* *
*************************************************************************
*/

void Schedule::finalizeCommunication()
{
performLocalCopies();

#ifdef HAVE_MPI
std::vector<MPI_Request> requests;
// Wait for both sends and recvs to complete
Expand Down Expand Up @@ -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: *
* *
Expand Down Expand Up @@ -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();
}
}

/*
*************************************************************************
* *
Expand Down Expand Up @@ -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);
}
}


Expand Down
17 changes: 4 additions & 13 deletions source/toolbox/parallel/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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.
*/
Expand Down Expand Up @@ -144,7 +140,6 @@ class Schedule : public DescribedClass
void calculateReceiveSizes();
void postMessageReceives();
void sendMessages();
void performLocalCopies();
void processIncomingMessages();
void deallocateSendBuffers();

Expand All @@ -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;

};


Expand Down