SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pcmmch2()

subroutine pcmmch2 ( integer  ictxt,
character*1  uplo,
character*1  trans,
integer  n,
integer  k,
complex  alpha,
complex, dimension( * )  a,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
complex, dimension( * )  b,
integer  ib,
integer  jb,
integer, dimension( * )  descb,
complex  beta,
complex, dimension( * )  c,
complex, dimension( * )  pc,
integer  ic,
integer  jc,
integer, dimension( * )  descc,
complex, dimension( * )  ct,
real, dimension( * )  g,
real  err,
integer  info 
)

Definition at line 6165 of file pcblastst.f.

6168*
6169* -- PBLAS test routine (version 2.0) --
6170* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6171* and University of California, Berkeley.
6172* April 1, 1998
6173*
6174* .. Scalar Arguments ..
6175 CHARACTER*1 TRANS, UPLO
6176 INTEGER IA, IB, IC, ICTXT, INFO, JA, JB, JC, K, N
6177 REAL ERR
6178 COMPLEX ALPHA, BETA
6179* ..
6180* .. Array Arguments ..
6181 INTEGER DESCA( * ), DESCB( * ), DESCC( * )
6182 REAL G( * )
6183 COMPLEX A( * ), B( * ), C( * ), CT( * ),
6184 $ PC( * )
6185* ..
6186*
6187* Purpose
6188* =======
6189*
6190* PCMMCH2 checks the results of the computational tests.
6191*
6192* Notes
6193* =====
6194*
6195* A description vector is associated with each 2D block-cyclicly dis-
6196* tributed matrix. This vector stores the information required to
6197* establish the mapping between a matrix entry and its corresponding
6198* process and memory location.
6199*
6200* In the following comments, the character _ should be read as
6201* "of the distributed matrix". Let A be a generic term for any 2D
6202* block cyclicly distributed matrix. Its description vector is DESCA:
6203*
6204* NOTATION STORED IN EXPLANATION
6205* ---------------- --------------- ------------------------------------
6206* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
6207* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
6208* the NPROW x NPCOL BLACS process grid
6209* A is distributed over. The context
6210* itself is global, but the handle
6211* (the integer value) may vary.
6212* M_A (global) DESCA( M_ ) The number of rows in the distribu-
6213* ted matrix A, M_A >= 0.
6214* N_A (global) DESCA( N_ ) The number of columns in the distri-
6215* buted matrix A, N_A >= 0.
6216* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
6217* block of the matrix A, IMB_A > 0.
6218* INB_A (global) DESCA( INB_ ) The number of columns of the upper
6219* left block of the matrix A,
6220* INB_A > 0.
6221* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
6222* bute the last M_A-IMB_A rows of A,
6223* MB_A > 0.
6224* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
6225* bute the last N_A-INB_A columns of
6226* A, NB_A > 0.
6227* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
6228* row of the matrix A is distributed,
6229* NPROW > RSRC_A >= 0.
6230* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
6231* first column of A is distributed.
6232* NPCOL > CSRC_A >= 0.
6233* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
6234* array storing the local blocks of
6235* the distributed matrix A,
6236* IF( Lc( 1, N_A ) > 0 )
6237* LLD_A >= MAX( 1, Lr( 1, M_A ) )
6238* ELSE
6239* LLD_A >= 1.
6240*
6241* Let K be the number of rows of a matrix A starting at the global in-
6242* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
6243* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
6244* receive if these K rows were distributed over NPROW processes. If K
6245* is the number of columns of a matrix A starting at the global index
6246* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
6247* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
6248* these K columns were distributed over NPCOL processes.
6249*
6250* The values of Lr() and Lc() may be determined via a call to the func-
6251* tion PB_NUMROC:
6252* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
6253* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
6254*
6255* Arguments
6256* =========
6257*
6258* ICTXT (local input) INTEGER
6259* On entry, ICTXT specifies the BLACS context handle, indica-
6260* ting the global context of the operation. The context itself
6261* is global, but the value of ICTXT is local.
6262*
6263* UPLO (global input) CHARACTER*1
6264* On entry, UPLO specifies which part of C should contain the
6265* result.
6266*
6267* TRANS (global input) CHARACTER*1
6268* On entry, TRANS specifies whether the matrices A and B have
6269* to be transposed or not before computing the matrix-matrix
6270* product.
6271*
6272* N (global input) INTEGER
6273* On entry, N specifies the order the submatrix operand C. N
6274* must be at least zero.
6275*
6276* K (global input) INTEGER
6277* On entry, K specifies the number of columns (resp. rows) of A
6278* and B when TRANS = 'N' (resp. TRANS <> 'N'). K must be at
6279* least zero.
6280*
6281* ALPHA (global input) COMPLEX
6282* On entry, ALPHA specifies the scalar alpha.
6283*
6284* A (local input) COMPLEX array
6285* On entry, A is an array of dimension (DESCA( M_ ),*). This
6286* array contains a local copy of the initial entire matrix PA.
6287*
6288* IA (global input) INTEGER
6289* On entry, IA specifies A's global row index, which points to
6290* the beginning of the submatrix sub( A ).
6291*
6292* JA (global input) INTEGER
6293* On entry, JA specifies A's global column index, which points
6294* to the beginning of the submatrix sub( A ).
6295*
6296* DESCA (global and local input) INTEGER array
6297* On entry, DESCA is an integer array of dimension DLEN_. This
6298* is the array descriptor for the matrix A.
6299*
6300* B (local input) COMPLEX array
6301* On entry, B is an array of dimension (DESCB( M_ ),*). This
6302* array contains a local copy of the initial entire matrix PB.
6303*
6304* IB (global input) INTEGER
6305* On entry, IB specifies B's global row index, which points to
6306* the beginning of the submatrix sub( B ).
6307*
6308* JB (global input) INTEGER
6309* On entry, JB specifies B's global column index, which points
6310* to the beginning of the submatrix sub( B ).
6311*
6312* DESCB (global and local input) INTEGER array
6313* On entry, DESCB is an integer array of dimension DLEN_. This
6314* is the array descriptor for the matrix B.
6315*
6316* BETA (global input) COMPLEX
6317* On entry, BETA specifies the scalar beta.
6318*
6319* C (local input/local output) COMPLEX array
6320* On entry, C is an array of dimension (DESCC( M_ ),*). This
6321* array contains a local copy of the initial entire matrix PC.
6322*
6323* PC (local input) COMPLEX array
6324* On entry, PC is an array of dimension (DESCC( LLD_ ),*). This
6325* array contains the local pieces of the matrix PC.
6326*
6327* IC (global input) INTEGER
6328* On entry, IC specifies C's global row index, which points to
6329* the beginning of the submatrix sub( C ).
6330*
6331* JC (global input) INTEGER
6332* On entry, JC specifies C's global column index, which points
6333* to the beginning of the submatrix sub( C ).
6334*
6335* DESCC (global and local input) INTEGER array
6336* On entry, DESCC is an integer array of dimension DLEN_. This
6337* is the array descriptor for the matrix C.
6338*
6339* CT (workspace) COMPLEX array
6340* On entry, CT is an array of dimension at least MAX(M,N,K). CT
6341* holds a copy of the current column of C.
6342*
6343* G (workspace) REAL array
6344* On entry, G is an array of dimension at least MAX(M,N,K). G
6345* is used to compute the gauges.
6346*
6347* ERR (global output) REAL
6348* On exit, ERR specifies the largest error in absolute value.
6349*
6350* INFO (global output) INTEGER
6351* On exit, if INFO <> 0, the result is less than half accurate.
6352*
6353* -- Written on April 1, 1998 by
6354* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
6355*
6356* =====================================================================
6357*
6358* .. Parameters ..
6359 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
6360 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
6361 $ RSRC_
6362 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
6363 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
6364 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
6365 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
6366 REAL RZERO, RONE
6367 parameter( rzero = 0.0e+0, rone = 1.0e+0 )
6368 COMPLEX ZERO
6369 parameter( zero = ( 0.0e+0, 0.0e+0 ) )
6370* ..
6371* .. Local Scalars ..
6372 LOGICAL COLREP, HTRAN, NOTRAN, ROWREP, TRAN, UPPER
6373 INTEGER I, IBB, IBEG, ICCOL, ICROW, ICURROW, IEND, IIC,
6374 $ IN, IOFFAK, IOFFAN, IOFFBK, IOFFBN, IOFFC, J,
6375 $ JJC, KK, LDA, LDB, LDC, LDPC, MYCOL, MYROW,
6376 $ NPCOL, NPROW
6377 REAL EPS, ERRI
6378 COMPLEX Z
6379* ..
6380* .. External Subroutines ..
6381 EXTERNAL blacs_gridinfo, igsum2d, pb_infog2l, sgamx2d
6382* ..
6383* .. External Functions ..
6384 LOGICAL LSAME
6385 REAL PSLAMCH
6386 EXTERNAL lsame, pslamch
6387* ..
6388* .. Intrinsic Functions ..
6389 INTRINSIC abs, aimag, conjg, max, min, mod, real, sqrt
6390* ..
6391* .. Statement Functions ..
6392 REAL ABS1
6393 abs1( z ) = abs( real( z ) ) + abs( aimag( z ) )
6394* ..
6395* .. Executable Statements ..
6396*
6397 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
6398*
6399 eps = pslamch( ictxt, 'eps' )
6400*
6401 upper = lsame( uplo, 'U' )
6402 htran = lsame( trans, 'H' )
6403 notran = lsame( trans, 'N' )
6404 tran = lsame( trans, 'T' )
6405*
6406 lda = max( 1, desca( m_ ) )
6407 ldb = max( 1, descb( m_ ) )
6408 ldc = max( 1, descc( m_ ) )
6409*
6410* Compute expected result in C using data in A, B and C.
6411* Compute gauges in G. This part of the computation is performed
6412* by every process in the grid.
6413*
6414 DO 140 j = 1, n
6415*
6416 IF( upper ) THEN
6417 ibeg = 1
6418 iend = j
6419 ELSE
6420 ibeg = j
6421 iend = n
6422 END IF
6423*
6424 DO 10 i = 1, n
6425 ct( i ) = zero
6426 g( i ) = rzero
6427 10 CONTINUE
6428*
6429 IF( notran ) THEN
6430 DO 30 kk = 1, k
6431 ioffak = ia + j - 1 + ( ja + kk - 2 ) * lda
6432 ioffbk = ib + j - 1 + ( jb + kk - 2 ) * ldb
6433 DO 20 i = ibeg, iend
6434 ioffan = ia + i - 1 + ( ja + kk - 2 ) * lda
6435 ioffbn = ib + i - 1 + ( jb + kk - 2 ) * ldb
6436 ct( i ) = ct( i ) + alpha * (
6437 $ a( ioffan ) * b( ioffbk ) +
6438 $ b( ioffbn ) * a( ioffak ) )
6439 g( i ) = g( i ) + abs( alpha ) * (
6440 $ abs1( a( ioffan ) ) * abs1( b( ioffbk ) ) +
6441 $ abs1( b( ioffbn ) ) * abs1( a( ioffak ) ) )
6442 20 CONTINUE
6443 30 CONTINUE
6444 ELSE IF( tran ) THEN
6445 DO 50 kk = 1, k
6446 ioffak = ia + kk - 1 + ( ja + j - 2 ) * lda
6447 ioffbk = ib + kk - 1 + ( jb + j - 2 ) * ldb
6448 DO 40 i = ibeg, iend
6449 ioffan = ia + kk - 1 + ( ja + i - 2 ) * lda
6450 ioffbn = ib + kk - 1 + ( jb + i - 2 ) * ldb
6451 ct( i ) = ct( i ) + alpha * (
6452 $ a( ioffan ) * b( ioffbk ) +
6453 $ b( ioffbn ) * a( ioffak ) )
6454 g( i ) = g( i ) + abs( alpha ) * (
6455 $ abs1( a( ioffan ) ) * abs1( b( ioffbk ) ) +
6456 $ abs1( b( ioffbn ) ) * abs1( a( ioffak ) ) )
6457 40 CONTINUE
6458 50 CONTINUE
6459 ELSE IF( htran ) THEN
6460 DO 70 kk = 1, k
6461 ioffak = ia + j - 1 + ( ja + kk - 2 ) * lda
6462 ioffbk = ib + j - 1 + ( jb + kk - 2 ) * ldb
6463 DO 60 i = ibeg, iend
6464 ioffan = ia + i - 1 + ( ja + kk - 2 ) * lda
6465 ioffbn = ib + i - 1 + ( jb + kk - 2 ) * ldb
6466 ct( i ) = ct( i ) +
6467 $ alpha * a( ioffan ) * conjg( b( ioffbk ) ) +
6468 $ b( ioffbn ) * conjg( alpha * a( ioffak ) )
6469 g( i ) = g( i ) + abs1( alpha ) * (
6470 $ abs1( a( ioffan ) ) * abs1( b( ioffbk ) ) +
6471 $ abs1( b( ioffbn ) ) * abs1( a( ioffak ) ) )
6472 60 CONTINUE
6473 70 CONTINUE
6474 ELSE
6475 DO 90 kk = 1, k
6476 ioffak = ia + kk - 1 + ( ja + j - 2 ) * lda
6477 ioffbk = ib + kk - 1 + ( jb + j - 2 ) * ldb
6478 DO 80 i = ibeg, iend
6479 ioffan = ia + kk - 1 + ( ja + i - 2 ) * lda
6480 ioffbn = ib + kk - 1 + ( jb + i - 2 ) * ldb
6481 ct( i ) = ct( i ) +
6482 $ alpha * conjg( a( ioffan ) ) * b( ioffbk ) +
6483 $ conjg( alpha * b( ioffbn ) ) * a( ioffak )
6484 g( i ) = g( i ) + abs1( alpha ) * (
6485 $ abs1( conjg( a( ioffan ) ) * b( ioffbk ) ) +
6486 $ abs1( conjg( b( ioffbn ) ) * a( ioffak ) ) )
6487 80 CONTINUE
6488 90 CONTINUE
6489 END IF
6490*
6491 ioffc = ic + ibeg - 1 + ( jc + j - 2 ) * ldc
6492*
6493 DO 100 i = ibeg, iend
6494 ct( i ) = ct( i ) + beta * c( ioffc )
6495 g( i ) = g( i ) + abs1( beta )*abs1( c( ioffc ) )
6496 c( ioffc ) = ct( i )
6497 ioffc = ioffc + 1
6498 100 CONTINUE
6499*
6500* Compute the error ratio for this result.
6501*
6502 err = rzero
6503 info = 0
6504 ldpc = descc( lld_ )
6505 ioffc = ic + ( jc + j - 2 ) * ldc
6506 CALL pb_infog2l( ic, jc+j-1, descc, nprow, npcol, myrow, mycol,
6507 $ iic, jjc, icrow, iccol )
6508 icurrow = icrow
6509 rowrep = ( icrow.EQ.-1 )
6510 colrep = ( iccol.EQ.-1 )
6511*
6512 IF( mycol.EQ.iccol .OR. colrep ) THEN
6513*
6514 ibb = descc( imb_ ) - ic + 1
6515 IF( ibb.LE.0 )
6516 $ ibb = ( ( -ibb ) / descc( mb_ ) + 1 )*descc( mb_ ) + ibb
6517 ibb = min( ibb, n )
6518 in = ic + ibb - 1
6519*
6520 DO 110 i = ic, in
6521*
6522 IF( myrow.EQ.icurrow .OR. rowrep ) THEN
6523 erri = abs( pc( iic+(jjc-1)*ldpc ) -
6524 $ c( ioffc ) ) / eps
6525 IF( g( i-ic+1 ).NE.rzero )
6526 $ erri = erri / g( i-ic+1 )
6527 err = max( err, erri )
6528 IF( err*sqrt( eps ).GE.rone )
6529 $ info = 1
6530 iic = iic + 1
6531 END IF
6532*
6533 ioffc = ioffc + 1
6534*
6535 110 CONTINUE
6536*
6537 icurrow = mod( icurrow+1, nprow )
6538*
6539 DO 130 i = in+1, ic+n-1, descc( mb_ )
6540 ibb = min( ic+n-i, descc( mb_ ) )
6541*
6542 DO 120 kk = 0, ibb-1
6543*
6544 IF( myrow.EQ.icurrow .OR. rowrep ) THEN
6545 erri = abs( pc( iic+(jjc-1)*ldpc ) -
6546 $ c( ioffc ) )/eps
6547 IF( g( i+kk-ic+1 ).NE.rzero )
6548 $ erri = erri / g( i+kk-ic+1 )
6549 err = max( err, erri )
6550 IF( err*sqrt( eps ).GE.rone )
6551 $ info = 1
6552 iic = iic + 1
6553 END IF
6554*
6555 ioffc = ioffc + 1
6556*
6557 120 CONTINUE
6558*
6559 icurrow = mod( icurrow+1, nprow )
6560*
6561 130 CONTINUE
6562*
6563 END IF
6564*
6565* If INFO = 0, all results are at least half accurate.
6566*
6567 CALL igsum2d( ictxt, 'All', ' ', 1, 1, info, 1, -1, mycol )
6568 CALL sgamx2d( ictxt, 'All', ' ', 1, 1, err, 1, i, j, -1, -1,
6569 $ mycol )
6570 IF( info.NE.0 )
6571 $ GO TO 150
6572*
6573 140 CONTINUE
6574*
6575 150 CONTINUE
6576*
6577 RETURN
6578*
6579* End of PCMMCH2
6580*
subroutine pb_infog2l(i, j, desc, nprow, npcol, myrow, mycol, ii, jj, prow, pcol)
Definition pblastst.f:1673
real function pslamch(ictxt, cmach)
Definition pcblastst.f:7455
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
logical function lsame(ca, cb)
Definition tools.f:1724
Here is the call graph for this function:
Here is the caller graph for this function: