pomerol  2.1
Public Member Functions | Data Fields
pMPI::MPIMaster Struct Reference

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< JobIdJobStack
 Stack of the jobs yet to be assigned to a worker. More...
 
std::stack< WorkerIdWorkerStack
 Stack of currently pending workers. More...
 
std::map< JobId, WorkerIdDispatchMap
 A mapping from job IDs to IDs of the workers assigned to perform the jobs. More...
 
std::vector< JobIdtask_numbers
 A list of IDs of all jobs to be completed. More...
 
std::vector< WorkerIdworker_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...
 

Detailed Description

Abstraction of an MPI master process.

Definition at line 78 of file mpi_dispatcher.hpp.

Constructor & Destructor Documentation

◆ MPIMaster() [1/3]

pMPI::MPIMaster::MPIMaster ( MPI_Comm const &  Comm,
std::vector< WorkerId worker_pool,
std::vector< JobId task_numbers 
)

Constructor.

Parameters
[in]CommMPI communicator.
[in]worker_poolA list of IDs of all worker processes.
[in]task_numbersA list of IDs of all jobs to be completed.

◆ MPIMaster() [2/3]

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.

Parameters
[in]CommMPI communicator.
[in]task_numbersA list of IDs of all jobs to be completed.
[in]include_bossIf true, allocate one worker per one MPI rank in the communicator. Otherwise, skip the rank of the master process.

◆ MPIMaster() [3/3]

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.

Parameters
[in]CommMPI communicator.
[in]ntasksThe number of jobs to be completed.
[in]include_bossIf true, allocate one worker per one MPI rank in the communicator. Otherwise, skip the rank of the master process.

Member Function Documentation

◆ check_workers()

void pMPI::MPIMaster::check_workers ( )

Check which workers have become available and which have been shut down.

◆ is_finished()

bool pMPI::MPIMaster::is_finished ( ) const

Have all the workers been shut down?

◆ order()

void pMPI::MPIMaster::order ( )

Request the next available worker to perform the next job from the job stack.

◆ order_worker()

void pMPI::MPIMaster::order_worker ( WorkerId  worker_id,
JobId  job 
)

Request a worker process to perform a job.

Parameters
[in]worker_idID of the worker process.
[in]jobID of the job to be performed.

Field Documentation

◆ Comm

MPI_Comm pMPI::MPIMaster::Comm

MPI communicator.

Definition at line 80 of file mpi_dispatcher.hpp.

◆ DispatchMap

std::map<JobId, WorkerId> pMPI::MPIMaster::DispatchMap

A mapping from job IDs to IDs of the workers assigned to perform the jobs.

Definition at line 92 of file mpi_dispatcher.hpp.

◆ JobStack

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.

◆ Nprocs

int pMPI::MPIMaster::Nprocs

Total number of worker processes.

Definition at line 84 of file mpi_dispatcher.hpp.

◆ Ntasks

int pMPI::MPIMaster::Ntasks

Total number of jobs.

Definition at line 82 of file mpi_dispatcher.hpp.

◆ task_numbers

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.

◆ wait_statuses

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.

◆ worker_pool

std::vector<WorkerId> pMPI::MPIMaster::worker_pool

A list of IDs of all worker processes.

Definition at line 96 of file mpi_dispatcher.hpp.

◆ WorkerIndices

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.

◆ workers_finish

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.

◆ WorkerStack

std::stack<WorkerId> pMPI::MPIMaster::WorkerStack

Stack of currently pending workers.

Definition at line 89 of file mpi_dispatcher.hpp.


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