These functions are designed for SPMD but assume that rank 0 is a manager and the rest are workers.
task.pull(jids, FUN, ..., rank.manager = .pbd_env$SPMD.CT$rank.root,
comm = .pbd_env$SPMD.CT$comm, bcast = .pbd_env$SPMD.TP$bcast,
barrier = .pbd_env$SPMD.TP$barrier,
try = .pbd_env$SPMD.TP$try,
try.silent = .pbd_env$SPMD.TP$try.silent)task.pull.workers(FUN = function(jid, ...){ return(jid) }, ...,
rank.manager = .pbd_env$SPMD.CT$rank.root,
comm = .pbd_env$SPMD.CT$comm,
try = .pbd_env$SPMD.TP$try,
try.silent = .pbd_env$SPMD.TP$try.silent)
task.pull.manager(jids, rank.manager = .pbd_env$SPMD.CT$rank.root,
comm = .pbd_env$SPMD.CT$comm)
A list with length comm.size() - 1
will be returned to the manager and NULL
to the workers.
Each element of the list contains the returns ret
of their FUN
results.
all job ids (a vector of positive integers).
a function to be evaluated by workers.
extra parameters for FUN
.
rank of the manager from where jid
is sent.
a communicator number.
if bcast to all ranks.
if barrier for all ranks.
wheter to use try()
to avoid crashes. CAUTION:
try = FALSE
is not safe and can crash all MPI/R jobs.
turn off error messages from try()
.
Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.
All of these functions are designed to emulate a manager/workers paradigm in an SPMD environment. If your chunk workloads are known and similar, consider a direct SPMD solution.
FUN
is a user defined function which has jid
as
its first argument and other variables are given in ...
.
The manager will be queried by workers whenever a worker finishes a job to see if more jobs are available.
Programming with Big Data in R Website: https://pbdr.org/
get.jid()
.
if (FALSE) {
### Under command mode, run the demo with 2 processors by
### (Use Rscript.exe for windows system)
# mpiexec -np 2 Rscript -e "demo(task_pull,'pbdMPI',ask=F,echo=F)"
### Or
# execmpi("demo(task_pull,'pbdMPI',ask=F,echo=F)", nranks = 2L)
}
Run the code above in your browser using DataLab