pbdBASE (version 0.5-0)

InitGrid: Initialize Process Grid

Description

Manages the creation of BLACS context grids.

Usage

init.grid(NPROW, NPCOL, ICTXT, quiet = FALSE)

Arguments

NPROW

number of process rows. Can be missing; see details.

NPCOL

number of process columns. Can be missing; see details.

ICTXT

BLACS context number.

quiet

logical; controls whether or not information about grid size should be printed.

Value

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

Details

blacs_init() is for experienced users only. It is a shallow wrapper of the BLACS routine BLACS_INIT, with the addition of creating the .__blacs_gridinfo_ICTXT objects, as described below.

The remainder of this section applies only to init.grid().

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, and 2 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.

Examples

Run this code
# NOT RUN {
spmd.code = "
  suppressMessages(library(pbdBASE))
  init.grid()

  finalize()
"

pbdMPI::execmpi(spmd.code = spmd.code, nranks = 2L)

# }

Run the code above in your browser using DataCamp Workspace