Learn R Programming

pbdBASE (version 0.1-1)

InitGrid: Initialize Process Grid

Description

Manages the creation of BLACS context grids.

Usage

init.grid(nprow, npcol, ICTXT)

Arguments

nprow
number of process rows.
npcol
number of process columns.
ICTXT
BLACS context number.

Value

  • Silently returns 0 when successful. Additionally, several variables are created in the .pbdBASEEnv environment. See Details section.

Details

If 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.

See Also

as.ddmatrix, BLACS, Distribute

Examples

Run this code
# 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