![]() |
SG++-Doxygen-Documentation
|
#include <MPIMethods.hpp>
Static Public Member Functions | |
| static void | assignBatch (int workerID, size_t batchOffset, size_t batchSize, bool doCrossValidation) |
| Tell a worker to learn from a batch. More... | |
| static void | assignSystemMatrixUpdate (int workerID, size_t classIndex) |
| Assign the task of updating the system matrix to the specified worker for processing. More... | |
| static void | bcastCommandNoArgs (MPI_COMMAND_ID commandId) |
| Broadcast a command that does not require any additional information. More... | |
| template<typename Iterator > | |
| static size_t | fillBufferWithData (void *buffer, void *bufferEnd, Iterator &iterator, Iterator &listEnd) |
| Copy data from a specified iterator type into a message's payload. More... | |
| static size_t | fillBufferWithLevelIndexData (void *buffer, const void *bufferEnd, std::list< std::vector< LevelIndexPair >>::iterator &iterator, std::list< std::vector< LevelIndexPair >>::const_iterator &listEnd) |
| Copy the level index data for as many grid points as possible into the buffer specified. More... | |
| static void | finalizeMPI () |
| Cancel any remaining requests and shutdown the MPI communicator. More... | |
| static size_t | getQueueSize () |
| Check how many pending MPI requests have been registered and not completed yet. More... | |
| static unsigned int | getWorldSize () |
| Get the number of nodes participating in the current problem. More... | |
| static bool | hasPendingOutgoingRequests () |
| Check whether there are any outgoing open MPI requests that have not completed yet. More... | |
| static void | initMPI (LearnerSGDEOnOffParallel *learnerInstance) |
| Initializes the MPI setup for the specified learner. More... | |
| static bool | isMaster () |
| Check whether the current role of this node is master. More... | |
| static void | processCompletedMPIRequests () |
| Process any asynchronous MPI requests that completed but have not been processed yet. More... | |
| static void | processIncomingMPICommands (PendingMPIRequest &pendingMPIRequest) |
| Process a specific completed MPI request. More... | |
| static void | receiveGridComponentsUpdate (sgpp::datadriven::RefinementResultNetworkMessage *networkMessage) |
| Receive potentially segmented message that contains modifications to the grid. More... | |
| static void | sendCommandNoArgs (int destinationRank, MPI_COMMAND_ID commandId) |
| Send an MPI command using point to point communication without any further payload. More... | |
| static PendingMPIRequest & | sendIBcast (MPI_Packet *mpiPacket) |
| Send an assembled packet as an MPI Broadcast from the master. More... | |
| static PendingMPIRequest & | sendISend (int destinationRank, MPI_Packet *mpiPacket, size_t packetSize=sizeof(MPI_Packet), bool highPriority=false) |
| Send an MPI packet to a target destination asynchronously. More... | |
| static size_t | sendMergeGridNetworkMessage (size_t classIndex, size_t batchOffset, size_t batchSize, base::DataVector &alphaVector) |
| Send the results of training back to the master node for merging. More... | |
| static void | sendRefinementUpdates (size_t &classIndex, std::list< size_t > &deletedGridPointsIndices, std::list< LevelIndexVector > &addedGridPoints) |
| Send the refinement updates for a specified class to all workers over a broadcast. More... | |
| static void | sendSystemMatrixDecomposition (const size_t &classIndex, sgpp::base::DataMatrix &newSystemMatrixDecomposition, int mpiTarget) |
| Send a new system matrix decomposition with either broadcast or normal send. More... | |
| static void | waitForAnyMPIRequestsToComplete () |
| Wait for any of the currently pending MPI requests to complete and process them. More... | |
| static void | waitForGridConsistent (size_t classIndex) |
| Wait for a specific grid to return to its consistent state before continuing. More... | |
| static void | waitForIncomingMessageType (MPI_COMMAND_ID commandId, unsigned int numOccurrences=1, std::function< bool(PendingMPIRequest &)> predicate=[](PendingMPIRequest &request) { return true;}) |
| Wait for an incoming message of the specified type. More... | |
Static Protected Member Functions | |
| static size_t | calculateTotalPacketSize (size_t containedPacketSize) |
| Calculate the size of an MPI_Packet based on the size of its contained payload. More... | |
| static PendingMPIRequest & | createPendingMPIRequest (MPI_Packet *mpiPacket, bool isInbound) |
| Create a pending MPI request for the specified packet in preparation to sending it. More... | |
| static std::list< sgpp::datadriven::MessageTrackRequest >::iterator | createTrackRequest (unsigned int numOccurrences, const std::function< bool(PendingMPIRequest &)> &predicate) |
| Create a message track request that tests each message against a predicate until the target number of occurences are found. More... | |
| static unsigned int | executeMPIWaitAny () |
| Wait for any of the requests in the MPI request pool to complete. More... | |
| static std::list< sgpp::datadriven::PendingMPIRequest >::iterator | findPendingMPIRequest (unsigned int completedRequestIndex) |
| Find a PendingMPIRequest from the index of the completed MPI_Request structure in the pool storage. More... | |
| static void | handleIncomingRequestFromCallback (PendingMPIRequest &request) |
| Callback function that processes the request and zeros then memory region afterwards. More... | |
| static void | processCompletedMPIRequest (const std::list< sgpp::datadriven::PendingMPIRequest >::iterator &pendingMPIRequestIterator) |
| Process a specific completed MPI request from its position in the request list. More... | |
| static void | receiveMergeGridNetworkMessage (MergeGridNetworkMessage &networkMessage) |
| Receive a packet of changes from the master and apply them to the grid and refinement result or to the system matrix decomposition. More... | |
| static void | runBatch (MPI_Packet *assignBatchMessage) |
| Learn from a batch based on the instructions in the specified packet. More... | |
Static Protected Attributes | |
| static LearnerSGDEOnOffParallel * | learnerInstance |
| The instance of the learner for which MPI communications are currently being handled. More... | |
| static std::list< MessageTrackRequest > | messageTrackRequests |
| Structure to track any pending tracking requests that need to be checked on every incoming message. More... | |
| static MPIRequestPool | mpiRequestStorage |
| Structure to hold the actual MPI_Request structures in memory sequentially along with the additional information for each request. More... | |
| static unsigned int | mpiWorldSize = 0 |
| The number of participating nodes for solving the problem. More... | |
| static std::list< PendingMPIRequest > | pendingMPIRequests |
| Structure to track all pending MPI requests that have been registered but not completed. More... | |
|
static |
Tell a worker to learn from a batch.
| workerID | The MPI rank of the worker to command. |
| batchOffset | The offset from the start of the training set to learn from. |
| batchSize | The size of the batch to learn from. |
| doCrossValidation | Whether to apply cross-validation |
References sgpp::datadriven::ASSIGN_BATCH, sgpp::datadriven::AssignBatchNetworkMessage::batchOffset, calculateTotalPacketSize(), sgpp::datadriven::MPI_Packet::commandID, and sendISend().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::assignBatchToWorker().
|
static |
Assign the task of updating the system matrix to the specified worker for processing.
| workerID | The MPI rank of the worker to assign to. |
| classIndex | The class index of the system matrix to update. |
References calculateTotalPacketSize(), sgpp::datadriven::MPI_Packet::commandID, sgpp::datadriven::COMPUTE_UPDATE_SYSTEM_MATRIX_DECOMPOSITION, sgpp::datadriven::LearnerSGDEOnOffParallel::getLocalGridVersion(), sgpp::datadriven::AssignSystemMatrixUpdateNetworkMessage::gridversion, learnerInstance, and sendISend().
Referenced by sgpp::datadriven::RefinementHandler::updateClassVariablesAfterRefinement().
|
static |
Broadcast a command that does not require any additional information.
| commandId | The command to broadcast |
References sgpp::datadriven::MPI_Packet::commandID, and sendIBcast().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::shutdownMPINodes().
|
staticprotected |
Calculate the size of an MPI_Packet based on the size of its contained payload.
| containedPacketSize | The size of the contained payload. |
References sgpp::datadriven::MPI_Packet::payload.
Referenced by assignBatch(), and assignSystemMatrixUpdate().
|
staticprotected |
Create a pending MPI request for the specified packet in preparation to sending it.
| mpiPacket | The packet of data for the request. |
| isInbound | Whether the request is an inbound request. |
References sgpp::datadriven::PendingMPIRequest::buffer, sgpp::datadriven::PendingMPIRequest::callback, D, sgpp::datadriven::PendingMPIRequest::disposeAfterCallback, sgpp::datadriven::PendingMPIRequest::inbound, mpiRequestStorage, and pendingMPIRequests.
Referenced by initMPI(), sendIBcast(), and sendISend().
|
staticprotected |
Create a message track request that tests each message against a predicate until the target number of occurences are found.
| numOccurrences | How many successful matches are required. |
| predicate | The predicate to test messages against. |
References messageTrackRequests.
Referenced by waitForIncomingMessageType().
|
staticprotected |
Wait for any of the requests in the MPI request pool to complete.
References CHECK_INT_TO_UINT, CHECK_SIZE_T_TO_INT, python.leja::count, D, sgpp::datadriven::MPIRequestPool::getMPIRequests(), mpiRequestStorage, pendingMPIRequests, and sgpp::datadriven::MPIRequestPool::size().
Referenced by waitForAnyMPIRequestsToComplete(), and waitForIncomingMessageType().
|
static |
Copy data from a specified iterator type into a message's payload.
| Iterator | The type of iterator used to read values to copy. |
| buffer | The start of the buffer to copy to. |
| bufferEnd | The end of the buffer to copy to. |
| iterator | The start of the data to copy from. |
| listEnd | The end of the data to copy from. |
Referenced by sendMergeGridNetworkMessage(), and sendSystemMatrixDecomposition().
|
static |
Copy the level index data for as many grid points as possible into the buffer specified.
| buffer | The start of the buffer to copy to. |
| bufferEnd | The end of the buffer to copy to. |
| iterator | The start of the data to copy. |
| listEnd | The end of the data to copy. |
Referenced by sendRefinementUpdates().
|
static |
Cancel any remaining requests and shutdown the MPI communicator.
May be called only once during a programs runtime. Collectives (for example MPI_Ibcast) cannot be cancelled. These must complete before calling this method.
References pendingMPIRequests.
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::~LearnerSGDEOnOffParallel().
|
staticprotected |
Find a PendingMPIRequest from the index of the completed MPI_Request structure in the pool storage.
| completedRequestIndex | The index of the completed MPI_Request in the MPIRequestPool. |
References pendingMPIRequests.
Referenced by waitForAnyMPIRequestsToComplete(), and waitForIncomingMessageType().
|
static |
Check how many pending MPI requests have been registered and not completed yet.
References pendingMPIRequests.
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel().
|
static |
Get the number of nodes participating in the current problem.
References mpiWorldSize.
Referenced by sgpp::datadriven::RoundRobinScheduler::assignTaskStaticTaskSize(), and sgpp::datadriven::LearnerSGDEOnOffParallel::shutdownMPINodes().
|
staticprotected |
Callback function that processes the request and zeros then memory region afterwards.
References sgpp::datadriven::PendingMPIRequest::buffer, D, and processIncomingMPICommands().
Referenced by initMPI().
|
static |
Check whether there are any outgoing open MPI requests that have not completed yet.
References pendingMPIRequests.
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel().
|
static |
Initializes the MPI setup for the specified learner.
This may only be called once, as it calls MPI_Init.
| learnerInstance | The instance of the learner to handle MPI communication for. |
References CHECK_INT_TO_UINT, createPendingMPIRequest(), D, handleIncomingRequestFromCallback(), isMaster(), learnerInstance, MPI_MASTER_RANK, MPI_MAX_PROCESSOR_NAME_LENGTH, MPI_TAG_HIGH_PRIORITY_NO_BLOCK, MPI_TAG_STANDARD_COMMAND, and mpiWorldSize.
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::LearnerSGDEOnOffParallel().
|
static |
Check whether the current role of this node is master.
References MPI_MASTER_RANK.
Referenced by initMPI(), receiveGridComponentsUpdate(), sgpp::datadriven::LearnerSGDEOnOffParallel::shutdownMPINodes(), sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel(), and sgpp::datadriven::RefinementHandler::updateClassVariablesAfterRefinement().
|
staticprotected |
Process a specific completed MPI request from its position in the request list.
| pendingMPIRequestIterator | The position of the completed MPI request. |
References D, messageTrackRequests, and pendingMPIRequests.
Referenced by processCompletedMPIRequests(), waitForAnyMPIRequestsToComplete(), and waitForIncomingMessageType().
|
static |
Process any asynchronous MPI requests that completed but have not been processed yet.
References D, pendingMPIRequests, and processCompletedMPIRequest().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel().
|
static |
Process a specific completed MPI request.
| pendingMPIRequest | The completed MPI request. |
References sgpp::datadriven::ASSIGN_BATCH, sgpp::datadriven::PendingMPIRequest::buffer, sgpp::datadriven::MPI_Packet::commandID, sgpp::datadriven::COMPUTE_UPDATE_SYSTEM_MATRIX_DECOMPOSITION, sgpp::datadriven::LearnerSGDEOnOffParallel::computeNewSystemMatrixDecomposition(), D, sgpp::datadriven::PendingMPIRequest::disposeAfterCallback, learnerInstance, sgpp::datadriven::MERGE_GRID, sgpp::datadriven::NULL_COMMAND, sgpp::datadriven::MPI_Packet::payload, receiveGridComponentsUpdate(), receiveMergeGridNetworkMessage(), runBatch(), sgpp::datadriven::SHUTDOWN, sgpp::datadriven::LearnerSGDEOnOffParallel::shutdownMPINodes(), sgpp::datadriven::UPDATE_GRID, and sgpp::datadriven::WORKER_SHUTDOWN_SUCCESS.
Referenced by handleIncomingRequestFromCallback().
|
static |
Receive potentially segmented message that contains modifications to the grid.
Extract the data into a refinement result and apply to grid or apply to system matrix. This includes additions, deletions, and system matrix updates.
| networkMessage | The message containing the modification data. |
References sgpp::datadriven::ADDED_GRID_POINTS_LIST, sgpp::datadriven::RefinementResult::addedGridPoints, sgpp::datadriven::ASSIGN_BATCH, sgpp::datadriven::LearnerSGDEOnOffParallel::checkGridStateConsistent(), sgpp::datadriven::RefinementResultNetworkMessage::classIndex, D, sgpp::datadriven::DELETED_GRID_POINTS_LIST, sgpp::datadriven::RefinementResult::deletedGridPointsIndices, sgpp::datadriven::LearnerSGDEOnOffParallel::getDensityFunctions(), sgpp::datadriven::LearnerSGDEOnOffParallel::getDimensionality(), sgpp::datadriven::LearnerSGDEOnOffParallel::getGrid(), sgpp::datadriven::LearnerSGDEOnOffParallel::getLocalGridVersion(), sgpp::datadriven::LearnerSGDEOnOffParallel::getRefinementHandler(), sgpp::datadriven::RefinementHandler::getRefinementResult(), GRID_RECEIVED_ADDED_POINTS, GRID_TEMPORARILY_INCONSISTENT, sgpp::datadriven::RefinementResultNetworkMessage::gridversion, isMaster(), sgpp::datadriven::LearnerSGDEOnOffParallel::isVersionConsistent(), learnerInstance, sgpp::datadriven::RefinementResultNetworkMessage::listLength, sgpp::datadriven::RefinementResultNetworkMessage::payload, sgpp::base::DataMatrix::resizeRowsCols(), sendSystemMatrixDecomposition(), sgpp::datadriven::LearnerSGDEOnOffParallel::setLocalGridVersion(), sgpp::datadriven::SYSTEM_MATRIX_DECOMPOSITION, sgpp::datadriven::RefinementHandler::updateClassVariablesAfterRefinement(), sgpp::datadriven::RefinementResultNetworkMessage::updateType, and waitForIncomingMessageType().
Referenced by processIncomingMPICommands().
|
staticprotected |
Receive a packet of changes from the master and apply them to the grid and refinement result or to the system matrix decomposition.
| networkMessage | The packet containing the changes |
References sgpp::datadriven::MergeGridNetworkMessage::alphaTotalSize, sgpp::datadriven::MergeGridNetworkMessage::batchOffset, sgpp::datadriven::MergeGridNetworkMessage::batchSize, sgpp::datadriven::MergeGridNetworkMessage::classIndex, D, sgpp::datadriven::MergeGridNetworkMessage::gridversion, learnerInstance, sgpp::datadriven::LearnerSGDEOnOffParallel::mergeAlphaValues(), sgpp::datadriven::MergeGridNetworkMessage::payload, sgpp::datadriven::MergeGridNetworkMessage::payloadLength, and sgpp::datadriven::MergeGridNetworkMessage::payloadOffset.
Referenced by processIncomingMPICommands().
|
staticprotected |
Learn from a batch based on the instructions in the specified packet.
| assignBatchMessage | The packet specifying learning parameters. |
References D, dataset, sgpp::datadriven::LearnerSGDEOnOffParallel::getDimensionality(), learnerInstance, sgpp::datadriven::MPI_Packet::payload, and sgpp::datadriven::LearnerSGDEOnOffParallel::workBatch().
Referenced by processIncomingMPICommands().
|
static |
Send an MPI command using point to point communication without any further payload.
| destinationRank | The MPI rank of the receiving node. |
| commandId | The command to send. |
References sgpp::datadriven::MPI_Packet::commandID, and sendISend().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel().
|
static |
Send an assembled packet as an MPI Broadcast from the master.
| mpiPacket | The packet to transmit. |
References createPendingMPIRequest(), D, sgpp::datadriven::PendingMPIRequest::getMPIRequestFromHandle(), and MPI_MASTER_RANK.
Referenced by bcastCommandNoArgs(), sendRefinementUpdates(), and sendSystemMatrixDecomposition().
|
static |
Send an MPI packet to a target destination asynchronously.
| destinationRank | The MPI rank of the destination. |
| mpiPacket | The MPI packet to send. |
| packetSize | The size of the MPI packet to send, defaults to the entire packet. |
| highPriority | Whether to send the packet on the high priority no_wait channel. |
References CHECK_SIZE_T_TO_INT, createPendingMPIRequest(), D, sgpp::datadriven::PendingMPIRequest::getMPIRequestFromHandle(), MPI_TAG_HIGH_PRIORITY_NO_BLOCK, and MPI_TAG_STANDARD_COMMAND.
Referenced by assignBatch(), assignSystemMatrixUpdate(), sendCommandNoArgs(), sendMergeGridNetworkMessage(), and sendSystemMatrixDecomposition().
|
static |
Send the results of training back to the master node for merging.
| classIndex | The index of the class to send results for. |
| batchOffset | The offset from the start of the dataset used in this batch. |
| batchSize | The size of the current batch. |
| alphaVector | The results vector to transmit. |
References sgpp::datadriven::MergeGridNetworkMessage::classIndex, sgpp::datadriven::MPI_Packet::commandID, D, fillBufferWithData(), sgpp::datadriven::LearnerSGDEOnOffParallel::getLocalGridVersion(), learnerInstance, sgpp::datadriven::MERGE_GRID, MPI_MASTER_RANK, and sendISend().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::workBatch().
|
static |
Send the refinement updates for a specified class to all workers over a broadcast.
| classIndex | The index of the modified class. |
| deletedGridPointsIndices | The list containing deleted grid points indices. |
| addedGridPoints | The coordinates of any added grid points. |
References sgpp::datadriven::ADDED_GRID_POINTS_LIST, sgpp::datadriven::RefinementResultNetworkMessage::classIndex, sgpp::datadriven::MPI_Packet::commandID, D, sgpp::datadriven::DELETED_GRID_POINTS_LIST, fillBufferWithLevelIndexData(), GRID_RECEIVED_ADDED_POINTS, GRID_RECEIVED_DELETED_INDEXES, GRID_TEMPORARILY_INCONSISTENT, sendIBcast(), and sgpp::datadriven::UPDATE_GRID.
Referenced by sgpp::datadriven::RefinementHandler::updateClassVariablesAfterRefinement().
|
static |
Send a new system matrix decomposition with either broadcast or normal send.
| classIndex | The class index of the new system matrix decomposition |
| newSystemMatrixDecomposition | The new system matrix decomposition |
| mpiTarget | The MPI rank to send the decomposition to. Use MPI_ANY_SOURCE for broadcast. |
References sgpp::datadriven::RefinementResultNetworkMessage::classIndex, sgpp::datadriven::MPI_Packet::commandID, D, fillBufferWithData(), sgpp::datadriven::LearnerSGDEOnOffParallel::getLocalGridVersion(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), GRID_TEMPORARILY_INCONSISTENT, learnerInstance, sgpp::datadriven::RefinementResultSystemMatrixNetworkMessage::matrixWidth, sendIBcast(), sendISend(), sgpp::datadriven::SYSTEM_MATRIX_DECOMPOSITION, and sgpp::datadriven::UPDATE_GRID.
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::computeNewSystemMatrixDecomposition(), and receiveGridComponentsUpdate().
|
static |
Wait for any of the currently pending MPI requests to complete and process them.
References executeMPIWaitAny(), findPendingMPIRequest(), and processCompletedMPIRequest().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::trainParallel().
|
static |
Wait for a specific grid to return to its consistent state before continuing.
| classIndex | The grid's class index. |
References sgpp::datadriven::LearnerSGDEOnOffParallel::checkGridStateConsistent(), D, sgpp::datadriven::LearnerSGDEOnOffParallel::getLocalGridVersion(), learnerInstance, sgpp::datadriven::UPDATE_GRID, and waitForIncomingMessageType().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::mergeAlphaValues(), and sgpp::datadriven::LearnerSGDEOnOffParallel::waitForAllGridsConsistent().
|
static |
Wait for an incoming message of the specified type.
Can optionally include a number of occurences to wait for and a predicate to test each message against.
| commandId | The command id of the target packet. |
| numOccurrences | The number of specified messages to receive. |
| predicate | A predicate to test each message against. |
References sgpp::datadriven::PendingMPIRequest::buffer, sgpp::datadriven::MPI_Packet::commandID, createTrackRequest(), D, executeMPIWaitAny(), findPendingMPIRequest(), sgpp::datadriven::PendingMPIRequest::inbound, messageTrackRequests, and processCompletedMPIRequest().
Referenced by sgpp::datadriven::LearnerSGDEOnOffParallel::computeNewSystemMatrixDecomposition(), sgpp::datadriven::LearnerSGDEOnOffParallel::doRefinementForAll(), receiveGridComponentsUpdate(), sgpp::datadriven::LearnerSGDEOnOffParallel::shutdownMPINodes(), and waitForGridConsistent().
|
staticprotected |
The instance of the learner for which MPI communications are currently being handled.
Referenced by assignSystemMatrixUpdate(), initMPI(), processIncomingMPICommands(), receiveGridComponentsUpdate(), receiveMergeGridNetworkMessage(), runBatch(), sendMergeGridNetworkMessage(), sendSystemMatrixDecomposition(), and waitForGridConsistent().
|
staticprotected |
Structure to track any pending tracking requests that need to be checked on every incoming message.
Referenced by createTrackRequest(), processCompletedMPIRequest(), and waitForIncomingMessageType().
|
staticprotected |
Structure to hold the actual MPI_Request structures in memory sequentially along with the additional information for each request.
Referenced by createPendingMPIRequest(), and executeMPIWaitAny().
|
staticprotected |
The number of participating nodes for solving the problem.
Referenced by getWorldSize(), and initMPI().
|
staticprotected |
Structure to track all pending MPI requests that have been registered but not completed.
Referenced by createPendingMPIRequest(), executeMPIWaitAny(), finalizeMPI(), findPendingMPIRequest(), getQueueSize(), hasPendingOutgoingRequests(), processCompletedMPIRequest(), and processCompletedMPIRequests().