init.grid(nprow, npcol, ICTXT)
.pbdBASEEnv
environment. See Details
section.ICTXT
is missing, three variables will be created in the
.pbdBASEEnv
environment:
.__blacs_gridinfo_0
.__blacs_gridinfo_1
.__blacs_gridinfo_2
These variables store the BLACS process grid information for the BLACS
context corresponding to the trailing digit of the variable. Most users should
invoke init.grid()
in this fashion, namely with ICTXT missing, and only
do so once.
Contexts 0, 1, 2, and 3 are reserved. Additional custom contexts
are possible to create, but they must be integers > 3.
Context 0 is the ``full'' process grid of nprow
by npcol
processes; contexts 1 is the process grid consisting of 1 process row and
nprow
*npcol
processes columns; context 2 is the process grid
consisting of nprow
*npcol
processes rows and 1 process column.
These contexts can be redundant depending on the number of prcesses available.
BLACS contexts have important internal use, and advanced users familiar with
ScaLAPACK might find some advantage in directly manipulating these process
grids. Most users should not need to directly manage BLACS contexts, in this
function or elsewhere.
If the nprow
and npcol
values are missing, then a best process
grid will be chosen for the user based on the total available number of
processes. Here ``best'' means as close to a square grid as possible.
The variables .__blacs_gridinfo_ICTXT
are just storage mechanisms
to avoid needing to directly invoke the BLACS routine BLACS_GRIDINFO
.
Additionally, another variable is created in the .pbdBASEEnv
environment, namely .__blacs_initialized
. Its existence
is to alert finalize()
to shut down BLACS communicators, if
necessary, to prevent memory leaks.
as.ddmatrix, BLACS, Distribute
# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r
library(pbdBASE, quiet = TRUE)
init.grid()
finalize()
Run the code above in your browser using DataLab