The SKIRT project
advanced radiative transfer for astrophysics
MultiHybridParallel Class Reference

#include <MultiHybridParallel.hpp>

Inheritance diagram for MultiHybridParallel:

Public Member Functions

 ~MultiHybridParallel ()
void call (size_t maxIndex, std::function< void(size_t firstIndex, size_t numIndices)> target) override
Public Member Functions inherited from Parallel
virtual ~Parallel ()

Private Member Functions

 MultiHybridParallel (int threadCount)
bool doSomeWork () override

Private Attributes

ChunkMaker _chunkMaker
std::condition_variable _conditionChildren
std::condition_variable _conditionParent
bool _done
size_t _firstIndex
std::mutex _mutex
size_t _numIndices
bool _ready
int _requests
std::function< void(size_t, size_t)> _target

Friends

class ParallelFactory

Additional Inherited Members

Protected Member Functions inherited from MultiParallel
void activateThreads ()
void constructThreads (int numThreads)
void destroyThreads ()
int numThreads ()
void waitForThreads ()
Protected Member Functions inherited from Parallel
 Parallel ()

Detailed Description

This class implements the Parallel base class interface using multiple threads in each of multiple processes. In each process, the actual work is performed in child threads created for that purpose, while the parent thread is used for communication among the processes (the MPI functions should be called only from the main thread). In the root process, the parent thread serves chunks of work to the other processes. In the non-root processes, the parent thread requests chunks from the root process for all of the local parallel threads. The extra thread in each process is not counted towards the number of threads specified by the user because the communication does not consume significant resources.

This class uses the facilities offered by the MultiParallel base class.

Constructor & Destructor Documentation

◆ MultiHybridParallel()

MultiHybridParallel::MultiHybridParallel ( int threadCount)
explicitprivate

Constructs a HybridParallel instance using the specified number of execution threads. The number of processes is retrieved from the ProcessManager. In each process, the specified number of child threads is created (and put on hold) so that the parent thread can be used to communicate with the other processes. This constructor is private; use the ParallelFactory::parallel() function instead.

◆ ~MultiHybridParallel()

MultiHybridParallel::~MultiHybridParallel ( )

Destructs the instance and its parallel child threads.

Member Function Documentation

◆ call()

void MultiHybridParallel::call ( size_t maxIndex,
std::function< void(size_t firstIndex, size_t numIndices)> target )
overridevirtual

This function implements the call() interface described in the Parallel base class for the parallelization scheme offered by this subclass.

Implements Parallel.

◆ doSomeWork()

bool MultiHybridParallel::doSomeWork ( )
overrideprivatevirtual

The function to do the actual work, one chunk at a time.

Implements MultiParallel.


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