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