IBM Books

Parallel Engineering and Scientific Subroutine Library for AIX Version 2 Release 3: Guide and Reference

PDTRAN, PZTRANC, and PZTRANU--Matrix Transpose for a General Matrix

PDTRAN and PZTRANU perform the following matrix computation:

C<--betaC+alphaAT

PZTRANC performs the following matrix computation:

C<--betaC+alphaAH

where, in the formula above:

A represents the global general submatrix Aia:ia+n-1, ja:ja+m-1.
C represents the global general submatrix Cic:ic+m-1, jc:jc+n-1.
alpha and beta are scalars.

Note:
No data should be moved to form AT or AH; that is, the matrix A should always be stored in its untransposed form.

In the following three cases, no computation is performed and the subroutine returns after doing some parameter checking:

See references [14] and [15].

Table 53. Data Types

alpha, beta, A, C Subprogram
Long-precision real PDTRAN
Long-precision complex PZTRANC and PZTRANU

Syntax

Fortran CALL PDTRAN | PZTRANC | PZTRANU (m, n, alpha, a, ia, ja, desc_a, beta, c, ic, jc, desc_c)
C and C++ pdtran | pztranc | pztranu (m, n, alpha, a, ia, ja, desc_a, beta, c, ic, jc, desc_c);

On Entry

m
is the number of rows in submatrix C and the number of columns in submatrix A used in the computation.

Scope: global

Specified as: a fullword integer; m >= 0.

n
is the number of columns in submatrix C and the number of rows in submatrix A used in the computation.

Scope: global

Specified as: a fullword integer; n >= 0.

alpha
is the scalar alpha.

Scope: global

Specified as: a number of the data type indicated in Table 53.

a
is the local part of the global general matrix A. This identifies the first element of the local array A. This subroutine computes the location of the first element of the local subarray used, based on ia, ja, desc_a, p, q, myrow, and mycol; therefore, the leading LOCp(ia+n-1) by LOCq(ja+m-1) part of the local array A must contain the local pieces of the leading ia+n-1 by ja+m-1 part of the global matrix.
Note:
No data should be moved to form AT or AH; that is, the matrix A should always be stored in its untransposed form.

Scope: local

Specified as: an LLD_A by (at least) LOCq(N_A) array, containing numbers of the data type indicated in Table 53. Details about the block-cyclic data distribution of global matrix A are stored in desc_a.

ia
is the row index of the global matrix A, identifying the first row of the submatrix A.

Scope: global

Specified as: a fullword integer; 1 <= ia <= M_A and ia+n-1 <= M_A.

ja
is the column index of the global matrix A, identifying the first column of the submatrix A.

Scope: global

Specified as: a fullword integer; 1 <= ja <= N_A and ja+m-1 <= N_A.

desc_a
is the array descriptor for global matrix A, described in the following table:
desc_a Name Description Limits Scope
1 DTYPE_A Descriptor type DTYPE_A=1 Global
2 CTXT_A BLACS context Valid value, as returned by BLACS_GRIDINIT or BLACS_GRIDMAP Global
3 M_A Number of rows in the global matrix If m = 0 or n = 0:
M_A >= 0
Otherwise:
M_A >= 1
Global
4 N_A Number of columns in the global matrix If m = 0 or n = 0:
N_A >= 0
Otherwise:
N_A >= 1
Global
5 MB_A Row block size MB_A >= 1 Global
6 NB_A Column block size NB_A >= 1 Global
7 RSRC_A The process row of the p × q grid over which the first row of the global matrix is distributed 0 <= RSRC_A < p Global
8 CSRC_A The process column of the p × q grid over which the first column of the global matrix is distributed 0 <= CSRC_A < q Global
9 LLD_A The leading dimension of the local array LLD_A >= max(1,LOCp(M_A)) Local

Specified as: an array of (at least) length 9, containing fullword integers.

beta
is the scalar beta.

Scope: global

Specified as: a number of the data type indicated in Table 53.

c
is the local part of the global general matrix C. This identifies the first element of the local array C. This subroutine computes the location of the first element of the local subarray used, based on ic, jc, desc_c, p, q, myrow, and mycol; therefore, the leading LOCp(ic+m-1) by LOCq(jc+n-1) part of the local array C must contain the local pieces of the leading ic+m-1 by jc+n-1 part of the global matrix.

When beta is zero, C need not be set on input.

Scope: local

Specified as: an LLD_C by (at least) LOCq(N_C) array, containing numbers of the data type indicated in Table 53. Details about the block-cyclic data distribution of global matrix C are stored in desc_c.

ic
is the row index of the global matrix C, identifying the first row of the submatrix C.

Scope: global

Specified as: a fullword integer; 1 <= ic <= M_C and ic+m-1 <= M_C.

jc
is the column index of the global matrix C, identifying the first column of the submatrix C.

Scope: global

Specified as: a fullword integer; 1 <= jc <= N_C and jc+n-1 <= N_C.

desc_c
is the array descriptor for global matrix C, described in the following table:
desc_c Name Description Limits Scope
1 DTYPE_C Descriptor type DTYPE_C=1 Global
2 CTXT_C BLACS context Valid value, as returned by BLACS_GRIDINIT or BLACS_GRIDMAP Global
3 M_C Number of rows in the global matrix If m = 0 or n = 0:
M_C >= 0
Otherwise:
M_C >= 1
Global
4 N_C Number of columns in the global matrix If m = 0 or n = 0:
N_C >= 0
Otherwise:
N_C >= 1
Global
5 MB_C Row block size MB_C >= 1 Global
6 NB_C Column block size NB_C >= 1 Global
7 RSRC_C The process row of the p × q grid over which the first row of the global matrix is distributed 0 <= RSRC_C < p Global
8 CSRC_C The process column of the p × q grid over which the first column of the global matrix is distributed 0 <= CSRC_C < q Global
9 LLD_C The leading dimension of the local array LLD_C >= max(1,LOCp(M_C)) Local

Specified as: an array of (at least) length 9, containing fullword integers.

On Return

c
is the updated local part of the global general matrix C, containing the results of the computation.

Scope: local

Returned as: an LLD_C by (at least) LOCq(N_C) array, containing numbers of the data type indicated in Table 53.

Notes and Coding Rules
  1. The matrices must have no common elements; otherwise, results are unpredictable.
  2. The NUMROC utility subroutine can be used to determine the values of LOCp(M_) and LOCq(N_) used in the argument descriptions above. For details, see Determining the Number of Rows and Columns in Your Local Arrays and NUMROC--Compute the Number of Rows or Columns of a Block-Cyclically Distributed Matrix Contained in a Process.
  3. For suggested block sizes, see Coding Tips for Optimizing Parallel Performance.
  4. The following values must be equal: CTXT_A = CTXT_C.
  5. The coding rules (given in this section) and the error conditions (given in the next section) are written in terms of adist. To determine a value for adist, check the following conditions, in order, and chose the first value having a true condition:
    1. If A is a block column matrix, that is:
      m+mod(ja-1, NB_A) <= NB_A

      then adist = 'C'

    2. If A is a block row matrix, that is:
      n+mod(ia-1, MB_A) <= MB_A

      then adist = 'R'

    3. If A is neither a block column or a block row matrix, then:
      • If m <= n, then adist = 'C'.
      • Otherwise, adist = 'R'.
  6. If adist = 'C', then you must follow these coding rules:
  7. If adist = 'R', then you must follow these coding rules:

Error Conditions

Computational Errors

None

Resource Errors

Unable to allocate work space

Input-Argument and Miscellaneous Errors

Stage 1 

  1. DTYPE_A is invalid.
  2. DTYPE_C is invalid.

Stage 2 

  1. CTXT_A is invalid.

Stage 3 

  1. This subroutine was called from outside the process grid.

Stage 4 

  1. m < 0
  2. n < 0
  3. M_A < 0 and (m = 0 or n = 0); M_A < 1 otherwise
  4. N_A < 0 and (m = 0 or n = 0); N_A < 1 otherwise
  5. MB_A < 1
  6. NB_A < 1
  7. RSRC_A < 0 or RSRC_A >= p
  8. CSRC_A < 0 or CSRC_A >= q
  9. ia < 1
  10. ja < 1
  11. M_C < 0 and (m = 0 or n = 0); M_C < 1 otherwise
  12. N_C < 0 and (m = 0 or n = 0); N_C < 1 otherwise
  13. MB_C < 1
  14. NB_C < 1
  15. RSRC_C < 0 or RSRC_C >= p
  16. CSRC_C < 0 or CSRC_C >= q
  17. ic < 1
  18. jc < 1
  19. CTXT_A <> CTXT_C

Stage 5 

Note:
Some of the following error conditions depend on the value of adist--that is, adist = 'C' or or adist = 'R'. For details on determining the value, see Notes and Coding Rules.

If m <> 0 and n <> 0:

  1. ia > M_A
  2. ja > N_A
  3. ia+n-1 > M_A
  4. ja+m-1 > N_A
  5. ic > M_C
  6. jc > N_C
  7. ic+m-1 > M_C
  8. jc+n-1 > N_C

If adist = 'C':

  1. mod(ia-1, MB_A) <> 0
  2. mod(jc-1, NB_C) <> 0
  3. MB_A <> NB_C
  4. If looping is required--that is, either of the following is true:
    m+mod(ja-1, NB_A) > NB_A
    m+mod(ic-1, MB_C) > MB_C

    then:

    1. mod(ja-1, NB_A) <> mod(ic-1, MB_C)
    2. NB_A <> MB_C.

If adist = 'R':

  1. mod(ja-1, NB_A) <> 0
  2. mod(ic-1, MB_C) <> 0
  3. NB_A <> MB_C
  4. If looping is required--that is, either of the following is true:
    n+mod(ia-1, MB_A) > MB_A
    n+mod(jc-1, NB_C) > NB_C

    then:

    1. mod(ia-1, MB_A) <> mod(jc-1, NB_C)
    2. MB_A <> NB_C.

Stage 6 

  1. LLD_A < max(1, LOCp(M_A))
  2. LLD_C < max(1, LOCp(M_C))

Example 1

This example computes C = betaC+alphaAT using a 2 × 2 process grid.

Call Statements and Input


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)
 
              M    N     ALPHA    A  IA  JA    DESC_A    BETA    C  IC  JC   DESC_C
              |    |       |      |   |   |      |         |     |   |   |     |
CALL PDTRAN(  9  , 8  ,  1.0D0  , A , 1 , 1 ,  DESC_A ,  1.0D0 , C , 1 , 1 , DESC_C )


Desc_A Desc_C
DTYPE_ 1 1
CTXT_ icontxt(IOBG32) icontxt(IOBG32)
M_ 8 9
N_ 9 8
MB_ 2 4
NB_ 4 2
RSRC_ 0 0
CSRC_ 0 0
LLD_ See below(EPSSL32) See below(EPSSL32)

Notes:

  1. icontxt is the output of the BLACS_GRIDINIT call.

  2. Each process should set the LLD_ as follows:
    LLD_A = MAX(1,NUMROC(M_A, MB_A, MYROW, RSRC_A, NPROW))
    LLD_C = MAX(1,NUMROC(M_C, MB_C, MYROW, RSRC_C, NPROW))
    

    In this example, LLD_A = 4 on all processes, LLD_C = 5 on P00 and P01, and LLD_C = 4 on P10 and P11.

Global general 8 × 9 matrix A with block size 2 × 4:

B,D             0                       1               2
     *                                                      *
 0   |  0.0 -1.0 -1.0  0.0  |   0.0  0.0  0.0  0.0  |   1.0 |
     |  0.0  1.0  0.0  1.0  |   0.0  1.0  0.0  1.0  |   1.0 |
     | ---------------------|-----------------------|------ |
 1   |  0.0  0.0 -1.0 -1.0  |   0.0  0.0  1.0  0.0  |   1.0 |
     |  0.0  1.0  0.0 -1.0  |   1.0  1.0  0.0  1.0  |   1.0 |
     | ---------------------|-----------------------|------ |
 2   |  1.0  0.0  0.0  0.0  |  -1.0  0.0  0.0  0.0  |   1.0 |
     |  1.0  0.0  0.0  0.0  |   1.0  1.0  0.0  0.0  |   1.0 |
     | ---------------------|-----------------------|------ |
 3   |  0.0  0.0 -1.0  0.0  |  -1.0  0.0  0.0  0.0  |   1.0 |
     | -1.0  0.0  0.0  0.0  |   0.0  0.0 -1.0  0.0  |   1.0 |
     *                                                      *

The following is the 2 × 2 process grid:

B,D  |   0 2   |  1  
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11
3    |         |

Local arrays for A:

p,q  |            0              |           1
-----|---------------------------|----------------------
     |  0.0 -1.0 -1.0  0.0  1.0  |   0.0  0.0  0.0  0.0
     |  0.0  1.0  0.0  1.0  1.0  |   0.0  1.0  0.0  1.0
 0   |  1.0  0.0  0.0  0.0  1.0  |  -1.0  0.0  0.0  0.0
     |  1.0  0.0  0.0  0.0  1.0  |   1.0  1.0  0.0  0.0
-----|---------------------------|----------------------
     |  0.0  0.0 -1.0 -1.0  1.0  |   0.0  0.0  1.0  0.0
     |  0.0  1.0  0.0 -1.0  1.0  |   1.0  1.0  0.0  1.0
 1   |  0.0  0.0 -1.0  0.0  1.0  |  -1.0  0.0  0.0  0.0
     | -1.0  0.0  0.0  0.0  1.0  |   0.0  0.0 -1.0  0.0

Global general 9 × 8 matrix C with block size 4 × 2:

B,D        0             1             2             3
     *                                                     *
     |  0.0  1.0  |   1.0  5.0  |   6.0  7.0  |   8.0  9.0 |
     |  0.0 -1.0  |   0.0 -1.0  |   0.0 -1.0  |   0.0  1.0 |
 0   |  0.0  0.0  |   1.0  1.0  |   0.0  0.0  |  -1.0  0.0 |
     |  0.0 -1.0  |   0.0  1.0  |  -1.0 -1.0  |   0.0  1.0 |
     | -----------|-------------|-------------|----------- |
     | -1.0  2.0  |   0.0  0.0  |   1.0  0.0  |   0.0  0.0 |
     | -1.0  3.0  |   0.0  0.0  |  -1.0 -1.0  |   0.0  0.0 |
 1   |  0.0  4.0  |   1.0  0.0  |   1.0  0.0  |   0.0  0.0 |
     |  1.0  5.0  |   0.0  0.0  |   0.0  0.0  |   1.0  0.0 |
     | -----------|-------------|-------------|----------- |
 2   |  1.0  2.0  |   3.0  4.0  |   1.0  1.0  |   1.0  1.0 |
     *                                                     *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:

p,q  |          0           |           1
-----|----------------------|----------------------
     |  0.0  1.0  6.0  7.0  |   1.0  5.0  8.0  9.0
     |  0.0 -1.0  0.0 -1.0  |   0.0 -1.0  0.0  1.0
 0   |  0.0  0.0  0.0  0.0  |   1.0  1.0 -1.0  0.0
     |  0.0 -1.0 -1.0 -1.0  |   0.0  1.0  0.0  1.0
     |  1.0  2.0  1.0  1.0  |   3.0  4.0  1.0  1.0
-----|----------------------|----------------------
     | -1.0  2.0  1.0  0.0  |   0.0  0.0  0.0  0.0
     | -1.0  3.0 -1.0 -1.0  |   0.0  0.0  0.0  0.0
 1   |  0.0  4.0  1.0  0.0  |   1.0  0.0  0.0  0.0
     |  1.0  5.0  0.0  0.0  |   0.0  0.0  1.0  0.0

Output:

Global general 9 × 8 matrix C with block size 4 × 2:

B,D        0             1             2             3
     *                                                     *
     |  0.0  1.0  |   1.0  5.0  |   7.0  8.0  |   8.0  8.0 |
     | -1.0  0.0  |   0.0  0.0  |   0.0 -1.0  |   0.0  1.0 |
 0   | -1.0  0.0  |   0.0  1.0  |   0.0  0.0  |  -2.0  0.0 |
     |  0.0  0.0  |  -1.0  0.0  |  -1.0 -1.0  |   0.0  1.0 |
     | -----------|-------------|-------------|----------- |
     | -1.0  2.0  |   0.0  1.0  |   0.0  1.0  |  -1.0  0.0 |
     | -1.0  4.0  |   0.0  1.0  |  -1.0  0.0  |   0.0  0.0 |
 1   |  0.0  4.0  |   2.0  0.0  |   1.0  0.0  |   0.0 -1.0 |
     |  1.0  6.0  |   0.0  1.0  |   0.0  0.0  |   1.0  0.0 |
     | -----------|-------------|-------------|----------- |
 2   |  2.0  3.0  |   4.0  5.0  |   2.0  2.0  |   2.0  2.0 |
     *                                                     *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:

p,q  |          0           |           1
-----|----------------------|----------------------
     |  0.0  1.0  7.0  8.0  |   1.0  5.0  8.0  8.0
     | -1.0  0.0  0.0 -1.0  |   0.0  0.0  0.0  1.0
 0   | -1.0  0.0  0.0  0.0  |   0.0  1.0 -2.0  0.0
     |  0.0  0.0 -1.0 -1.0  |  -1.0  0.0  0.0  1.0
     |  2.0  3.0  2.0  2.0  |   4.0  5.0  2.0  2.0
-----|----------------------|----------------------
     | -1.0  2.0  0.0  1.0  |   0.0  1.0 -1.0  0.0
     | -1.0  4.0 -1.0  0.0  |   0.0  1.0  0.0  0.0
 1   |  0.0  4.0  1.0  0.0  |   2.0  0.0  0.0 -1.0
     |  1.0  6.0  0.0  0.0  |   0.0  1.0  1.0  0.0

Example 2

This example computes C = betaC+alphaAH using a 2 × 2 process grid.

Call Statements and Input


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)
 
               M    N     ALPHA    A  IA  JA    DESC_A    BETA    C  IC  JC   DESC_C
               |    |       |      |   |   |      |         |     |   |   |     |
CALL PZTRANC(  7  , 8  ,  ALPHA  , A , 1 , 1 ,  DESC_A ,  BETA  , C , 1 , 1 , DESC_C )
 
               ALPHA = (1.0,0.0)
 
               BETA  = (1.0,0.0)    


Desc_A Desc_C
DTYPE_ 1 1
CTXT_ icontxt(IOBG33) icontxt(IOBG33)
M_ 8 7
N_ 7 8
MB_ 2 3
NB_ 3 2
RSRC_ 0 0
CSRC_ 0 0
LLD_ See below(EPSSL33) See below(EPSSL33)

Notes:

  1. icontxt is the output of the BLACS_GRIDINIT call.

  2. Each process should set the LLD_ as follows:
    LLD_A = MAX(1,NUMROC(M_A, MB_A, MYROW, RSRC_A, NPROW))
    LLD_C = MAX(1,NUMROC(M_C, MB_C, MYROW, RSRC_C, NPROW))
    

    In this example, LLD_A = 4 on all processes, LLD_C = 4 on P00 and P01, and LLD_C = 3 on P10 and P11.

Global general 8 × 7 matrix A with block size 2 × 3:


B,D                     0                                     1                         2
     *                                                                                         *
 0   | ( 0.0, 1.0) (-1.0, 0.0) (-1.0, 0.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) | ( 1.0, 2.0) ( 0.0, 1.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 1   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 1.0, 2.0) |
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) | (-1.0, 0.0) ( 1.0, 2.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 2   | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 1.0, 2.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 3   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | (-1.0, 0.0) |
     *                                                                                         *

The following is the 2 × 2 process grid:

B,D  |   0 2   |  1  
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11
3    |         |

Local arrays for A:


p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------
     | ( 0.0, 1.0) (-1.0, 0.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0)
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 1.0, 2.0) ( 0.0, 1.0) ( 1.0, 2.0)
 0   | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0)
     | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 1.0, 2.0) ( 1.0, 2.0)
-----|-------------------------------------------------|------------------------------------
     | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) ( 1.0, 2.0) | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0)
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | (-1.0, 0.0) ( 1.0, 2.0) ( 1.0, 2.0)
 1   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0)
     | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0)

Global general 7 × 8 matrix C with block size 3 × 2:



B,D               0                         1                         2                         3
     *                                                                                                       *
     | ( 0.0,-2.0) ( 1.0,-1.0) | ( 1.0,-1.0) ( 5.0, 3.0) | ( 6.0, 4.0) ( 7.0, 5.0) | ( 8.0, 6.0) ( 9.0, 7.0) |
 0   | ( 1.0,-1.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) |
     | ( 2.0, 0.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 1.0,-1.0) | ( 2.0, 0.0) ( 3.0, 1.0) | (-1.0,-3.0) ( 0.0,-2.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
     | ( 3.0, 1.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) | (-1.0,-3.0) (-1.0,-3.0) | ( 3.0, 1.0) ( 1.0,-1.0) |
 1   | (-1.0,-3.0) ( 2.0, 0.0) | ( 0.0,-2.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 1.0,-1.0) | ( 2.0, 0.0) ( 0.0,-2.0) |
     | (-1.0,-3.0) ( 3.0, 1.0) | ( 0.0,-2.0) ( 0.0,-2.0) | (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 0.0,-2.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
 2   | ( 5.0, 3.0) ( 4.0, 2.0) | ( 1.0,-1.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 0.0,-2.0) | ( 0.0,-2.0) ( 0.0,-2.0) |
     *                                                                                                       *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:



p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------------------
     | ( 0.0,-2.0) ( 1.0,-1.0) ( 6.0, 4.0) ( 7.0, 5.0) | ( 1.0,-1.0) ( 5.0, 3.0) ( 8.0, 6.0) ( 9.0, 7.0)
     | ( 1.0,-1.0) (-1.0,-3.0) ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) ( 0.0,-2.0) ( 1.0,-1.0)
 0   | ( 2.0, 0.0) ( 0.0,-2.0) ( 2.0, 0.0) ( 3.0, 1.0) | ( 1.0,-1.0) ( 1.0,-1.0) (-1.0,-3.0) ( 0.0,-2.0)
     | ( 5.0, 3.0) ( 4.0, 2.0) ( 1.0,-1.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0)
-----|-------------------------------------------------|------------------------------------------------
     | ( 3.0, 1.0) (-1.0,-3.0) (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) ( 3.0, 1.0) ( 1.0,-1.0)
 1   | (-1.0,-3.0) ( 2.0, 0.0) ( 1.0,-1.0) ( 1.0,-1.0) | ( 0.0,-2.0) ( 0.0,-2.0) ( 2.0, 0.0) ( 0.0,-2.0)
     | (-1.0,-3.0) ( 3.0, 1.0) (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0)

Output:

Global general 7 × 8 matrix C with block size 3 × 2:



B,D               0                         1                         2                         3
     *                                                                                                       *
     | ( 0.0,-3.0) ( 1.0,-2.0) | ( 1.0,-2.0) ( 5.0, 2.0) | ( 7.0, 2.0) ( 8.0, 3.0) | ( 8.0, 5.0) ( 8.0, 7.0) |
 0   | ( 0.0,-1.0) ( 0.0,-5.0) | ( 0.0,-3.0) ( 0.0,-5.0) | ( 0.0,-3.0) (-1.0,-4.0) | ( 0.0,-3.0) ( 1.0,-2.0) |
     | ( 1.0, 0.0) ( 0.0,-3.0) | ( 0.0,-1.0) ( 1.0,-2.0) | ( 2.0,-1.0) ( 3.0, 0.0) | (-2.0,-3.0) ( 0.0,-3.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
     | ( 3.0, 0.0) ( 0.0,-5.0) | (-1.0,-2.0) ( 0.0,-1.0) | (-1.0,-4.0) (-1.0,-4.0) | ( 3.0, 0.0) ( 1.0,-2.0) |
 1   | (-1.0,-4.0) ( 2.0,-1.0) | ( 0.0,-3.0) ( 1.0,-4.0) | ( 0.0,-1.0) ( 2.0,-3.0) | ( 1.0, 0.0) ( 0.0,-3.0) |
     | (-1.0,-4.0) ( 4.0,-1.0) | ( 0.0,-3.0) ( 1.0,-4.0) | (-1.0,-4.0) ( 0.0,-5.0) | ( 0.0,-3.0) ( 0.0,-3.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
 2   | ( 5.0, 2.0) ( 4.0, 1.0) | ( 2.0,-3.0) ( 0.0,-3.0) | ( 1.0,-2.0) ( 0.0,-3.0) | ( 0.0,-3.0) (-1.0,-2.0) |
     *                                                                                                       *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:



p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------------------
     | ( 0.0,-3.0) ( 1.0,-2.0) ( 7.0, 2.0) ( 8.0, 3.0) | ( 1.0,-2.0) ( 5.0, 2.0) ( 8.0, 5.0) ( 8.0, 7.0)
     | ( 0.0,-1.0) ( 0.0,-5.0) ( 0.0,-3.0) (-1.0,-4.0) | ( 0.0,-3.0) ( 0.0,-5.0) ( 0.0,-3.0) ( 1.0,-2.0)
 0   | ( 1.0, 0.0) ( 0.0,-3.0) ( 2.0,-1.0) ( 3.0, 0.0) | ( 0.0,-1.0) ( 1.0,-2.0) (-2.0,-3.0) ( 0.0,-3.0)
     | ( 5.0, 2.0) ( 4.0, 1.0) ( 1.0,-2.0) ( 0.0,-3.0) | ( 2.0,-3.0) ( 0.0,-3.0) ( 0.0,-3.0) (-1.0,-2.0)
-----|-------------------------------------------------|------------------------------------------------
     | ( 3.0, 0.0) ( 0.0,-5.0) (-1.0,-4.0) (-1.0,-4.0) | (-1.0,-2.0) ( 0.0,-1.0) ( 3.0, 0.0) ( 1.0,-2.0)
 1   | (-1.0,-4.0) ( 2.0,-1.0) ( 0.0,-1.0) ( 2.0,-3.0) | ( 0.0,-3.0) ( 1.0,-4.0) ( 1.0, 0.0) ( 0.0,-3.0)
     | (-1.0,-4.0) ( 4.0,-1.0) (-1.0,-4.0) ( 0.0,-5.0) | ( 0.0,-3.0) ( 1.0,-4.0) ( 0.0,-3.0) ( 0.0,-3.0)

Example 3

This example computes C = betaC+alphaAT using a 2 × 2 process grid.

Call Statements and Input


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)
 
               M    N     ALPHA    A  IA  JA    DESC_A    BETA    C  IC  JC   DESC_C
               |    |       |      |   |   |      |         |     |   |   |     |
CALL PZTRANU(  7  , 8  ,  ALPHA  , A , 1 , 1 ,  DESC_A ,  BETA  , C , 1 , 1 , DESC_C )
 
               ALPHA = (1.0,0.0)
 
               BETA  = (1.0,0.0)    


Desc_A Desc_C
DTYPE_ 1 1
CTXT_ icontxt(IOBG34) icontxt(IOBG34)
M_ 8 7
N_ 7 8
MB_ 2 3
NB_ 3 2
RSRC_ 0 0
CSRC_ 0 0
LLD_ See below(EPSSL34) See below(EPSSL34)

Notes:

  1. icontxt is the output of the BLACS_GRIDINIT call.

  2. Each process should set the LLD_ as follows:
    LLD_A = MAX(1,NUMROC(M_A, MB_A, MYROW, RSRC_A, NPROW))
    LLD_C = MAX(1,NUMROC(M_C, MB_C, MYROW, RSRC_C, NPROW))
    

    In this example, LLD_A = 4 on all processes, LLD_C = 4 on P00 and P01, and LLD_C = 3 on P10 and P11.

Global general 8 × 7 matrix A with block size 2 × 3:


B,D                     0                                     1                         2
     *                                                                                         *
 0   | ( 0.0, 1.0) (-1.0, 0.0) (-1.0, 0.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) | ( 1.0, 2.0) ( 0.0, 1.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 1   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 1.0, 2.0) |
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) | (-1.0, 0.0) ( 1.0, 2.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 2   | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 1.0, 2.0) ( 1.0, 2.0) | ( 0.0, 1.0) |
     | ------------------------------------|-------------------------------------|------------ |
 3   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) |
     | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | (-1.0, 0.0) |
     *                                                                                         *

The following is the 2 × 2 process grid:

B,D  |   0 2   |  1  
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11
3    |         |

Local arrays for A:


p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------
     | ( 0.0, 1.0) (-1.0, 0.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0)
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 1.0, 2.0) ( 0.0, 1.0) ( 1.0, 2.0)
 0   | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0)
     | ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0) | ( 0.0, 1.0) ( 1.0, 2.0) ( 1.0, 2.0)
-----|-------------------------------------------------|------------------------------------
     | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) ( 1.0, 2.0) | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0)
     | ( 0.0, 1.0) ( 1.0, 2.0) ( 0.0, 1.0) ( 0.0, 1.0) | (-1.0, 0.0) ( 1.0, 2.0) ( 1.0, 2.0)
 1   | ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0) | ( 0.0, 1.0) (-1.0, 0.0) ( 0.0, 1.0)
     | (-1.0, 0.0) ( 0.0, 1.0) ( 0.0, 1.0) (-1.0, 0.0) | ( 0.0, 1.0) ( 0.0, 1.0) ( 0.0, 1.0)

Global general 7 × 8 matrix C with block size 3 × 2:



B,D               0                         1                         2                         3
     *                                                                                                       *
     | ( 0.0,-2.0) ( 1.0,-1.0) | ( 1.0,-1.0) ( 5.0, 3.0) | ( 6.0, 4.0) ( 7.0, 5.0) | ( 8.0, 6.0) ( 9.0, 7.0) |
 0   | ( 1.0,-1.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) |
     | ( 2.0, 0.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 1.0,-1.0) | ( 2.0, 0.0) ( 3.0, 1.0) | (-1.0,-3.0) ( 0.0,-2.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
     | ( 3.0, 1.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) | (-1.0,-3.0) (-1.0,-3.0) | ( 3.0, 1.0) ( 1.0,-1.0) |
 1   | (-1.0,-3.0) ( 2.0, 0.0) | ( 0.0,-2.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 1.0,-1.0) | ( 2.0, 0.0) ( 0.0,-2.0) |
     | (-1.0,-3.0) ( 3.0, 1.0) | ( 0.0,-2.0) ( 0.0,-2.0) | (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 0.0,-2.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
 2   | ( 5.0, 3.0) ( 4.0, 2.0) | ( 1.0,-1.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 0.0,-2.0) | ( 0.0,-2.0) ( 0.0,-2.0) |
     *                                                                                                       *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:



p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------------------
     | ( 0.0,-2.0) ( 1.0,-1.0) ( 6.0, 4.0) ( 7.0, 5.0) | ( 1.0,-1.0) ( 5.0, 3.0) ( 8.0, 6.0) ( 9.0, 7.0)
     | ( 1.0,-1.0) (-1.0,-3.0) ( 0.0,-2.0) (-1.0,-3.0) | ( 0.0,-2.0) (-1.0,-3.0) ( 0.0,-2.0) ( 1.0,-1.0)
 0   | ( 2.0, 0.0) ( 0.0,-2.0) ( 2.0, 0.0) ( 3.0, 1.0) | ( 1.0,-1.0) ( 1.0,-1.0) (-1.0,-3.0) ( 0.0,-2.0)
     | ( 5.0, 3.0) ( 4.0, 2.0) ( 1.0,-1.0) ( 0.0,-2.0) | ( 1.0,-1.0) ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0)
-----|-------------------------------------------------|------------------------------------------------
     | ( 3.0, 1.0) (-1.0,-3.0) (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 1.0,-1.0) ( 3.0, 1.0) ( 1.0,-1.0)
 1   | (-1.0,-3.0) ( 2.0, 0.0) ( 1.0,-1.0) ( 1.0,-1.0) | ( 0.0,-2.0) ( 0.0,-2.0) ( 2.0, 0.0) ( 0.0,-2.0)
     | (-1.0,-3.0) ( 3.0, 1.0) (-1.0,-3.0) (-1.0,-3.0) | ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0) ( 0.0,-2.0)

Output:

Global general 7 × 8 matrix C with block size 3 × 2:



B,D               0                         1                         2                         3
     *                                                                                                       *
     | ( 0.0,-1.0) ( 1.0, 0.0) | ( 1.0, 0.0) ( 5.0, 4.0) | ( 7.0, 6.0) ( 8.0, 7.0) | ( 8.0, 7.0) ( 8.0, 7.0) |
 0   | ( 0.0,-1.0) ( 0.0,-1.0) | ( 0.0,-1.0) ( 0.0,-1.0) | ( 0.0,-1.0) (-1.0,-2.0) | ( 0.0,-1.0) ( 1.0, 0.0) |
     | ( 1.0, 0.0) ( 0.0,-1.0) | ( 0.0,-1.0) ( 1.0, 0.0) | ( 2.0, 1.0) ( 3.0, 2.0) | (-2.0,-3.0) ( 0.0,-1.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
     | ( 3.0, 2.0) ( 0.0,-1.0) | (-1.0,-2.0) ( 0.0,-1.0) | (-1.0,-2.0) (-1.0,-2.0) | ( 3.0, 2.0) ( 1.0, 0.0) |
 1   | (-1.0,-2.0) ( 2.0, 1.0) | ( 0.0,-1.0) ( 1.0, 0.0) | ( 0.0,-1.0) ( 2.0, 1.0) | ( 1.0, 0.0) ( 0.0,-1.0) |
     | (-1.0,-2.0) ( 4.0, 3.0) | ( 0.0,-1.0) ( 1.0, 0.0) | (-1.0,-2.0) ( 0.0,-1.0) | ( 0.0,-1.0) ( 0.0,-1.0) |
     | ------------------------|-------------------------|-------------------------|------------------------ |
 2   | ( 5.0, 4.0) ( 4.0, 3.0) | ( 2.0, 1.0) ( 0.0,-1.0) | ( 1.0, 0.0) ( 0.0,-1.0) | ( 0.0,-1.0) (-1.0,-2.0) |
     *                                                                                                       *

The following is the 2 × 2 process grid:

B,D  |   0 2   | 1 3 
-----| ------- |-----
0    |   P00   |  P01
2    |         |
-----| ------- |-----
1    |   P10   |  P11

Local arrays for C:



p,q  |                        0                        |                  1 
-----|-------------------------------------------------|------------------------------------------------
     | ( 0.0,-1.0) ( 1.0, 0.0) ( 7.0, 6.0) ( 8.0, 7.0) | ( 1.0, 0.0) ( 5.0, 4.0) ( 8.0, 7.0) ( 8.0, 7.0)
     | ( 0.0,-1.0) ( 0.0,-1.0) ( 0.0,-1.0) (-1.0,-2.0) | ( 0.0,-1.0) ( 0.0,-1.0) ( 0.0,-1.0) ( 1.0, 0.0)
 0   | ( 1.0, 0.0) ( 0.0,-1.0) ( 2.0, 1.0) ( 3.0, 2.0) | ( 0.0,-1.0) ( 1.0, 0.0) (-2.0,-3.0) ( 0.0,-1.0)
     | ( 5.0, 4.0) ( 4.0, 3.0) ( 1.0, 0.0) ( 0.0,-1.0) | ( 2.0, 1.0) ( 0.0,-1.0) ( 0.0,-1.0) (-1.0,-2.0)
-----|-------------------------------------------------|------------------------------------------------
     | ( 3.0, 2.0) ( 0.0,-1.0) (-1.0,-2.0) (-1.0,-2.0) | (-1.0,-2.0) ( 0.0,-1.0) ( 3.0, 2.0) ( 1.0, 0.0)
 1   | (-1.0,-2.0) ( 2.0, 1.0) ( 0.0,-1.0) ( 2.0, 1.0) | ( 0.0,-1.0) ( 1.0, 0.0) ( 1.0, 0.0) ( 0.0,-1.0)
     | (-1.0,-2.0) ( 4.0, 3.0) (-1.0,-2.0) ( 0.0,-1.0) | ( 0.0,-1.0) ( 1.0, 0.0) ( 0.0,-1.0) ( 0.0,-1.0)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]