get job id | R Documentation |

This function obtains job id which can be used to divide jobs.

get.jid(n, method = .pbd_env$SPMD.CT$divide.method[1], all = FALSE, comm = .pbd_env$SPMD.CT$comm, reduced = FALSE)

`n` |
total number of jobs. |

`method` |
a way to divide jobs. |

`all` |
indicate if return all id for each processor. |

`comm` |
a communicator number. |

`reduced` |
indicate if return should be a reduced representation. |

`n`

is total number of jobs needed to be divided into all processors
(`comm.size(comm)`

, i.e. `1:n`

will be split according to
the rank of processor (`comm.rank(comm)`

) and `method`

.
Job id will be returned. Currently, three possible methods are provided.

`"block"`

will use return id's which are nearly equal size blocks.
For example,
7 jobs in 4 processors will have `jid=1`

for rank 0, `jid=2,3`

for rank 1, `jid=4,5`

for rank 2, and `jid=6,7`

for rank 3.

`"block0"`

will use return id's which are nearly equal size blocks,
in the opposite direction of `"block"`

.
For example,
7 jobs in 4 processors will have `jid=1,2`

for rank 0, `jid=3,4`

for rank 1, `jid=5,6`

for rank 2, and `jid=7`

for rank 3.

`"cycle"`

will use return id's which are nearly equal size in cycle.
For example, 7 jobs in 4 processors will have `jid=1,5`

for rank 0,
`jid=2,6`

for rank 1, `jid=3,7`

for rank 2, and `jid=4`

for rank 3.

`get.id()`

returns a vector containing job id for each individual
processor if `all = FALSE`

. While it returns a list containing all
job id for all processor if `all = TRUE`

. The list has length equal
to `COMM.SIZE`

.

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/

`task.pull()`

.

### Save code in a file "demo.r" and run with 2 processors by ### SHELL> mpiexec -np 2 Rscript demo.r spmd.code <- " ### Initial. suppressMessages(library(pbdMPI, quietly = TRUE)) init() ### Examples. comm.cat(\">>> block\n\", quiet = TRUE) jid <- get.jid(7, method = \"block\") comm.print(jid, all.rank = TRUE) comm.cat(\">>> cycle\n\", quiet = TRUE) jid <- get.jid(7, method = \"cycle\") comm.print(jid, all.rank = TRUE) comm.cat(\">>> block (all)\n\", quiet = TRUE) alljid <- get.jid(7, method = \"block\", all = TRUE) comm.print(alljid) comm.cat(\">>> cycle (all)\n\", quiet = TRUE) alljid <- get.jid(7, method = \"cycle\", all = TRUE) comm.print(alljid) ### Finish. finalize() " pbdMPI::execmpi(spmd.code, nranks = 2L)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.