https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ParallelRayStudy Class Referenceabstract

#include <ParallelRayStudy.h>

Inheritance diagram for ParallelRayStudy:
[legend]

Public Types

typedef MooseUtils::Buffer< std::shared_ptr< Ray > >::iterator work_iterator
 
typedef MooseUtils::Buffer< std::shared_ptr< Ray > >::iterator parallel_data_iterator
 

Public Member Functions

 ParallelRayStudy (RayTracingStudy &study, const std::vector< std::shared_ptr< TraceRay > > &threaded_trace_ray)
 
void preExecute ()
 Pre-execute method that MUST be called before execute() and before adding work.
 
void execute ()
 Execute method.
 
MooseUtils::SharedPool< Ray >::PtrType acquireParallelData (const THREAD_ID tid, Args &&... args)
 Acquire a parallel data object from the pool.
 
void moveParallelDataToBuffer (std::shared_ptr< Ray > &data, const processor_id_type dest_pid)
 Moves parallel data objects to the send buffer to be communicated to processor dest_pid.
 
const ReceiveBuffer< Ray, ParallelStudy< std::shared_ptr< Ray >, Ray > > & receiveBuffer () const
 Gets the receive buffer.
 
const MooseUtils::Buffer< std::shared_ptr< Ray > > & workBuffer () const
 Gets the work buffer.
 
unsigned long long int sendBufferPoolCreated () const
 Gets the total number of send buffer pools created.
 
unsigned long long int parallelDataSent () const
 Gets the total number of parallel data objects sent from this processor.
 
unsigned long long int buffersSent () const
 Gets the total number of buffers sent from this processor.
 
unsigned long long int poolParallelDataCreated () const
 Gets the total number of parallel data created in all of the threaded pools.
 
unsigned long long int localWorkStarted () const
 Gets the total amount of work started from this processor.
 
unsigned long long int localWorkExecuted () const
 Gets the total amount of work executed on this processor.
 
unsigned long long int totalWorkCompleted () const
 Gets the total amount of work completeed across all processors.
 
unsigned long long int localChunksExecuted () const
 Gets the total number of chunks of work executed on this processor.
 
bool currentlyExecuting () const
 Whether or not this object is currently in execute().
 
bool currentlyPreExecuting () const
 Whether or not this object is between preExecute() and execute().
 
unsigned int maxBufferSize () const
 Gets the max buffer size.
 
unsigned int chunkSize () const
 Gets the chunk size.
 
unsigned int clicksPerCommunication () const
 Gets the number of iterations to wait before communicating.
 
unsigned int clicksPerRootCommunication () const
 Gets the number of iterations to wait before communicating with root.
 
unsigned int clicksPerReceive () const
 Gets the number of iterations to wait before checking for new parallel data.
 
ParallelStudyMethod method () const
 Gets the method.
 
void reserveBuffer (const std::size_t size)
 Reserve size entries in the work buffer.
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
RayTracingStudyrayTracingStudy ()
 Get the RayTracingStudy associated with this ParallelRayStudy.
 
const RayTracingStudyrayTracingStudy () const
 
void moveWorkToBuffer (std::shared_ptr< Ray > &work, const THREAD_ID tid)
 Adds work to the buffer to be executed.
 
void moveWorkToBuffer (const work_iterator begin, const work_iterator end, const THREAD_ID tid)
 
void moveWorkToBuffer (std::vector< std::shared_ptr< Ray > > &work, const THREAD_ID tid)
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Types

enum  MoveWorkError
 Enum for providing useful errors during work addition in moveWorkError(). More...
 

Protected Member Functions

void executeWork (const std::shared_ptr< Ray > &ray, const THREAD_ID tid) override
 Pure virtual to be overridden that executes a single object of work on a given thread.
 
void moveWorkError (const MoveWorkError error, const std::shared_ptr< Ray > *ray) const override
 
void postReceiveParallelData (const parallel_data_iterator begin, const parallel_data_iterator end) override
 
bool workIsComplete (const std::shared_ptr< Ray > &ray) override
 Can be overridden to denote if a piece of work is not complete yet.
 
void postExecuteChunk (const work_iterator begin, const work_iterator end) override
 
virtual std::unique_ptr< MooseUtils::Buffer< std::shared_ptr< Ray > > > createWorkBuffer ()
 Creates the work buffer.
 
virtual void moveWorkError (const MoveWorkError error, const std::shared_ptr< Ray > *work=nullptr) const
 Virtual that allows for the customization of error text for moving work into the buffer.
 
virtual bool alternateSmartEndingCriteriaMet ()
 Insertion point for derived classes to provide an alternate ending criteria for SMART execution.
 
virtual void postExecuteChunk (const work_iterator, const work_iterator)
 Insertion point for acting on work that was just executed.
 
virtual void preReceiveAndExecute ()
 Insertion point called just after trying to receive work and just before beginning work on the work buffer.
 
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.
 
bool buffersAreEmpty () const
 Whether or not ALL of the buffers are empty: Working buffer, threaded buffers, receive buffer, and send buffers.
 
void moveContinuingWorkToBuffer (std::shared_ptr< Ray > &Work)
 Moves work that is considered continuing for the purposes of the execution algorithm into the buffer.
 
void moveContinuingWorkToBuffer (const work_iterator begin, const work_iterator end)
 

Protected Attributes

RayTracingStudy_ray_tracing_study
 The RayTracingStudy.
 
const std::vector< std::shared_ptr< TraceRay > > & _threaded_trace_ray
 The TraceRay objects that do the tracing for each thread.
 
const processor_id_type _pid
 This rank.
 
const std::string _name
 Name for this object for use in error handling.
 
const InputParameters_params
 The InputParameters.
 
const ParallelStudyMethod _method
 The study method.
 
bool _has_alternate_ending_criteria
 Whether or not this object has alternate ending criteria.
 
const Parallel::Communicator & _communicator
 

Private Member Functions

void flushSendBuffers ()
 Flushes all parallel data out of the send buffers.
 
void smartExecute ()
 Execute work using SMART.
 
void harmExecute ()
 Execute work using HARM.
 
void bsExecute ()
 Execute work using BS.
 
bool receiveAndExecute ()
 Receive packets of parallel data from other processors and executes work.
 
void executeAndBuffer (const std::size_t chunk_size)
 Execute a chunk of work and buffer.
 
void canMoveWorkCheck (const THREAD_ID tid)
 Internal check for if it is allowed to currently add work in moveWorkToBuffer().
 
void postReceiveParallelDataInternal ()
 Internal method for acting on the parallel data that has just been received into the parallel buffer.
 

Private Attributes

const unsigned int _min_buffer_size
 Minimum size of a SendBuffer.
 
const unsigned int _max_buffer_size
 Number of objects to buffer before communication.
 
const Real _buffer_growth_multiplier
 Multiplier for the buffer size for growing the buffer.
 
const Real _buffer_shrink_multiplier
 Multiplier for the buffer size for shrinking the buffer.
 
const unsigned int _chunk_size
 Number of objects to execute at once during communication.
 
const bool _allow_new_work_during_execution
 Whether or not to allow the addition of new work to the buffer during execution.
 
const unsigned int _clicks_per_communication
 Iterations to wait before communicating.
 
const unsigned int _clicks_per_root_communication
 Iterations to wait before communicating with root.
 
const unsigned int _clicks_per_receive
 Iterations to wait before checking for new objects.
 
Parallel::MessageTag _parallel_data_buffer_tag
 MessageTag for sending parallel data.
 
std::vector< MooseUtils::SharedPool< Ray > > _parallel_data_pools
 Pools for re-using destructed parallel data objects (one for each thread)
 
std::vector< std::vector< std::shared_ptr< Ray > > > _temp_threaded_work
 Threaded temprorary storage for work added while we're using the _work_buffer (one for each thread)
 
const std::unique_ptr< MooseUtils::Buffer< std::shared_ptr< Ray > > > _work_buffer
 Buffer for executing work.
 
const std::unique_ptr< ReceiveBuffer< Ray, ParallelStudy< std::shared_ptr< Ray >, Ray > > > _receive_buffer
 The receive buffer.
 
std::unordered_map< processor_id_type, std::unique_ptr< SendBuffer< Ray, ParallelStudy< std::shared_ptr< Ray >, Ray > > > > _send_buffers
 Send buffers for each processor.
 
unsigned long long int _local_chunks_executed
 Number of chunks of work executed on this processor.
 
unsigned long long int _local_work_completed
 Amount of work completed on this processor.
 
unsigned long long int _local_work_started
 Amount of work started on this processor.
 
unsigned long long int _local_work_executed
 Amount of work executed on this processor.
 
unsigned long long int _total_work_started
 Amount of work started on all processors.
 
unsigned long long int _total_work_completed
 Amount of work completed on all processors.
 
bool _currently_executing
 Whether we are within execute()
 
bool _currently_pre_executing
 Whether we are between preExecute() and execute()
 
bool _currently_executing_work
 Whether or not we are currently within executeAndBuffer()
 

Detailed Description

Definition at line 21 of file ParallelRayStudy.h.

Member Typedef Documentation

◆ parallel_data_iterator

typedef MooseUtils::Buffer<std::shared_ptr<Ray >>::iterator ParallelStudy< std::shared_ptr< Ray > , Ray >::parallel_data_iterator
inherited

Definition at line 34 of file ParallelStudy.h.

◆ work_iterator

typedef MooseUtils::Buffer<std::shared_ptr< Ray > >::iterator ParallelStudy< std::shared_ptr< Ray > , Ray >::work_iterator
inherited

Definition at line 32 of file ParallelStudy.h.

Member Enumeration Documentation

◆ MoveWorkError

enum ParallelStudy::MoveWorkError
protectedinherited

Constructor & Destructor Documentation

◆ ParallelRayStudy()

ParallelRayStudy::ParallelRayStudy ( RayTracingStudy study,
const std::vector< std::shared_ptr< TraceRay > > &  threaded_trace_ray 
)

Definition at line 16 of file ParallelRayStudy.C.

20 ray_tracing_study.comm(), ray_tracing_study.parameters(), "ParallelRayStudy"),
21 _ray_tracing_study(ray_tracing_study),
22 _threaded_trace_ray(threaded_trace_ray)
23{
24}
RayTracingStudy & _ray_tracing_study
The RayTracingStudy.
const std::vector< std::shared_ptr< TraceRay > > & _threaded_trace_ray
The TraceRay objects that do the tracing for each thread.
Basic datastructure for a ray that will traverse the mesh.
Definition Ray.h:58

Member Function Documentation

◆ acquireParallelData()

MooseUtils::SharedPool< Ray >::PtrType ParallelStudy< std::shared_ptr< Ray > , Ray >::acquireParallelData ( const THREAD_ID  tid,
Args &&...  args 
)
inlineinherited

Acquire a parallel data object from the pool.

Definition at line 73 of file ParallelStudy.h.

74 {
75 return _parallel_data_pools[tid].acquire(std::forward<Args>(args)...);
76 }
std::vector< MooseUtils::SharedPool< Ray > > _parallel_data_pools
Pools for re-using destructed parallel data objects (one for each thread)

◆ alternateSmartEndingCriteriaMet()

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::alternateSmartEndingCriteriaMet ( )
protectedvirtualinherited

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 212 of file ParallelStudy.h.

1203{
1204 mooseError(_name, ": Unimplemented alternateSmartEndingCriteriaMet()");
1205}
void mooseError(Args &&... args)
const std::string _name
Name for this object for use in error handling.

◆ bsExecute()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::bsExecute ( )
privateinherited

Execute work using BS.

Definition at line 288 of file ParallelStudy.h.

901{
903 mooseError("ParallelStudy: Alternate ending criteria not yet supported for BS");
905 mooseError(_name, ": The addition of new work during execution is not supported by BS");
906 mooseAssert(_method == ParallelStudyMethod::BS, "Should be called with BS only");
907
908 Parallel::Request work_completed_probe_status;
909 Parallel::Request work_completed_request;
910
911 // Temp for use in sending the current value in a nonblocking sum instead of an updated value
912 unsigned long long int temp;
913
914 // Get the amount of work that were started in the whole domain
915 comm().sum(_local_work_started, _total_work_started, work_completed_probe_status);
916
917 // Keep working until done
918 while (true)
919 {
920 bool receiving = false;
921 bool sending = false;
922
923 Parallel::Request some_left_request;
924 unsigned int some_left = 0;
925 unsigned int all_some_left = 1;
926
927 do
928 {
929 _receive_buffer->receive();
932
933 receiving = _receive_buffer->currentlyReceiving();
934
935 sending = false;
936 for (auto & send_buffer : _send_buffers)
937 sending = sending || send_buffer.second->currentlySending() ||
938 send_buffer.second->currentlyBuffered();
939
940 if (!receiving && !sending && some_left_request.test() && all_some_left)
941 {
942 some_left = receiving || sending;
943 comm().sum(some_left, all_some_left, some_left_request);
944 }
945 } while (receiving || sending || !some_left_request.test() || all_some_left);
946
948
949 comm().barrier();
950
951 if (work_completed_probe_status.test() && work_completed_request.test())
952 {
954 return;
955
957 comm().sum(temp, _total_work_completed, work_completed_request);
958 }
959 }
960}
const ParallelStudyMethod _method
The study method.
unsigned long long int _local_work_started
Amount of work started on this processor.
void executeAndBuffer(const std::size_t chunk_size)
Execute a chunk of work and buffer.
bool _has_alternate_ending_criteria
Whether or not this object has alternate ending criteria.
unsigned long long int _local_work_completed
Amount of work completed on this processor.
void postReceiveParallelDataInternal()
Internal method for acting on the parallel data that has just been received into the parallel buffer.
unsigned long long int _total_work_started
Amount of work started on all processors.
const bool _allow_new_work_during_execution
Whether or not to allow the addition of new work to the buffer during execution.
const std::unique_ptr< ReceiveBuffer< Ray, ParallelStudy< std::shared_ptr< Ray >, Ray > > > _receive_buffer
The receive buffer.
std::unordered_map< processor_id_type, std::unique_ptr< SendBuffer< Ray, ParallelStudy< std::shared_ptr< Ray >, Ray > > > > _send_buffers
Send buffers for each processor.
const std::unique_ptr< MooseUtils::Buffer< std::shared_ptr< Ray > > > _work_buffer
Buffer for executing work.
void flushSendBuffers()
Flushes all parallel data out of the send buffers.
unsigned long long int _total_work_completed
Amount of work completed on all processors.
const Parallel::Communicator & comm() const

◆ buffersAreEmpty()

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::buffersAreEmpty ( ) const
protectedinherited

Whether or not ALL of the buffers are empty: Working buffer, threaded buffers, receive buffer, and send buffers.

Definition at line 258 of file ParallelStudy.h.

1210{
1211 if (!_work_buffer->empty())
1212 return false;
1213 for (const auto & threaded_buffer : _temp_threaded_work)
1214 if (!threaded_buffer.empty())
1215 return false;
1216 if (_receive_buffer->currentlyReceiving())
1217 return false;
1218 for (const auto & map_pair : _send_buffers)
1219 if (map_pair.second->currentlySending() || map_pair.second->currentlyBuffered())
1220 return false;
1221
1222 return true;
1223}
std::vector< std::vector< std::shared_ptr< Ray > > > _temp_threaded_work
Threaded temprorary storage for work added while we're using the _work_buffer (one for each thread)
if(subdm)

◆ buffersSent()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::buffersSent ( ) const
inherited

Gets the total number of buffers sent from this processor.

Definition at line 109 of file ParallelStudy.h.

1179{
1180 unsigned long long int total_sent = 0;
1181
1182 for (const auto & buffer : _send_buffers)
1183 total_sent += buffer.second->buffersSent();
1184
1185 return total_sent;
1186}
unsigned long long int buffersSent() const
Gets the total number of buffers sent from this processor.

◆ canMoveWorkCheck()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::canMoveWorkCheck ( const THREAD_ID  tid)
privateinherited

Internal check for if it is allowed to currently add work in moveWorkToBuffer().

Definition at line 303 of file ParallelStudy.h.

1051{
1053 {
1055 moveWorkError(MoveWorkError::DURING_EXECUTION_DISABLED);
1056 }
1057 else if (!_currently_pre_executing)
1058 {
1060 moveWorkError(MoveWorkError::PRE_EXECUTION_AND_EXECUTION_ONLY);
1061 else
1062 moveWorkError(MoveWorkError::PRE_EXECUTION_ONLY);
1063 }
1064 else if (tid != 0)
1065 moveWorkError(MoveWorkError::PRE_EXECUTION_THREAD_0_ONLY);
1066}
bool _currently_executing
Whether we are within execute()
virtual void moveWorkError(const MoveWorkError error, const std::shared_ptr< Ray > *work=nullptr) const
Virtual that allows for the customization of error text for moving work into the buffer.
bool _currently_pre_executing
Whether we are between preExecute() and execute()

◆ chunkSize()

unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::chunkSize ( ) const
inlineinherited

Gets the chunk size.

Definition at line 148 of file ParallelStudy.h.

148{ return _chunk_size; }
const unsigned int _chunk_size
Number of objects to execute at once during communication.

◆ clicksPerCommunication()

unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::clicksPerCommunication ( ) const
inlineinherited

Gets the number of iterations to wait before communicating.

Definition at line 153 of file ParallelStudy.h.

const unsigned int _clicks_per_communication
Iterations to wait before communicating.

◆ clicksPerReceive()

unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::clicksPerReceive ( ) const
inlineinherited

Gets the number of iterations to wait before checking for new parallel data.

Definition at line 161 of file ParallelStudy.h.

161{ return _clicks_per_receive; }
const unsigned int _clicks_per_receive
Iterations to wait before checking for new objects.

◆ clicksPerRootCommunication()

unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::clicksPerRootCommunication ( ) const
inlineinherited

Gets the number of iterations to wait before communicating with root.

Definition at line 157 of file ParallelStudy.h.

const unsigned int _clicks_per_root_communication
Iterations to wait before communicating with root.

◆ createWorkBuffer()

std::unique_ptr< MooseUtils::Buffer< std::shared_ptr< Ray > > > ParallelStudy< std::shared_ptr< Ray > , Ray >::createWorkBuffer ( )
protectedvirtualinherited

Creates the work buffer.

This is virtual so that derived classes can use their own specialized buffers

Definition at line 196 of file ParallelStudy.h.

420{
421 std::unique_ptr<MooseUtils::Buffer<WorkType>> buffer;
422
423 const auto buffer_type = _params.get<MooseEnum>("work_buffer_type");
424 if (buffer_type == "lifo")
425 buffer = std::make_unique<MooseUtils::LIFOBuffer<WorkType>>();
426 else if (buffer_type == "circular")
427 buffer = std::make_unique<MooseUtils::CircularBuffer<WorkType>>();
428 else
429 mooseError("Unknown work buffer type");
430
431 return buffer;
432}
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const InputParameters & _params
The InputParameters.

◆ currentlyExecuting()

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::currentlyExecuting ( ) const
inlineinherited

Whether or not this object is currently in execute().

Definition at line 135 of file ParallelStudy.h.

135{ return _currently_executing; }

◆ currentlyPreExecuting()

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::currentlyPreExecuting ( ) const
inlineinherited

Whether or not this object is between preExecute() and execute().

Definition at line 139 of file ParallelStudy.h.

139{ return _currently_pre_executing; }

◆ execute()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::execute ( )
inherited

Execute method.

Definition at line 49 of file ParallelStudy.h.

989{
991 mooseError(_name, ": preExecute() was not called before execute()");
992
995
996 switch (_method)
997 {
999 smartExecute();
1000 break;
1002 harmExecute();
1003 break;
1005 bsExecute();
1006 break;
1007 default:
1008 mooseError("Unknown ParallelStudyMethod");
1009 }
1010
1011 _currently_executing = false;
1012
1013 // Sanity checks on if we're really done
1014 comm().barrier();
1015
1016 if (!buffersAreEmpty())
1017 mooseError(_name, ": Buffers are not empty after execution");
1018}
void harmExecute()
Execute work using HARM.
bool buffersAreEmpty() const
Whether or not ALL of the buffers are empty: Working buffer, threaded buffers, receive buffer,...
void smartExecute()
Execute work using SMART.

◆ executeAndBuffer()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::executeAndBuffer ( const std::size_t  chunk_size)
privateinherited

Execute a chunk of work and buffer.

Definition at line 298 of file ParallelStudy.h.

498{
500
501 // If chunk_size > the number of objects left, this will properly grab all of them
502 const auto begin = _work_buffer->beginChunk(chunk_size);
503 const auto end = _work_buffer->endChunk(chunk_size);
504
506
507#ifdef LIBMESH_HAVE_OPENMP
508#pragma omp parallel
509#endif
510 {
511 const THREAD_ID tid =
512#ifdef LIBMESH_HAVE_OPENMP
513 omp_get_thread_num();
514#else
515 0;
516#endif
517
518#ifdef LIBMESH_HAVE_OPENMP
519#pragma omp for schedule(dynamic, 20) nowait
520#endif
521 for (auto it = begin; it < end; ++it)
522 executeWork(*it, tid);
523 }
524
525 // Increment the executed and completed counters
526 _local_work_executed += std::distance(begin, end);
527 for (auto it = begin; it != end; ++it)
528 if (workIsComplete(*it))
530
531 // Insertion point for derived classes to do something to the completed work
532 // Example: Create ParallelData to spawn additional work on another processor
533 postExecuteChunk(begin, end);
534
535 // Remove the objects we just worked on from the buffer
536 _work_buffer->eraseChunk(chunk_size);
537
538 // If new work is allowed to be geneated during execution, it goes into _temp_threaded_work
539 // during the threaded execution phase and then must be moved into the working buffer
541 {
542 // Amount of work that needs to be moved into the main working buffer from
543 // the temporary working buffer
544 std::size_t threaded_work_size = 0;
545 for (const auto & work_objects : _temp_threaded_work)
546 threaded_work_size += work_objects.size();
547
548 if (threaded_work_size)
549 {
550 // We don't ever want to decrease the capacity, so only set it if we need more entries
551 if (_work_buffer->capacity() < _work_buffer->size() + threaded_work_size)
552 _work_buffer->setCapacity(_work_buffer->size() + threaded_work_size);
553
554 // Move the work into the buffer
555 for (auto & threaded_work_vector : _temp_threaded_work)
556 {
557 for (auto & work : threaded_work_vector)
558 _work_buffer->move(work);
559 threaded_work_vector.clear();
560 }
561
562 // Variable that must be set when adding work so that the algorithm can keep count
563 // of how much work still needs to be executed
564 _local_work_started += threaded_work_size;
565 }
566 }
567
570
572}
unsigned int THREAD_ID
bool _currently_executing_work
Whether or not we are currently within executeAndBuffer()
virtual bool workIsComplete(const std::shared_ptr< Ray > &)
Can be overridden to denote if a piece of work is not complete yet.
virtual void executeWork(const std::shared_ptr< Ray > &work, const THREAD_ID tid)=0
Pure virtual to be overridden that executes a single object of work on a given thread.
unsigned long long int _local_work_executed
Amount of work executed on this processor.
virtual void postExecuteChunk(const work_iterator, const work_iterator)
Insertion point for acting on work that was just executed.
unsigned long long int _local_chunks_executed
Number of chunks of work executed on this processor.

◆ executeWork()

void ParallelRayStudy::executeWork ( const std::shared_ptr< Ray > &  work,
const THREAD_ID  tid 
)
overrideprotectedvirtual

Pure virtual to be overridden that executes a single object of work on a given thread.

Implements ParallelStudy< std::shared_ptr< Ray >, Ray >.

Definition at line 64 of file ParallelRayStudy.C.

65{
66 mooseAssert(ray->shouldContinue(), "Tracing Ray that should not continue");
67
68 // If this is false, it means we have a Ray that is banked to go onto another processor
69 if (ray->currentElem()->processor_id() == _pid)
70 _threaded_trace_ray[tid]->trace(ray);
71}
const processor_id_type _pid
This rank.

◆ flushSendBuffers()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::flushSendBuffers ( )
privateinherited

Flushes all parallel data out of the send buffers.

Definition at line 275 of file ParallelStudy.h.

611{
612 for (auto & send_buffer_iter : _send_buffers)
613 send_buffer_iter.second->forceSend();
614}

◆ harmExecute()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::harmExecute ( )
privateinherited

Execute work using HARM.

Definition at line 284 of file ParallelStudy.h.

804{
806 mooseError("ParallelStudy: Alternate ending criteria not yet supported for HARM");
808 mooseError(_name, ": The addition of new work during execution is not supported by HARM");
809 mooseAssert(_method == ParallelStudyMethod::HARM, "Should be called with HARM only");
810
811 // Request for the total amount of work started
812 Parallel::Request work_started_request;
813 // Requests for sending the amount of finished worked to every other processor
814 std::vector<Parallel::Request> work_completed_requests(comm().size());
815 // Whether or not the finished requests have been sent to each processor
816 std::vector<bool> work_completed_requests_sent(comm().size(), false);
817 // Values of work completed on this processor that are being sent to other processors
818 std::vector<unsigned long long int> work_completed_requests_temps(comm().size(), 0);
819 // Work completed by each processor
820 std::vector<unsigned long long int> work_completed_per_proc(comm().size(), 0);
821 // Tag for sending work finished
822 const auto work_completed_requests_tag = comm().get_unique_tag();
823
824 // Get the amount of work that was started in the whole domain
825 comm().sum(_local_work_started, _total_work_started, work_started_request);
826
827 // All work has been executed, so time to communicate
829
830 // HARM only does some communication based on times through the loop.
831 // This counter will be used for that
832 unsigned int communication_clicks = 0;
833
834 Parallel::Status work_completed_probe_status;
835 int work_completed_probe_flag;
836
837 // Keep working until done
838 while (true)
839 {
841
843
844 if (communication_clicks > comm().size())
845 {
846 // Receive messages about work being finished
847 do
848 {
849 MPI_Iprobe(MPI_ANY_SOURCE,
850 work_completed_requests_tag.value(),
851 comm().get(),
852 &work_completed_probe_flag,
853 work_completed_probe_status.get());
854
855 if (work_completed_probe_flag)
856 {
857 auto proc = work_completed_probe_status.source();
858 comm().receive(proc, work_completed_per_proc[proc], work_completed_requests_tag);
859 }
860 } while (work_completed_probe_flag);
861
862 _total_work_completed = std::accumulate(
863 work_completed_per_proc.begin(), work_completed_per_proc.end(), _local_work_completed);
864
865 // Reset
866 communication_clicks = 0;
867 }
868
869 // Send messages about objects being finished
870 for (processor_id_type pid = 0; pid < comm().size(); ++pid)
871 if (pid != _pid &&
872 (!work_completed_requests_sent[pid] || work_completed_requests[pid].test()) &&
873 _local_work_completed > work_completed_requests_temps[pid])
874 {
875 work_completed_requests_temps[pid] = _local_work_completed;
876 comm().send(pid,
877 work_completed_requests_temps[pid],
878 work_completed_requests[pid],
879 work_completed_requests_tag);
880 work_completed_requests_sent[pid] = true;
881 }
882
883 // All procs agree on the amount of work started and we've finished all the work started
884 if (work_started_request.test() && _total_work_started == _total_work_completed)
885 {
886 // Need to call the post wait work for all of the requests
887 for (processor_id_type pid = 0; pid < comm().size(); ++pid)
888 if (pid != _pid)
889 work_completed_requests[pid].wait();
890
891 return;
892 }
893
894 communication_clicks++;
895 }
896}
bool receiveAndExecute()
Receive packets of parallel data from other processors and executes work.
processor_id_type size() const
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ localChunksExecuted()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::localChunksExecuted ( ) const
inlineinherited

Gets the total number of chunks of work executed on this processor.

Definition at line 130 of file ParallelStudy.h.

130{ return _local_chunks_executed; }

◆ localWorkExecuted()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::localWorkExecuted ( ) const
inlineinherited

Gets the total amount of work executed on this processor.

Definition at line 122 of file ParallelStudy.h.

122{ return _local_work_executed; }

◆ localWorkStarted()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::localWorkStarted ( ) const
inlineinherited

Gets the total amount of work started from this processor.

Definition at line 118 of file ParallelStudy.h.

118{ return _local_work_started; }

◆ maxBufferSize()

unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::maxBufferSize ( ) const
inlineinherited

Gets the max buffer size.

Definition at line 144 of file ParallelStudy.h.

144{ return _max_buffer_size; }
const unsigned int _max_buffer_size
Number of objects to buffer before communication.

◆ method()

ParallelStudyMethod ParallelStudy< std::shared_ptr< Ray > , Ray >::method ( ) const
inlineinherited

Gets the method.

Definition at line 166 of file ParallelStudy.h.

166{ return _method; }

◆ moveContinuingWorkToBuffer() [1/2]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveContinuingWorkToBuffer ( const work_iterator  begin,
const work_iterator  end 
)
protectedinherited

Definition at line 251 of file ParallelStudy.h.

1140{
1142 moveWorkError(MoveWorkError::CONTINUING_DURING_EXECUTING_WORK);
1143
1144 const auto size = std::distance(begin, end);
1145 if (_work_buffer->capacity() < _work_buffer->size() + size)
1146 _work_buffer->setCapacity(_work_buffer->size() + size);
1147
1148 for (auto it = begin; it != end; ++it)
1149 _work_buffer->move(*it);
1150}

◆ moveContinuingWorkToBuffer() [2/2]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveContinuingWorkToBuffer ( std::shared_ptr< Ray > &  Work)
protectedinherited

Moves work that is considered continuing for the purposes of the execution algorithm into the buffer.

Definition at line 250 of file ParallelStudy.h.

1129{
1131 moveWorkError(MoveWorkError::CONTINUING_DURING_EXECUTING_WORK);
1132
1133 _work_buffer->move(work);
1134}

◆ moveParallelDataToBuffer()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveParallelDataToBuffer ( std::shared_ptr< Ray > &  data,
const processor_id_type  dest_pid 
)
inherited

Moves parallel data objects to the send buffer to be communicated to processor dest_pid.

Definition at line 81 of file ParallelStudy.h.

578{
579 mooseAssert(comm().size() > dest_pid, "Invalid processor ID");
580 mooseAssert(_pid != dest_pid, "Processor ID is self");
581
583 mooseError(_name, ": Cannot sendParallelData() when not executing");
584
585 // Get the send buffer for the proc this object is going to
586 auto find_pair = _send_buffers.find(dest_pid);
587 // Need to create a send buffer for said processor
588 if (find_pair == _send_buffers.end())
590 .emplace(dest_pid,
591 std::make_unique<
593 comm(),
594 this,
595 dest_pid,
596 _method,
602 .first->second->moveObject(data);
603 // Send buffer exists for this processor
604 else
605 find_pair->second->moveObject(data);
606}
const Real _buffer_growth_multiplier
Multiplier for the buffer size for growing the buffer.
const unsigned int _min_buffer_size
Minimum size of a SendBuffer.
const Real _buffer_shrink_multiplier
Multiplier for the buffer size for shrinking the buffer.
Parallel::MessageTag _parallel_data_buffer_tag
MessageTag for sending parallel data.

◆ moveWorkError() [1/2]

void ParallelRayStudy::moveWorkError ( const MoveWorkError  error,
const std::shared_ptr< Ray > *  ray 
) const
overrideprotected

Definition at line 74 of file ParallelRayStudy.C.

75{
76 std::stringstream oss;
77 oss << "In method " << _ray_tracing_study.type() << "::addRay(s)ToBuffer:\n";
78
79 if (error == MoveWorkError::DURING_EXECUTION_DISABLED)
80 {
81 oss << "Rays are being added to the buffer during propagation.\n\n";
82 oss << "This capability must be enabled by setting the parameter\n";
83 oss << "'allow_new_work_during_execution' to true.";
84 }
85 else if (error == MoveWorkError::PRE_EXECUTION_AND_EXECUTION_ONLY)
86 oss << "Rays can only be added to the buffer during generateRays() and tracing.";
87 else if (error == MoveWorkError::PRE_EXECUTION_ONLY)
88 oss << "Rays can only be added to the buffer during generateRays().";
89 else if (error == MoveWorkError::PRE_EXECUTION_THREAD_0_ONLY)
90 oss << "Rays can only be added on thread 0 during generateRays() (not thread safe)";
91 else if (error == CONTINUING_DURING_EXECUTING_WORK)
93
94 if (ray)
95 oss << "\n\n" << (*ray)->getInfo();
96
97 mooseError(oss.str());
98}
const std::string & type() const
void moveWorkError(const MoveWorkError error, const std::shared_ptr< Ray > *ray) const override

Referenced by moveWorkError().

◆ moveWorkError() [2/2]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveWorkError ( const MoveWorkError  error,
const std::shared_ptr< Ray > *  work = nullptr 
) const
protectedvirtualinherited

Virtual that allows for the customization of error text for moving work into the buffer.

Definition at line 206 of file ParallelStudy.h.

1024{
1025 if (error == MoveWorkError::DURING_EXECUTION_DISABLED)
1027 ": The moving of new work into the buffer during work execution requires\n",
1028 "that the parameter 'allow_new_work_during_execution = true'");
1029 if (error == MoveWorkError::PRE_EXECUTION_AND_EXECUTION_ONLY)
1030 mooseError(
1031 _name,
1032 ": Can only move work into the buffer in the pre-execution and execution phase\n(between "
1033 "preExecute() and the end of execute()");
1034 if (error == MoveWorkError::PRE_EXECUTION_ONLY)
1036 ": Can only move work into the buffer in the pre-execution phase\n(between "
1037 "preExecute() and execute()");
1038 if (error == MoveWorkError::PRE_EXECUTION_THREAD_0_ONLY)
1040 ": Can only move work into the buffer in the pre-execution phase\n(between "
1041 "preExecute() and execute()) on thread 0");
1043 mooseError(_name, ": Cannot move continuing work into the buffer during executeAndBuffer()");
1044
1045 mooseError("Unknown MoveWorkError");
1046}

◆ moveWorkToBuffer() [1/3]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveWorkToBuffer ( const work_iterator  begin,
const work_iterator  end,
const THREAD_ID  tid 
)
inherited

Definition at line 64 of file ParallelStudy.h.

1092{
1093 // Error checks for moving work into the buffer at unallowed times
1094 canMoveWorkCheck(tid);
1095
1096 // Get work size beforehand so we can resize
1097 const auto size = std::distance(begin, end);
1098
1099 // Can move directly into the work buffer on thread 0 when we're not executing work
1100 if (!_currently_executing_work && tid == 0)
1101 {
1102 if (_work_buffer->capacity() < _work_buffer->size() + size)
1103 _work_buffer->setCapacity(_work_buffer->size() + size);
1104 _local_work_started += size;
1105 }
1106 else
1107 _temp_threaded_work[tid].reserve(_temp_threaded_work[tid].size() + size);
1108
1109 // Move the objects
1110 if (!_currently_executing_work && tid == 0)
1111 for (auto it = begin; it != end; ++it)
1112 _work_buffer->move(*it);
1113 else
1114 for (auto it = begin; it != end; ++it)
1115 _temp_threaded_work[tid].emplace_back(std::move(*it));
1116}
void canMoveWorkCheck(const THREAD_ID tid)
Internal check for if it is allowed to currently add work in moveWorkToBuffer().

◆ moveWorkToBuffer() [2/3]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveWorkToBuffer ( std::shared_ptr< Ray > &  work,
const THREAD_ID  tid 
)
inherited

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 63 of file ParallelStudy.h.

1071{
1072 // Error checks for moving work into the buffer at unallowed times
1073 canMoveWorkCheck(tid);
1074
1075 // Can move directly into the work buffer on thread 0 when we're not executing work
1076 if (!_currently_executing_work && tid == 0)
1077 {
1078 ++_local_work_started; // must ALWAYS increment when adding new work to the working buffer
1079 _work_buffer->move(work);
1080 }
1081 // Objects added during execution go into a temporary threaded vector (is thread safe) to be
1082 // moved into the working buffer when possible
1083 else
1084 _temp_threaded_work[tid].emplace_back(std::move(work));
1085}

◆ moveWorkToBuffer() [3/3]

void ParallelStudy< std::shared_ptr< Ray > , Ray >::moveWorkToBuffer ( std::vector< std::shared_ptr< Ray > > &  work,
const THREAD_ID  tid 
)
inherited

Definition at line 65 of file ParallelStudy.h.

1122{
1123 moveWorkToBuffer(work_vector.begin(), work_vector.end(), tid);
1124}
void moveWorkToBuffer(std::shared_ptr< Ray > &work, const THREAD_ID tid)
Adds work to the buffer to be executed.

◆ parallelDataSent()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::parallelDataSent ( ) const
inherited

Gets the total number of parallel data objects sent from this processor.

Definition at line 105 of file ParallelStudy.h.

1167{
1168 unsigned long long int total_sent = 0;
1169
1170 for (const auto & buffer : _send_buffers)
1171 total_sent += buffer.second->objectsSent();
1172
1173 return total_sent;
1174}

◆ poolParallelDataCreated()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::poolParallelDataCreated ( ) const
inherited

Gets the total number of parallel data created in all of the threaded pools.

Definition at line 113 of file ParallelStudy.h.

1191{
1192 unsigned long long int num_created = 0;
1193
1194 for (const auto & pool : _parallel_data_pools)
1195 num_created += pool.num_created();
1196
1197 return num_created;
1198}

◆ postExecuteChunk() [1/2]

void ParallelRayStudy::postExecuteChunk ( const work_iterator  begin,
const work_iterator  end 
)
overrideprotected

Definition at line 27 of file ParallelRayStudy.C.

28{
29 for (auto it = begin; it != end; ++it)
30 {
31 std::shared_ptr<Ray> & ray = *it;
32
33 // The Ray is done tracing
34 if (!ray->shouldContinue())
35 {
37 continue;
38 }
39
40 // Going to another processor
41 mooseAssert(ray->currentElem()->processor_id() != _pid,
42 "Continuing Ray not going to another processor");
43 moveParallelDataToBuffer(ray, ray->currentElem()->processor_id());
44 }
45}
void moveParallelDataToBuffer(std::shared_ptr< Ray > &data, const processor_id_type dest_pid)
Moves parallel data objects to the send buffer to be communicated to processor dest_pid.
virtual void onCompleteRay(const std::shared_ptr< Ray > &ray)
Entry point for acting on a ray when it is completed (shouldContinue() == false)

◆ postExecuteChunk() [2/2]

virtual void ParallelStudy< std::shared_ptr< Ray > , Ray >::postExecuteChunk ( const work_iterator  ,
const work_iterator   
)
inlineprotectedvirtualinherited

Insertion point for acting on work that was just executed.

This is not called in threads.

Definition at line 219 of file ParallelStudy.h.

219{}

◆ postReceiveParallelData() [1/2]

void ParallelRayStudy::postReceiveParallelData ( const parallel_data_iterator  begin,
const parallel_data_iterator  end 
)
overrideprotected

Definition at line 55 of file ParallelRayStudy.C.

57{
58 // Move all of the parallel data (Rays that are continuing to be traced on this processor)
59 // directly into the work buffer
61}
void moveContinuingWorkToBuffer(std::shared_ptr< Ray > &Work)
Moves work that is considered continuing for the purposes of the execution algorithm into the buffer.

◆ postReceiveParallelData() [2/2]

virtual void ParallelStudy< std::shared_ptr< Ray > , Ray >::postReceiveParallelData ( const parallel_data_iterator  begin,
const parallel_data_iterator  end 
)
protectedpure virtualinherited

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.

◆ postReceiveParallelDataInternal()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::postReceiveParallelDataInternal ( )
privateinherited

Internal method for acting on the parallel data that has just been received into the parallel buffer.

Definition at line 309 of file ParallelStudy.h.

631{
632 if (_receive_buffer->buffer().empty())
633 return;
634
635 // Let derived classes work on the data and then clear it after
636 postReceiveParallelData(_receive_buffer->buffer().begin(), _receive_buffer->buffer().end());
637 for (auto & data : _receive_buffer->buffer())
638 if (data)
639 data.reset();
640
641 _receive_buffer->buffer().clear();
642}
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.
auto reset(int, T &obj, Args... args) -> decltype(obj.reset(args...), void())

◆ preExecute()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::preExecute ( )
inherited

Pre-execute method that MUST be called before execute() and before adding work.

Definition at line 45 of file ParallelStudy.h.

965{
966 if (!buffersAreEmpty())
967 mooseError(_name, ": Buffers are not empty in preExecute()");
968
969 // Clear communication buffers
970 for (auto & send_buffer_pair : _send_buffers)
971 send_buffer_pair.second->clear();
972 _send_buffers.clear();
973 _receive_buffer->clear();
974
975 // Clear counters
982
984}
sideset clear()

◆ preReceiveAndExecute()

virtual void ParallelStudy< std::shared_ptr< Ray > , Ray >::preReceiveAndExecute ( )
inlineprotectedvirtualinherited

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.

225{}

◆ rayTracingStudy() [1/2]

RayTracingStudy & ParallelRayStudy::rayTracingStudy ( )
inline

Get the RayTracingStudy associated with this ParallelRayStudy.

Definition at line 31 of file ParallelRayStudy.h.

31{ return _ray_tracing_study; }

◆ rayTracingStudy() [2/2]

const RayTracingStudy & ParallelRayStudy::rayTracingStudy ( ) const
inline

Definition at line 32 of file ParallelRayStudy.h.

32{ return _ray_tracing_study; }

◆ receiveAndExecute()

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::receiveAndExecute ( )
privateinherited

Receive packets of parallel data from other processors and executes work.

Definition at line 293 of file ParallelStudy.h.

647{
648 bool executed_some = false;
649
650 if (_receive_buffer->currentlyReceiving() && _method == ParallelStudyMethod::SMART)
651 _receive_buffer->cleanupRequests();
652 else
653 _receive_buffer->receive();
654
656
658
659 while (!_work_buffer->empty())
660 {
661 executed_some = true;
662
663 // Switch between tracing a chunk and buffering with SMART
665 {
666 // Look for extra work first so that these transfers can be finishing while we're executing
667 // Start receives only if our work buffer is decently sized
668 const bool start_receives_only = _work_buffer->size() > (2 * _chunk_size);
669 _receive_buffer->receive(_work_buffer->size() > (2 * _chunk_size));
670 if (!start_receives_only)
672
673 // Execute some objects
675 }
676 // Execute all of them and then buffer with the other methods
677 else
679 }
680
681 return executed_some;
682}
virtual void preReceiveAndExecute()
Insertion point called just after trying to receive work and just before beginning work on the work b...

◆ receiveBuffer()

const ReceiveBuffer< Ray , ParallelStudy< std::shared_ptr< Ray > , Ray > > & ParallelStudy< std::shared_ptr< Ray > , Ray >::receiveBuffer ( ) const
inlineinherited

Gets the receive buffer.

Definition at line 88 of file ParallelStudy.h.

89 {
90 return *_receive_buffer;
91 }

◆ reserveBuffer()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::reserveBuffer ( const std::size_t  size)
inherited

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 176 of file ParallelStudy.h.

619{
621 mooseError(_name, ": Can only reserve in object buffer during pre-execution");
622
623 // We don't ever want to decrease the capacity, so only set if we need more entries
624 if (_work_buffer->capacity() < size)
625 _work_buffer->setCapacity(size);
626}

◆ sendBufferPoolCreated()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::sendBufferPoolCreated ( ) const
inherited

Gets the total number of send buffer pools created.

Definition at line 101 of file ParallelStudy.h.

1155{
1156 unsigned long long int total = 0;
1157
1158 for (const auto & buffer : _send_buffers)
1159 total += buffer.second->bufferPoolCreated();
1160
1161 return total;
1162}

◆ smartExecute()

void ParallelStudy< std::shared_ptr< Ray > , Ray >::smartExecute ( )
privateinherited

Execute work using SMART.

Definition at line 280 of file ParallelStudy.h.

687{
688 mooseAssert(_method == ParallelStudyMethod::SMART, "Should be called with SMART only");
689
690 // Request for the sum of the started work
691 Parallel::Request started_request;
692 // Request for the sum of the completed work
693 Parallel::Request completed_request;
694
695 // Temp for use in sending the current value in a nonblocking sum instead of an updated value
696 unsigned long long int temp;
697
698 // Whether or not to make the started request first, or after every finished request.
699 // When allowing adding new work during the execution phase, the starting object counts could
700 // change after right now, so we must update them after each finished request is complete.
701 // When not allowing generation during propagation, we know the counts up front.
702 const bool started_request_first = !_allow_new_work_during_execution;
703
704 // Get the amount of work that was started in the whole domain, if applicable
705 if (started_request_first)
706 comm().sum(_local_work_started, _total_work_started, started_request);
707
708 // Whether or not the started request has been made
709 bool made_started_request = started_request_first;
710 // Whether or not the completed request has been made
711 bool made_completed_request = false;
712
713 // Good time to get rid of whatever's currently in our SendBuffers
715
716 // Use these to try to delay some forced communication
717 unsigned int non_executing_clicks = 0;
718 unsigned int non_executing_root_clicks = 0;
719 bool executed_some = true;
720
721 // Keep executing work until it has all completed
722 while (true)
723 {
724 executed_some = receiveAndExecute();
725
726 if (executed_some)
727 {
728 non_executing_clicks = 0;
729 non_executing_root_clicks = 0;
730 }
731 else
732 {
733 non_executing_clicks++;
734 non_executing_root_clicks++;
735 }
736
737 if (non_executing_clicks >= _clicks_per_communication)
738 {
739 non_executing_clicks = 0;
740
742 }
743
745 {
747 {
748 comm().barrier();
749 return;
750 }
751 }
752 else if (non_executing_root_clicks >= _clicks_per_root_communication)
753 {
754 non_executing_root_clicks = 0;
755
756 // We need the starting work sum first but said request isn't complete yet
757 if (started_request_first && !started_request.test())
758 continue;
759
760 // At this point, we need to make a request for the completed work sum
761 if (!made_completed_request)
762 {
763 made_completed_request = true;
765 comm().sum(temp, _total_work_completed, completed_request);
766 continue;
767 }
768
769 // We have the completed work sum
770 if (completed_request.test())
771 {
772 // The starting work sum must be requested /after/ we have finishing counts and we
773 // need to make the request for said sum
774 if (!made_started_request)
775 {
776 made_started_request = true;
777 temp = _local_work_started;
778 comm().sum(temp, _total_work_started, started_request);
779 continue;
780 }
781
782 // The starting work sum must be requested /after/ we have finishing sum and we
783 // don't have the starting sum yet
784 if (!started_request_first && !started_request.test())
785 continue;
786
787 // Started count is the same as the finished count - we're done!
789 return;
790
791 // Next time around we should make a completed sum request
792 made_completed_request = false;
793 // If we need the starting work sum after the completed work sum, we need those now as well
794 if (!started_request_first)
795 made_started_request = false;
796 }
797 }
798 }
799}
virtual bool alternateSmartEndingCriteriaMet()
Insertion point for derived classes to provide an alternate ending criteria for SMART execution.

◆ totalWorkCompleted()

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::totalWorkCompleted ( ) const
inlineinherited

Gets the total amount of work completeed across all processors.

Definition at line 126 of file ParallelStudy.h.

126{ return _total_work_completed; }

◆ validParams()

InputParameters ParallelStudy< std::shared_ptr< Ray > , Ray >::validParams ( )
staticinherited

Definition at line 36 of file ParallelStudy.h.

437{
438 auto params = emptyInputParameters();
439
440 params.addRangeCheckedParam<unsigned int>(
441 "send_buffer_size", 100, "send_buffer_size > 0", "The size of the send buffer");
442 params.addRangeCheckedParam<unsigned int>(
443 "chunk_size",
444 100,
445 "chunk_size > 0",
446 "The number of objects to process at one time during execution");
447 params.addRangeCheckedParam<unsigned int>("clicks_per_communication",
448 10,
449 "clicks_per_communication >= 0",
450 "Iterations to wait before communicating");
451 params.addRangeCheckedParam<unsigned int>("clicks_per_root_communication",
452 10,
453 "clicks_per_root_communication > 0",
454 "Iterations to wait before communicating with root");
455 params.addRangeCheckedParam<unsigned int>("clicks_per_receive",
456 1,
457 "clicks_per_receive > 0",
458 "Iterations to wait before checking for new objects");
459
460 params.addParam<unsigned int>("min_buffer_size",
461 "The initial size of the SendBuffer and the floor for shrinking "
462 "it. This defaults to send_buffer_size if not set (i.e. the "
463 "buffer won't change size)");
464 params.addParam<Real>("buffer_growth_multiplier",
465 2.,
466 "How much to grow a SendBuffer by if the buffer completely fills and "
467 "dumps. Will max at send_buffer_size");
468 params.addRangeCheckedParam<Real>("buffer_shrink_multiplier",
469 0.5,
470 "0 < buffer_shrink_multiplier <= 1.0",
471 "Multiplier (between 0 and 1) to apply to the current buffer "
472 "size if it is force dumped. Will stop at "
473 "min_buffer_size.");
474
475 params.addParam<bool>(
476 "allow_new_work_during_execution",
477 true,
478 "Whether or not to allow the addition of new work to the work buffer during execution");
479
480 MooseEnum methods("smart harm bs", "smart");
481 params.addParam<MooseEnum>("method", methods, "The algorithm to use");
482
483 MooseEnum work_buffers("lifo circular", "circular");
484 params.addParam<MooseEnum>("work_buffer_type", work_buffers, "The work buffer type to use");
485
486 params.addParamNamesToGroup(
487 "send_buffer_size chunk_size clicks_per_communication clicks_per_root_communication "
488 "clicks_per_receive min_buffer_size buffer_growth_multiplier buffer_shrink_multiplier method "
489 "work_buffer_type allow_new_work_during_execution",
490 "Advanced");
491
492 return params;
493}
InputParameters emptyInputParameters()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ workBuffer()

const MooseUtils::Buffer< std::shared_ptr< Ray > > & ParallelStudy< std::shared_ptr< Ray > , Ray >::workBuffer ( ) const
inlineinherited

Gets the work buffer.

Definition at line 96 of file ParallelStudy.h.

96{ return *_work_buffer; }

◆ workIsComplete()

bool ParallelRayStudy::workIsComplete ( const std::shared_ptr< Ray > &  )
overrideprotectedvirtual

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 from ParallelStudy< std::shared_ptr< Ray >, Ray >.

Definition at line 48 of file ParallelRayStudy.C.

49{
50 // "Work" (a Ray) is considered complete in the parallel algorithm when it is done tracing
51 return !ray->shouldContinue();
52}

Member Data Documentation

◆ _allow_new_work_during_execution

const bool ParallelStudy< std::shared_ptr< Ray > , Ray >::_allow_new_work_during_execution
privateinherited

Whether or not to allow the addition of new work to the buffer during execution.

Definition at line 322 of file ParallelStudy.h.

◆ _buffer_growth_multiplier

const Real ParallelStudy< std::shared_ptr< Ray > , Ray >::_buffer_growth_multiplier
privateinherited

Multiplier for the buffer size for growing the buffer.

Definition at line 316 of file ParallelStudy.h.

◆ _buffer_shrink_multiplier

const Real ParallelStudy< std::shared_ptr< Ray > , Ray >::_buffer_shrink_multiplier
privateinherited

Multiplier for the buffer size for shrinking the buffer.

Definition at line 318 of file ParallelStudy.h.

◆ _chunk_size

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_chunk_size
privateinherited

Number of objects to execute at once during communication.

Definition at line 320 of file ParallelStudy.h.

◆ _clicks_per_communication

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_clicks_per_communication
privateinherited

Iterations to wait before communicating.

Definition at line 325 of file ParallelStudy.h.

◆ _clicks_per_receive

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_clicks_per_receive
privateinherited

Iterations to wait before checking for new objects.

Definition at line 329 of file ParallelStudy.h.

◆ _clicks_per_root_communication

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_clicks_per_root_communication
privateinherited

Iterations to wait before communicating with root.

Definition at line 327 of file ParallelStudy.h.

◆ _currently_executing

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::_currently_executing
privateinherited

Whether we are within execute()

Definition at line 362 of file ParallelStudy.h.

◆ _currently_executing_work

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::_currently_executing_work
privateinherited

Whether or not we are currently within executeAndBuffer()

Definition at line 366 of file ParallelStudy.h.

◆ _currently_pre_executing

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::_currently_pre_executing
privateinherited

Whether we are between preExecute() and execute()

Definition at line 364 of file ParallelStudy.h.

◆ _has_alternate_ending_criteria

bool ParallelStudy< std::shared_ptr< Ray > , Ray >::_has_alternate_ending_criteria
protectedinherited

Whether or not this object has alternate ending criteria.

Definition at line 269 of file ParallelStudy.h.

◆ _local_chunks_executed

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_local_chunks_executed
privateinherited

Number of chunks of work executed on this processor.

Definition at line 349 of file ParallelStudy.h.

◆ _local_work_completed

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_local_work_completed
privateinherited

Amount of work completed on this processor.

Definition at line 351 of file ParallelStudy.h.

◆ _local_work_executed

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_local_work_executed
privateinherited

Amount of work executed on this processor.

Definition at line 355 of file ParallelStudy.h.

◆ _local_work_started

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_local_work_started
privateinherited

Amount of work started on this processor.

Definition at line 353 of file ParallelStudy.h.

◆ _max_buffer_size

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_max_buffer_size
privateinherited

Number of objects to buffer before communication.

Definition at line 314 of file ParallelStudy.h.

◆ _method

const ParallelStudyMethod ParallelStudy< std::shared_ptr< Ray > , Ray >::_method
protectedinherited

The study method.

Definition at line 267 of file ParallelStudy.h.

◆ _min_buffer_size

const unsigned int ParallelStudy< std::shared_ptr< Ray > , Ray >::_min_buffer_size
privateinherited

Minimum size of a SendBuffer.

Definition at line 312 of file ParallelStudy.h.

◆ _name

const std::string ParallelStudy< std::shared_ptr< Ray > , Ray >::_name
protectedinherited

Name for this object for use in error handling.

Definition at line 263 of file ParallelStudy.h.

◆ _parallel_data_buffer_tag

Parallel::MessageTag ParallelStudy< std::shared_ptr< Ray > , Ray >::_parallel_data_buffer_tag
privateinherited

MessageTag for sending parallel data.

Definition at line 332 of file ParallelStudy.h.

◆ _parallel_data_pools

std::vector<MooseUtils::SharedPool<Ray > > ParallelStudy< std::shared_ptr< Ray > , Ray >::_parallel_data_pools
privateinherited

Pools for re-using destructed parallel data objects (one for each thread)

Definition at line 334 of file ParallelStudy.h.

◆ _params

const InputParameters& ParallelStudy< std::shared_ptr< Ray > , Ray >::_params
protectedinherited

The InputParameters.

Definition at line 265 of file ParallelStudy.h.

◆ _pid

const processor_id_type ParallelStudy< std::shared_ptr< Ray > , Ray >::_pid
protectedinherited

This rank.

Definition at line 261 of file ParallelStudy.h.

◆ _ray_tracing_study

RayTracingStudy& ParallelRayStudy::_ray_tracing_study
protected

◆ _receive_buffer

const std::unique_ptr<ReceiveBuffer<Ray , ParallelStudy<std::shared_ptr< Ray > , Ray > > > ParallelStudy< std::shared_ptr< Ray > , Ray >::_receive_buffer
privateinherited

The receive buffer.

Definition at line 341 of file ParallelStudy.h.

◆ _send_buffers

std::unordered_map< processor_id_type, std::unique_ptr<SendBuffer<Ray , ParallelStudy<std::shared_ptr< Ray > , Ray > > > > ParallelStudy< std::shared_ptr< Ray > , Ray >::_send_buffers
privateinherited

Send buffers for each processor.

Definition at line 346 of file ParallelStudy.h.

◆ _temp_threaded_work

std::vector<std::vector<std::shared_ptr< Ray > > > ParallelStudy< std::shared_ptr< Ray > , Ray >::_temp_threaded_work
privateinherited

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.

◆ _threaded_trace_ray

const std::vector<std::shared_ptr<TraceRay> >& ParallelRayStudy::_threaded_trace_ray
protected

The TraceRay objects that do the tracing for each thread.

Definition at line 46 of file ParallelRayStudy.h.

Referenced by executeWork().

◆ _total_work_completed

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_total_work_completed
privateinherited

Amount of work completed on all processors.

Definition at line 359 of file ParallelStudy.h.

◆ _total_work_started

unsigned long long int ParallelStudy< std::shared_ptr< Ray > , Ray >::_total_work_started
privateinherited

Amount of work started on all processors.

Definition at line 357 of file ParallelStudy.h.

◆ _work_buffer

const std::unique_ptr<MooseUtils::Buffer<std::shared_ptr< Ray > > > ParallelStudy< std::shared_ptr< Ray > , Ray >::_work_buffer
privateinherited

Buffer for executing work.

Definition at line 338 of file ParallelStudy.h.


The documentation for this class was generated from the following files: