pomerol
2.1
|
Abstraction of an MPI master process. More...
#include <mpi_dispatcher.hpp>
Public Member Functions | |
MPIMaster (MPI_Comm const &Comm, std::vector< WorkerId > worker_pool, std::vector< JobId > task_numbers) | |
MPIMaster (MPI_Comm const &Comm, std::vector< JobId > task_numbers, bool include_boss=true) | |
MPIMaster (MPI_Comm const &Comm, std::size_t ntasks, bool include_boss=true) | |
void | order_worker (WorkerId worker_id, JobId job) |
void | order () |
Request the next available worker to perform the next job from the job stack. More... | |
void | check_workers () |
Check which workers have become available and which have been shut down. More... | |
bool | is_finished () const |
Have all the workers been shut down? More... | |
Data Fields | |
MPI_Comm | Comm |
MPI communicator. More... | |
int | Ntasks |
Total number of jobs. More... | |
int | Nprocs |
Total number of worker processes. More... | |
std::stack< JobId > | JobStack |
Stack of the jobs yet to be assigned to a worker. More... | |
std::stack< WorkerId > | WorkerStack |
Stack of currently pending workers. More... | |
std::map< JobId, WorkerId > | DispatchMap |
A mapping from job IDs to IDs of the workers assigned to perform the jobs. More... | |
std::vector< JobId > | task_numbers |
A list of IDs of all jobs to be completed. More... | |
std::vector< WorkerId > | worker_pool |
A list of IDs of all worker processes. More... | |
std::map< WorkerId, int > | WorkerIndices |
Worker IDs and their serial numbers from the [0; worker_pool.size()[ range. More... | |
std::vector< MPI_Request > | wait_statuses |
MPI request handles used to perform non-blocking communications with the workers. More... | |
std::vector< bool > | workers_finish |
Flags to mark workers that have been shut down. More... | |
Abstraction of an MPI master process.
Definition at line 78 of file mpi_dispatcher.hpp.
pMPI::MPIMaster::MPIMaster | ( | MPI_Comm const & | Comm, |
std::vector< WorkerId > | worker_pool, | ||
std::vector< JobId > | task_numbers | ||
) |
Constructor.
[in] | Comm | MPI communicator. |
[in] | worker_pool | A list of IDs of all worker processes. |
[in] | task_numbers | A list of IDs of all jobs to be completed. |
pMPI::MPIMaster::MPIMaster | ( | MPI_Comm const & | Comm, |
std::vector< JobId > | task_numbers, | ||
bool | include_boss = true |
||
) |
Constructor. This version generates a list of worker IDs automatically.
[in] | Comm | MPI communicator. |
[in] | task_numbers | A list of IDs of all jobs to be completed. |
[in] | include_boss | If true, allocate one worker per one MPI rank in the communicator. Otherwise, skip the rank of the master process. |
pMPI::MPIMaster::MPIMaster | ( | MPI_Comm const & | Comm, |
std::size_t | ntasks, | ||
bool | include_boss = true |
||
) |
Constructor. This version generates lists of job IDs and worker IDs automatically.
[in] | Comm | MPI communicator. |
[in] | ntasks | The number of jobs to be completed. |
[in] | include_boss | If true, allocate one worker per one MPI rank in the communicator. Otherwise, skip the rank of the master process. |
void pMPI::MPIMaster::check_workers | ( | ) |
Check which workers have become available and which have been shut down.
bool pMPI::MPIMaster::is_finished | ( | ) | const |
Have all the workers been shut down?
void pMPI::MPIMaster::order | ( | ) |
Request the next available worker to perform the next job from the job stack.
Request a worker process to perform a job.
[in] | worker_id | ID of the worker process. |
[in] | job | ID of the job to be performed. |
MPI_Comm pMPI::MPIMaster::Comm |
MPI communicator.
Definition at line 80 of file mpi_dispatcher.hpp.
A mapping from job IDs to IDs of the workers assigned to perform the jobs.
Definition at line 92 of file mpi_dispatcher.hpp.
std::stack<JobId> pMPI::MPIMaster::JobStack |
Stack of the jobs yet to be assigned to a worker.
Definition at line 87 of file mpi_dispatcher.hpp.
int pMPI::MPIMaster::Nprocs |
Total number of worker processes.
Definition at line 84 of file mpi_dispatcher.hpp.
int pMPI::MPIMaster::Ntasks |
Total number of jobs.
Definition at line 82 of file mpi_dispatcher.hpp.
std::vector<JobId> pMPI::MPIMaster::task_numbers |
A list of IDs of all jobs to be completed.
Definition at line 94 of file mpi_dispatcher.hpp.
std::vector<MPI_Request> pMPI::MPIMaster::wait_statuses |
MPI request handles used to perform non-blocking communications with the workers.
Definition at line 101 of file mpi_dispatcher.hpp.
std::vector<WorkerId> pMPI::MPIMaster::worker_pool |
A list of IDs of all worker processes.
Definition at line 96 of file mpi_dispatcher.hpp.
std::map<WorkerId, int> pMPI::MPIMaster::WorkerIndices |
Worker IDs and their serial numbers from the [0; worker_pool.size()[ range.
Definition at line 98 of file mpi_dispatcher.hpp.
std::vector<bool> pMPI::MPIMaster::workers_finish |
Flags to mark workers that have been shut down.
Definition at line 103 of file mpi_dispatcher.hpp.
std::stack<WorkerId> pMPI::MPIMaster::WorkerStack |
Stack of currently pending workers.
Definition at line 89 of file mpi_dispatcher.hpp.