Go to the documentation of this file.
16 #ifndef POMEROL_INCLUDE_MPI_DISPATCHER_MPI_DISPATCHER_HPP
17 #define POMEROL_INCLUDE_MPI_DISPATCHER_MPI_DISPATCHER_HPP
121 MPIMaster(MPI_Comm
const&
Comm, std::size_t ntasks,
bool include_boss =
true);
143 #endif // #ifndef POMEROL_INCLUDE_MPI_DISPATCHER_MPI_DISPATCHER_HPP
void receive_order()
Check if there is an outstanding order from the master.
JobId current_job_
ID of the job currently assigned to this worker.
MPI_Comm Comm
MPI communicator.
MPI_Request req
An MPI request handle used for non-blocking communications.
bool is_working()
Is a job being processed by this worker?
std::vector< JobId > task_numbers
A list of IDs of all jobs to be completed.
MPIWorker(MPI_Comm const &Comm, int Boss)
std::vector< MPI_Request > wait_statuses
MPI request handles used to perform non-blocking communications with the workers.
std::stack< JobId > JobStack
Stack of the jobs yet to be assigned to a worker.
int Nprocs
Total number of worker processes.
std::stack< WorkerId > WorkerStack
Stack of currently pending workers.
int Ntasks
Total number of jobs.
const int boss
Rank of the master process.
std::map< WorkerId, int > WorkerIndices
Worker IDs and their serial numbers from the [0; worker_pool.size()[ range.
void order()
Request the next available worker to perform the next job from the job stack.
JobId current_job() const
Get the ID of the job currently assigned to this worker.
MPI_Comm Comm
MPI communicator.
WorkerTag
MPI message tags used in communications between the master and its workers.
@ Finish
Order a worker to shut down.
std::vector< bool > workers_finish
Flags to mark workers that have been shut down.
const WorkerId id
Worker ID of this process.
Abstraction of an MPI master process.
bool is_finished() const
Have all the workers been shut down?
bool is_finished()
Has this worker process finished execution.
@ Work
Request a worker to do a job.
@ Pending
A worker is waiting for a new job.
int WorkerId
ID of a worker process.
void order_worker(WorkerId worker_id, JobId job)
std::vector< WorkerId > worker_pool
A list of IDs of all worker processes.
void check_workers()
Check which workers have become available and which have been shut down.
WorkerTag Status
Current state of this worker.
Abstraction of an MPI worker process.
MPIMaster(MPI_Comm const &Comm, std::vector< WorkerId > worker_pool, std::vector< JobId > task_numbers)
std::map< JobId, WorkerId > DispatchMap
A mapping from job IDs to IDs of the workers assigned to perform the jobs.
A bunch of tools used for MPI-parallelization of computations.
void report_job_done()
Notify the master about a job's completion.