#include <ParallelStudy.h>
Public Types | |
typedef MooseUtils::Buffer< WorkType >::iterator | work_iterator |
typedef MooseUtils::Buffer< std::shared_ptr< ParallelDataType > >::iterator | parallel_data_iterator |
Public Member Functions | |
ParallelStudy (const libMesh::Parallel::Communicator &comm, const InputParameters ¶ms, const std::string &name) | |
void | preExecute () |
Pre-execute method that MUST be called before execute() and before adding work. More... | |
void | execute () |
Execute method. More... | |
template<typename... Args> | |
MooseUtils::SharedPool< ParallelDataType >::PtrType | acquireParallelData (const THREAD_ID tid, Args &&... args) |
Acquire a parallel data object from the pool. More... | |
void | moveParallelDataToBuffer (std::shared_ptr< ParallelDataType > &data, const processor_id_type dest_pid) |
Moves parallel data objects to the send buffer to be communicated to processor dest_pid . More... | |
const ReceiveBuffer< ParallelDataType, ParallelStudy< WorkType, ParallelDataType > > & | receiveBuffer () const |
Gets the receive buffer. More... | |
const MooseUtils::Buffer< WorkType > & | workBuffer () const |
Gets the work buffer. More... | |
unsigned long long int | sendBufferPoolCreated () const |
Gets the total number of send buffer pools created. More... | |
unsigned long long int | parallelDataSent () const |
Gets the total number of parallel data objects sent from this processor. More... | |
unsigned long long int | buffersSent () const |
Gets the total number of buffers sent from this processor. More... | |
unsigned long long int | poolParallelDataCreated () const |
Gets the total number of parallel data created in all of the threaded pools. More... | |
unsigned long long int | localWorkStarted () const |
Gets the total amount of work started from this processor. More... | |
unsigned long long int | localWorkExecuted () const |
Gets the total amount of work executed on this processor. More... | |
unsigned long long int | totalWorkCompleted () const |
Gets the total amount of work completeed across all processors. More... | |
unsigned long long int | localChunksExecuted () const |
Gets the total number of chunks of work executed on this processor. More... | |
bool | currentlyExecuting () const |
Whether or not this object is currently in execute(). More... | |
bool | currentlyPreExecuting () const |
Whether or not this object is between preExecute() and execute(). More... | |
unsigned int | maxBufferSize () const |
Gets the max buffer size. More... | |
unsigned int | chunkSize () const |
Gets the chunk size. More... | |
unsigned int | clicksPerCommunication () const |
Gets the number of iterations to wait before communicating. More... | |
unsigned int | clicksPerRootCommunication () const |
Gets the number of iterations to wait before communicating with root. More... | |
unsigned int | clicksPerReceive () const |
Gets the number of iterations to wait before checking for new parallel data. More... | |
ParallelStudyMethod | method () const |
Gets the method. More... | |
void | reserveBuffer (const std::size_t size) |
Reserve size entries in the work buffer. More... | |
const Parallel::Communicator & | comm () const |
processor_id_type | n_processors () const |
processor_id_type | processor_id () const |
void | moveWorkToBuffer (WorkType &work, const THREAD_ID tid) |
Adds work to the buffer to be executed. More... | |
void | moveWorkToBuffer (const work_iterator begin, const work_iterator end, const THREAD_ID tid) |
void | moveWorkToBuffer (std::vector< WorkType > &work, const THREAD_ID tid) |
Static Public Member Functions | |
static InputParameters | validParams () |
Protected Types | |
enum | MoveWorkError { DURING_EXECUTION_DISABLED, PRE_EXECUTION_AND_EXECUTION_ONLY, PRE_EXECUTION_ONLY, PRE_EXECUTION_THREAD_0_ONLY, CONTINUING_DURING_EXECUTING_WORK } |
Enum for providing useful errors during work addition in moveWorkError(). More... | |
Protected Member Functions | |
virtual std::unique_ptr< MooseUtils::Buffer< WorkType > > | createWorkBuffer () |
Creates the work buffer. More... | |
virtual void | executeWork (const WorkType &work, const THREAD_ID tid)=0 |
Pure virtual to be overridden that executes a single object of work on a given thread. More... | |
virtual void | moveWorkError (const MoveWorkError error, const WorkType *work=nullptr) const |
Virtual that allows for the customization of error text for moving work into the buffer. More... | |
virtual bool | alternateSmartEndingCriteriaMet () |
Insertion point for derived classes to provide an alternate ending criteria for SMART execution. More... | |
virtual void | postExecuteChunk (const work_iterator, const work_iterator) |
Insertion point for acting on work that was just executed. More... | |
virtual void | preReceiveAndExecute () |
Insertion point called just after trying to receive work and just before beginning work on the work buffer. More... | |
virtual void | postReceiveParallelData (const parallel_data_iterator begin, const parallel_data_iterator end)=0 |
Pure virtual for acting on parallel data that has JUST been received and filled into the buffer. More... | |
virtual bool | workIsComplete (const WorkType &) |
Can be overridden to denote if a piece of work is not complete yet. More... | |
bool | buffersAreEmpty () const |
Whether or not ALL of the buffers are empty: Working buffer, threaded buffers, receive buffer, and send buffers. More... | |
void | moveContinuingWorkToBuffer (WorkType &Work) |
Moves work that is considered continuing for the purposes of the execution algorithm into the buffer. More... | |
void | moveContinuingWorkToBuffer (const work_iterator begin, const work_iterator end) |
Protected Attributes | |
const processor_id_type | _pid |
This rank. More... | |
const std::string | _name |
Name for this object for use in error handling. More... | |
const InputParameters & | _params |
The InputParameters. More... | |
const ParallelStudyMethod | _method |
The study method. More... | |
bool | _has_alternate_ending_criteria |
Whether or not this object has alternate ending criteria. More... | |
const Parallel::Communicator & | _communicator |
Private Member Functions | |
void | flushSendBuffers () |
Flushes all parallel data out of the send buffers. More... | |
void | smartExecute () |
Execute work using SMART. More... | |
void | harmExecute () |
Execute work using HARM. More... | |
void | bsExecute () |
Execute work using BS. More... | |
bool | receiveAndExecute () |
Receive packets of parallel data from other processors and executes work. More... | |
void | executeAndBuffer (const std::size_t chunk_size) |
Execute a chunk of work and buffer. More... | |
void | canMoveWorkCheck (const THREAD_ID tid) |
Internal check for if it is allowed to currently add work in moveWorkToBuffer(). More... | |
void | postReceiveParallelDataInternal () |
Internal method for acting on the parallel data that has just been received into the parallel buffer. More... | |
Private Attributes | |
const unsigned int | _min_buffer_size |
Minimum size of a SendBuffer. More... | |
const unsigned int | _max_buffer_size |
Number of objects to buffer before communication. More... | |
const Real | _buffer_growth_multiplier |
Multiplier for the buffer size for growing the buffer. More... | |
const Real | _buffer_shrink_multiplier |
Multiplier for the buffer size for shrinking the buffer. More... | |
const unsigned int | _chunk_size |
Number of objects to execute at once during communication. More... | |
const bool | _allow_new_work_during_execution |
Whether or not to allow the addition of new work to the buffer during execution. More... | |
const unsigned int | _clicks_per_communication |
Iterations to wait before communicating. More... | |
const unsigned int | _clicks_per_root_communication |
Iterations to wait before communicating with root. More... | |
const unsigned int | _clicks_per_receive |
Iterations to wait before checking for new objects. More... | |
Parallel::MessageTag | _parallel_data_buffer_tag |
MessageTag for sending parallel data. More... | |
std::vector< MooseUtils::SharedPool< ParallelDataType > > | _parallel_data_pools |
Pools for re-using destructed parallel data objects (one for each thread) More... | |
std::vector< std::vector< WorkType > > | _temp_threaded_work |
Threaded temprorary storage for work added while we're using the _work_buffer (one for each thread) More... | |
const std::unique_ptr< MooseUtils::Buffer< WorkType > > | _work_buffer |
Buffer for executing work. More... | |
const std::unique_ptr< ReceiveBuffer< ParallelDataType, ParallelStudy< WorkType, ParallelDataType > > > | _receive_buffer |
The receive buffer. More... | |
std::unordered_map< processor_id_type, std::unique_ptr< SendBuffer< ParallelDataType, ParallelStudy< WorkType, ParallelDataType > > > > | _send_buffers |
Send buffers for each processor. More... | |
unsigned long long int | _local_chunks_executed |
Number of chunks of work executed on this processor. More... | |
unsigned long long int | _local_work_completed |
Amount of work completed on this processor. More... | |
unsigned long long int | _local_work_started |
Amount of work started on this processor. More... | |
unsigned long long int | _local_work_executed |
Amount of work executed on this processor. More... | |
unsigned long long int | _total_work_started |
Amount of work started on all processors. More... | |
unsigned long long int | _total_work_completed |
Amount of work completed on all processors. More... | |
bool | _currently_executing |
Whether we are within execute() More... | |
bool | _currently_pre_executing |
Whether we are between preExecute() and execute() More... | |
bool | _currently_executing_work |
Whether or not we are currently within executeAndBuffer() More... | |
Definition at line 29 of file ParallelStudy.h.
typedef MooseUtils::Buffer<std::shared_ptr<ParallelDataType> >::iterator ParallelStudy< WorkType, ParallelDataType >::parallel_data_iterator |
Definition at line 34 of file ParallelStudy.h.
typedef MooseUtils::Buffer<WorkType>::iterator ParallelStudy< WorkType, ParallelDataType >::work_iterator |
Definition at line 32 of file ParallelStudy.h.
|
protected |
Enum for providing useful errors during work addition in moveWorkError().
Enumerator | |
---|---|
DURING_EXECUTION_DISABLED | |
PRE_EXECUTION_AND_EXECUTION_ONLY | |
PRE_EXECUTION_ONLY | |
PRE_EXECUTION_THREAD_0_ONLY | |
CONTINUING_DURING_EXECUTING_WORK |
Definition at line 182 of file ParallelStudy.h.
ParallelStudy< WorkType, ParallelDataType >::ParallelStudy | ( | const libMesh::Parallel::Communicator & | comm, |
const InputParameters & | params, | ||
const std::string & | name | ||
) |
Definition at line 370 of file ParallelStudy.h.
|
inline |
Acquire a parallel data object from the pool.
Definition at line 73 of file ParallelStudy.h.
|
protectedvirtual |
Insertion point for derived classes to provide an alternate ending criteria for SMART execution.
Only called when _has_alternate_ending_criteria == true.
Definition at line 1202 of file ParallelStudy.h.
|
private |
Execute work using BS.
Definition at line 900 of file ParallelStudy.h.
|
protected |
Whether or not ALL of the buffers are empty: Working buffer, threaded buffers, receive buffer, and send buffers.
Definition at line 1209 of file ParallelStudy.h.
unsigned long long int ParallelStudy< WorkType, ParallelDataType >::buffersSent | ( | ) | const |
Gets the total number of buffers sent from this processor.
Definition at line 1178 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
private |
Internal check for if it is allowed to currently add work in moveWorkToBuffer().
Definition at line 1050 of file ParallelStudy.h.
|
inline |
Gets the chunk size.
Definition at line 148 of file ParallelStudy.h.
|
inline |
Gets the number of iterations to wait before communicating.
Definition at line 153 of file ParallelStudy.h.
|
inline |
Gets the number of iterations to wait before checking for new parallel data.
Definition at line 161 of file ParallelStudy.h.
|
inline |
Gets the number of iterations to wait before communicating with root.
Definition at line 157 of file ParallelStudy.h.
|
protectedvirtual |
Creates the work buffer.
This is virtual so that derived classes can use their own specialized buffers
Definition at line 419 of file ParallelStudy.h.
|
inline |
Whether or not this object is currently in execute().
Definition at line 135 of file ParallelStudy.h.
|
inline |
Whether or not this object is between preExecute() and execute().
Definition at line 139 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::execute | ( | ) |
Execute method.
Definition at line 988 of file ParallelStudy.h.
|
private |
Execute a chunk of work and buffer.
Definition at line 497 of file ParallelStudy.h.
|
protectedpure virtual |
Pure virtual to be overridden that executes a single object of work on a given thread.
Implemented in ParallelRayStudy.
|
private |
Flushes all parallel data out of the send buffers.
Definition at line 610 of file ParallelStudy.h.
|
private |
Execute work using HARM.
Definition at line 803 of file ParallelStudy.h.
|
inline |
Gets the total number of chunks of work executed on this processor.
Definition at line 130 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
inline |
Gets the total amount of work executed on this processor.
Definition at line 122 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
inline |
Gets the total amount of work started from this processor.
Definition at line 118 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
inline |
Gets the max buffer size.
Definition at line 144 of file ParallelStudy.h.
|
inline |
Gets the method.
Definition at line 166 of file ParallelStudy.h.
|
protected |
Moves work that is considered continuing for the purposes of the execution algorithm into the buffer.
Definition at line 1128 of file ParallelStudy.h.
|
protected |
Definition at line 1138 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::moveParallelDataToBuffer | ( | std::shared_ptr< ParallelDataType > & | data, |
const processor_id_type | dest_pid | ||
) |
Moves parallel data objects to the send buffer to be communicated to processor dest_pid
.
Definition at line 576 of file ParallelStudy.h.
|
protectedvirtual |
Virtual that allows for the customization of error text for moving work into the buffer.
Definition at line 1022 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::moveWorkToBuffer | ( | WorkType & | work, |
const THREAD_ID | tid | ||
) |
Adds work to the buffer to be executed.
This will move the work into the buffer (with std::move), therefore the passed in work will be invalid after this call. For the purposes of the completion algorithm, this added work is considered NEW work.
During pre-execution (between preExecute() and execute()), this method can ONLY be called on thread 0.
During execute(), this method is thread safe and can be used to add work during execution.
Definition at line 1070 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::moveWorkToBuffer | ( | const work_iterator | begin, |
const work_iterator | end, | ||
const THREAD_ID | tid | ||
) |
Definition at line 1089 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::moveWorkToBuffer | ( | std::vector< WorkType > & | work, |
const THREAD_ID | tid | ||
) |
Definition at line 1120 of file ParallelStudy.h.
unsigned long long int ParallelStudy< WorkType, ParallelDataType >::parallelDataSent | ( | ) | const |
Gets the total number of parallel data objects sent from this processor.
Definition at line 1166 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
unsigned long long int ParallelStudy< WorkType, ParallelDataType >::poolParallelDataCreated | ( | ) | const |
Gets the total number of parallel data created in all of the threaded pools.
Definition at line 1190 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
inlineprotectedvirtual |
Insertion point for acting on work that was just executed.
This is not called in threads.
Definition at line 219 of file ParallelStudy.h.
|
protectedpure virtual |
Pure virtual for acting on parallel data that has JUST been received and filled into the buffer.
The parallel data in the range passed here will have its use count reduced by one if it still exists after this call.
|
private |
Internal method for acting on the parallel data that has just been received into the parallel buffer.
Definition at line 630 of file ParallelStudy.h.
void ParallelStudy< WorkType, ParallelDataType >::preExecute | ( | ) |
Pre-execute method that MUST be called before execute() and before adding work.
Definition at line 964 of file ParallelStudy.h.
|
inlineprotectedvirtual |
Insertion point called just after trying to receive work and just before beginning work on the work buffer.
Definition at line 225 of file ParallelStudy.h.
|
private |
Receive packets of parallel data from other processors and executes work.
Definition at line 646 of file ParallelStudy.h.
|
inline |
Gets the receive buffer.
Definition at line 88 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
void ParallelStudy< WorkType, ParallelDataType >::reserveBuffer | ( | const std::size_t | size | ) |
Reserve size
entries in the work buffer.
This can only be used during the pre-execution phase (between preExecute() and execute()).
This is particularly useful when one wants to move many work objects into the buffer using moveWorkToBuffer() and wants to allocate the space ahead of time.
Definition at line 618 of file ParallelStudy.h.
unsigned long long int ParallelStudy< WorkType, ParallelDataType >::sendBufferPoolCreated | ( | ) | const |
Gets the total number of send buffer pools created.
Definition at line 1154 of file ParallelStudy.h.
Referenced by PerProcessorRayTracingResultsVectorPostprocessor::execute().
|
private |
Execute work using SMART.
Definition at line 686 of file ParallelStudy.h.
|
inline |
Gets the total amount of work completeed across all processors.
Definition at line 126 of file ParallelStudy.h.
Referenced by RayTracingStudyResult::getValue().
|
static |
Definition at line 436 of file ParallelStudy.h.
|
inline |
Gets the work buffer.
Definition at line 96 of file ParallelStudy.h.
|
inlineprotectedvirtual |
Can be overridden to denote if a piece of work is not complete yet.
The complete terminology is used within the execution algorithms to determine if the study is complete.
Reimplemented in ParallelRayStudy.
Definition at line 243 of file ParallelStudy.h.
|
private |
Whether or not to allow the addition of new work to the buffer during execution.
Definition at line 322 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::ParallelStudy().
|
private |
Multiplier for the buffer size for growing the buffer.
Definition at line 316 of file ParallelStudy.h.
|
private |
Multiplier for the buffer size for shrinking the buffer.
Definition at line 318 of file ParallelStudy.h.
|
private |
Number of objects to execute at once during communication.
Definition at line 320 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::chunkSize().
|
private |
Iterations to wait before communicating.
Definition at line 325 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::clicksPerCommunication().
|
private |
Iterations to wait before checking for new objects.
Definition at line 329 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::clicksPerReceive().
|
private |
Iterations to wait before communicating with root.
Definition at line 327 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::clicksPerRootCommunication().
|
private |
Whether we are within execute()
Definition at line 362 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::currentlyExecuting().
|
private |
Whether or not we are currently within executeAndBuffer()
Definition at line 366 of file ParallelStudy.h.
|
private |
Whether we are between preExecute() and execute()
Definition at line 364 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::currentlyPreExecuting().
|
protected |
Whether or not this object has alternate ending criteria.
Definition at line 269 of file ParallelStudy.h.
|
private |
Number of chunks of work executed on this processor.
Definition at line 349 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::localChunksExecuted().
|
private |
Amount of work completed on this processor.
Definition at line 351 of file ParallelStudy.h.
|
private |
Amount of work executed on this processor.
Definition at line 355 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::localWorkExecuted().
|
private |
Amount of work started on this processor.
Definition at line 353 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::localWorkStarted().
|
private |
Number of objects to buffer before communication.
Definition at line 314 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::maxBufferSize().
|
protected |
The study method.
Definition at line 267 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::method(), and ParallelStudy< std::shared_ptr< Ray >, Ray >::ParallelStudy().
|
private |
Minimum size of a SendBuffer.
Definition at line 312 of file ParallelStudy.h.
|
protected |
Name for this object for use in error handling.
Definition at line 263 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::ParallelStudy().
|
private |
MessageTag for sending parallel data.
Definition at line 332 of file ParallelStudy.h.
|
private |
Pools for re-using destructed parallel data objects (one for each thread)
Definition at line 334 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::acquireParallelData().
|
protected |
The InputParameters.
Definition at line 265 of file ParallelStudy.h.
|
protected |
This rank.
Definition at line 261 of file ParallelStudy.h.
|
private |
The receive buffer.
Definition at line 341 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::receiveBuffer().
|
private |
Send buffers for each processor.
Definition at line 346 of file ParallelStudy.h.
|
private |
Threaded temprorary storage for work added while we're using the _work_buffer (one for each thread)
Definition at line 336 of file ParallelStudy.h.
|
private |
Amount of work completed on all processors.
Definition at line 359 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::totalWorkCompleted().
|
private |
Amount of work started on all processors.
Definition at line 357 of file ParallelStudy.h.
|
private |
Buffer for executing work.
Definition at line 338 of file ParallelStudy.h.
Referenced by ParallelStudy< std::shared_ptr< Ray >, Ray >::workBuffer().