global print and cat | R Documentation |
The functions globally print or cat a variable from specified processors, by default messages is shown on screen.
comm.print(x, all.rank = .pbd_env$SPMD.CT$print.all.rank,
rank.print = .pbd_env$SPMD.CT$rank.source,
comm = .pbd_env$SPMD.CT$comm,
quiet = .pbd_env$SPMD.CT$print.quiet,
flush = .pbd_env$SPMD.CT$msg.flush,
barrier = .pbd_env$SPMD.CT$msg.barrier,
con = stdout(), sleep = 0, ...)
comm.cat(..., all.rank = .pbd_env$SPMD.CT$print.all.rank,
rank.print = .pbd_env$SPMD.CT$rank.source,
comm = .pbd_env$SPMD.CT$comm,
quiet = .pbd_env$SPMD.CT$print.quiet, sep = " ", fill = FALSE,
labels = NULL, append = FALSE, flush = .pbd_env$SPMD.CT$msg.flush,
barrier = .pbd_env$SPMD.CT$msg.barrier, con = stdout(), sleep = 0)
x |
a variable to be printed. |
... |
variables to be cat. |
all.rank |
if all ranks print (default = FALSE). |
rank.print |
rank for printing if not all ranks print (default = 0). |
comm |
communicator for printing (default = 1). |
quiet |
Logical to control whether whether a "COMM.RANK = #" line is added to indicate which rank is printing, or integer to do rank-coloring instead. If integer, giving a communicator number, up to 8 colors are used to distinguish each rank prints. If the specified communicator has more than 8 ranks, colors are recycled. With a single communicator, this is straightforward. This can be extremely helpful in debugging complex communicator splits. In these cases, the parameter 'comm' below can be different from the split communicator assigned to 'quiet'. |
sep |
sep argument as in the |
fill |
fill argument as in the |
labels |
labels argument as in the |
append |
labels argument as in the |
flush |
if flush |
barrier |
if barrier |
con |
|
sleep |
Normally left at 0. If overprinting by ranks occurrs, set to 0.01 or smaller to delay the first printing rank action and allow any previous print to land. |
Warning: These two functions use barrier()
to make sure
the well printing process on screen, so should be called by all processors
to avoid a deadlock. A typical misuse is called inside a condition check,
such as if(.comm.rank == 0) comm.cat(...)
.
rank.print
can be a integer vector containing the ranks of
processors which print messages.
A print()
or cat()
is called for the specified processors
and the messages of the input variables is shown on screen by default.
Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.
Programming with Big Data in R Website: https://pbdr.org/
## Not run:
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r
spmd.code <- "
### Initialize
suppressMessages(library(pbdMPI, quietly = TRUE))
### Example.
comm.print(comm.rank(), rank.print = 1)
### Finish.
finalize()
"
# execmpi(spmd.code, nranks = 2L)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.