Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ mpi_map_chunks()

std::vector< int > stan::math::mpi_map_chunks ( std::size_t  num_jobs,
std::size_t  chunk_size = 1 
)
inline

Maps jobs of given chunk size to workers and returning a vector of counts.

The returned vector is indexed by the rank of each worker and has size equal to the # of workers. Each count per worker is the product of the number of assigned jobs times the chunk size. The jobs are deterministically assigned to workers. This is used for static scheduling of jobs internally.

So with num_workers workers, then the counts for worker with given rank is

chunks[rank] = floor(num_jobs/num_workers) * chunk_size

The remainder jobs num_jobs % num_workers are assigned to rank >=1 workers such that the root (rank = 0) has a little less assigned chunks unless num_jobs < num_workers in which case the first num_jobs nodes receive a job (including the root).

Parameters
num_jobsTotal number of jobs to dispatch
chunk_sizeChunk size per job
Returns
vector indexed by rank with the total number of elements mapped to a given worker

Definition at line 84 of file mpi_cluster.hpp.