This function computes the local number of rows or columns of a block-cyclically distributed matrix contained in a process row or process column, respectively, indicated by the calling sequence argument iproc.
Fortran | NUMROC (n, nb, iproc, isrcproc, nprocs) |
C and C++ | numroc (n, nb, iproc, isrcproc, nprocs); |
Scope: global
Specified as: a fullword integer; n >= 0.
Scope: global
Specified as: a fullword integer; nb > 0.
Scope: local
Specified as: a fullword integer; 0 <= iproc < nprocs.
Scope: global
Specified as: a fullword integer; 0 <= isrcproc < nprocs.
Scope: global
Specified as: a fullword integer; nprocs > 0.
Scope: local
Returned as: a fullword integer.
The variables p and nprow are used interchangeably to indicate the number of rows in a process grid. The variables q and npcol are used interchangeably to indicate the number of columns in a process grid.
None
None
This example shows the local invocations of NUMROC from four processes in a 2 × 2 process grid, using a global symmetric matrix of order 9.
ORDER = 'R' NPROW = 2 NPCOL = 2 CALL BLACS_GET(0, 0, ICONTXT) CALL BLACS_GRIDINIT(ICONTXT, ORDER, NPROW, NPCOL) CALL BLACS_GRIDINFO(ICONTXT, NPROW, NPCOL, MYROW, MYCOL)
The NUMROC function invocations and associated data on each process are shown in "Local Invocations of NUMROC."
The pertinent array descriptor values for global matrix C are
shown below:
| Desc_C |
---|---|
M_ | 9 |
N_ | 9 |
MB_ | 4 |
NB_ | 4 |
RSRC_ | 0 |
CSRC_ | 0 |
Global symmetric matrix C of order 9 is stored in upper storage mode with block sizes 4 × 4:
B,D 0 1 2 * * | -6.0 0.0 0.0 0.0 | 0.0 -2.0 -2.0 0.0 | -2.0 | | . -6.0 -2.0 0.0 | -2.0 -4.0 0.0 -4.0 | -2.0 | 0 | . . -6.0 -2.0 | -2.0 0.0 2.0 0.0 | 6.0 | | . . . -6.0 | 2.0 0.0 2.0 0.0 | 2.0 | | ---------------------|-----------------------|------- | | . . . . | -8.0 -4.0 0.0 -2.0 | 0.0 | | . . . . | . -6.0 0.0 -4.0 | -6.0 | 1 | . . . . | . . -4.0 0.0 | 0.0 | | . . . . | . . . -4.0 | -4.0 | | ---------------------|-----------------------|------- | 2 | . . . . | . . . . | -16.0 | * *
The following is the 2 × 2 process grid:
B,D | 0 2 | 1 -----| ------- |----- 0 | P00 | P01 2 | | -----| ------- |----- 1 | P10 | P11
Local arrays for C:
p,q | 0 | 1 -----|----------------------------|---------------------- | -6.0 0.0 0.0 0.0 -2.0 | 0.0 -2.0 -2.0 0.0 | . -6.0 -2.0 0.0 -2.0 | -2.0 -4.0 0.0 -4.0 0 | . . -6.0 -2.0 6.0 | -2.0 0.0 2.0 0.0 | . . . -6.0 2.0 | 2.0 0.0 2.0 0.0 | . . . . -16.0 | . . . . -----|----------------------------|---------------------- | . . . . 0.0 | -8.0 -4.0 0.0 -2.0 | . . . . -6.0 | . -6.0 0.0 -4.0 1 | . . . . 0.0 | . . -4.0 0.0 | . . . . -4.0 | . . . -4.0
Local Invocations of NUMROC:
p,q | 0 | 1 -----|----------------------------------------------|---------------------------------------------- | M_C MB_C MYROW RSRC_C NPROW | M_C MB_C MYROW RSRC_C NPROW | | | | | | | | | | | | | MP = NUMROC( 9, 4, 0, 0, 2) | MP = NUMROC( 9, 4, 0, 0, 2) 0 | | | N_C NB_C MYCOL CSRC_C NPCOL | N_C NB_C MYCOL CSRC_C NPCOL | | | | | | | | | | | | | NQ = NUMROC( 9, 4, 0, 0, 2) | NQ = NUMROC( 9, 4, 1, 0, 2) -----|----------------------------------------------|---------------------------------------------- | M_C MB_C MYROW RSRC_C NPROW | M_C MB_C MYROW RSRC_C NPROW | | | | | | | | | | | | | MP = NUMROC( 9, 4, 1, 0, 2) | MP = NUMROC( 9, 4, 1, 0, 2) 1 | | | N_C NB_C MYCOL CSRC_C NPCOL | N_C NB_C MYCOL CSRC_C NPCOL | | | | | | | | | | | | | NQ = NUMROC( 9, 4, 0, 0, 2) | NQ = NUMROC( 9, 4, 1, 0, 2)
Output:
The local number of rows MP and columns NQ of the block-cyclically distributed matrix returned by NUMROC on each process:
p,q | 0 | 1 -----|--------|-------- 0 | MP=5 | MP=5 | NQ=5 | NQ=4 -----|--------|-------- 1 | MP=4 | MP=4 | NQ=5 | NQ=4