ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pslafchk.f
Go to the documentation of this file.
1  SUBROUTINE pslafchk( AFORM, DIAG, M, N, A, IA, JA, DESCA, IASEED,
2  $ ANORM, FRESID, WORK )
3 *
4 * -- ScaLAPACK auxiliary routine (version 1.7) --
5 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6 * and University of California, Berkeley.
7 * May 1, 1997
8 *
9 * .. Scalar Arguments ..
10  CHARACTER AFORM, DIAG
11  INTEGER IA, IASEED, JA, M, N
12  REAL ANORM, FRESID
13 * ..
14 * .. Array Arguments ..
15  INTEGER DESCA( * )
16  REAL A( * ), WORK( * )
17 * ..
18 *
19 * Purpose
20 * =======
21 *
22 * PSLAFCHK computes the residual
23 * || sub( A ) - sub( Ao ) || / (|| sub( Ao ) ||*eps*MAX(M,N)),
24 * where Ao will be regenerated by the parallel random matrix generator,
25 * sub( A ) = A( IA:IA+M-1, JA:JA+N-1 ) and ||.|| stands for the infini-
26 * ty norm.
27 *
28 * Notes
29 * =====
30 *
31 * Each global data object is described by an associated description
32 * vector. This vector stores the information required to establish
33 * the mapping between an object element and its corresponding process
34 * and memory location.
35 *
36 * Let A be a generic term for any 2D block cyclicly distributed array.
37 * Such a global array has an associated description vector DESCA.
38 * In the following comments, the character _ should be read as
39 * "of the global array".
40 *
41 * NOTATION STORED IN EXPLANATION
42 * --------------- -------------- --------------------------------------
43 * DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
44 * DTYPE_A = 1.
45 * CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
46 * the BLACS process grid A is distribu-
47 * ted over. The context itself is glo-
48 * bal, but the handle (the integer
49 * value) may vary.
50 * M_A (global) DESCA( M_ ) The number of rows in the global
51 * array A.
52 * N_A (global) DESCA( N_ ) The number of columns in the global
53 * array A.
54 * MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
55 * the rows of the array.
56 * NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
57 * the columns of the array.
58 * RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
59 * row of the array A is distributed.
60 * CSRC_A (global) DESCA( CSRC_ ) The process column over which the
61 * first column of the array A is
62 * distributed.
63 * LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
64 * array. LLD_A >= MAX(1,LOCr(M_A)).
65 *
66 * Let K be the number of rows or columns of a distributed matrix,
67 * and assume that its process grid has dimension p x q.
68 * LOCr( K ) denotes the number of elements of K that a process
69 * would receive if K were distributed over the p processes of its
70 * process column.
71 * Similarly, LOCc( K ) denotes the number of elements of K that a
72 * process would receive if K were distributed over the q processes of
73 * its process row.
74 * The values of LOCr() and LOCc() may be determined via a call to the
75 * ScaLAPACK tool function, NUMROC:
76 * LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
77 * LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
78 * An upper bound for these quantities may be computed by:
79 * LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
80 * LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
81 *
82 * Arguments
83 * =========
84 *
85 * AFORM (global input) CHARACTER
86 * sub( A ) is overwritten with:
87 * - a symmetric matrix, if AFORM = 'S';
88 * - a Hermitian matrix, if AFORM = 'H';
89 * - the transpose of what would normally be generated,
90 * if AFORM = 'T';
91 * - the conjugate transpose of what would normally be
92 * generated, if AFORM = 'C';
93 * - otherwise a random matrix.
94 *
95 * DIAG (global input) CHARACTER
96 * if DIAG = 'D' : sub( A ) is diagonally dominant.
97 *
98 * M (global input) INTEGER
99 * The number of rows to be operated on, i.e. the number of rows
100 * of the distributed submatrix sub( A ). M >= 0.
101 *
102 * N (global input) INTEGER
103 * The number of columns to be operated on, i.e. the number of
104 * columns of the distributed submatrix sub( A ). N >= 0.
105 *
106 * A (local input/local output) REAL pointer into the
107 * local memory to an array of dimension (LLD_A,LOCc(JA+N-1)).
108 * On entry, this array contains the local pieces of the M-by-N
109 * distributed matrix sub( A ) to be checked. On exit, this
110 * array contains the local pieces of the difference
111 * sub( A ) - sub( Ao ).
112 *
113 * IA (global input) INTEGER
114 * The row index in the global array A indicating the first
115 * row of sub( A ).
116 *
117 * JA (global input) INTEGER
118 * The column index in the global array A indicating the
119 * first column of sub( A ).
120 *
121 * DESCA (global and local input) INTEGER array of dimension DLEN_.
122 * The array descriptor for the distributed matrix A.
123 *
124 * IASEED (global input) INTEGER
125 * The seed number to generate the original matrix Ao.
126 *
127 * ANORM (global input) REAL
128 * The Infinity norm of sub( A ).
129 *
130 * FRESID (global output) REAL
131 * The maximum (worst) factorizational error.
132 *
133 * WORK (local workspace) REAL array, dimension (LWORK).
134 * LWORK >= MpA0 * NB_A, where
135 *
136 * IROFFA = MOD( IA-1, MB_A ),
137 * IAROW = INDXG2P( IA, MB_A, MYROW, RSRC_A, NPROW ),
138 * MpA0 = NUMROC( M+IROFFA, MB_A, MYROW, IAROW, NPROW ),
139 *
140 * WORK is used to store a block of columns of sub( A ).
141 * INDXG2P and NUMROC are ScaLAPACK tool functions; MYROW,
142 * MYCOL, NPROW and NPCOL can be determined by calling the
143 * subroutine BLACS_GRIDINFO.
144 *
145 * =====================================================================
146 *
147 * .. Parameters ..
148  INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
149  $ lld_, mb_, m_, nb_, n_, rsrc_
150  parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
151  $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
152  $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
153  REAL ONE
154  parameter( one = 1.0e+0 )
155 * ..
156 * .. Local Scalars ..
157  INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IOFFA, IROFF,
158  $ jb, jj, jja, jn, lda, ldw, mp, mycol, myrow,
159  $ npcol, nprow, nq
160  REAL EPS
161 * ..
162 * .. External Subroutines ..
163  EXTERNAL blacs_gridinfo, infog2l, psmatgen, smatadd
164 * ..
165 * .. External Functions ..
166  INTEGER ICEIL, NUMROC
167  REAL PSLAMCH, PSLANGE
168  EXTERNAL iceil, numroc, pslamch, pslange
169 * ..
170 * .. Intrinsic Functions ..
171  INTRINSIC max, min, mod
172 * ..
173 * .. Executable Statements ..
174 *
175  ictxt = desca( ctxt_ )
176  CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
177  eps = pslamch( ictxt, 'eps' )
178  CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
179  $ iarow, iacol )
180 *
181 * Compute sub( A ) := sub( A ) - sub( Ao )
182 *
183  iroff = mod( ia-1, desca( mb_ ) )
184  icoff = mod( ja-1, desca( nb_ ) )
185  mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
186  nq = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
187  IF( myrow.EQ.iarow )
188  $ mp = mp-iroff
189  IF( mycol.EQ.iacol )
190  $ nq = nq-icoff
191  jn = min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
192  ldw = max( 1, mp )
193  lda = desca( lld_ )
194  ioffa = iia + ( jja - 1 )*lda
195 *
196 * Handle first block of columns separately
197 *
198  IF( mycol.EQ.iacol ) THEN
199  jb = jn-ja+1
200  CALL psmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
201  $ desca( mb_ ), desca( nb_ ), work, ldw,
202  $ desca( rsrc_ ), desca( csrc_ ), iaseed, iia-1,
203  $ mp, jja-1, jb, myrow, mycol, nprow, npcol )
204  CALL smatadd( mp, jb, -one, work, ldw, one, a( ioffa ), lda )
205  jja = jja + jb
206  nq = nq - jb
207  ioffa = ioffa + jb * lda
208  END IF
209 *
210 * Handle the remaning blocks of columns
211 *
212  DO 10 jj = jja, jja+nq-1, desca( nb_ )
213  jb = min( desca( nb_ ), jja+nq-jj )
214  ioffa = iia + ( jj - 1 ) * lda
215  CALL psmatgen( ictxt, aform, diag, desca( m_ ), desca( n_ ),
216  $ desca( mb_ ), desca( nb_ ), work, ldw,
217  $ desca( rsrc_ ), desca( csrc_ ), iaseed, iia-1,
218  $ mp, jj-1, jb, myrow, mycol, nprow, npcol )
219  CALL smatadd( mp, jb, -one, work, ldw, one, a( ioffa ), lda )
220  10 CONTINUE
221 *
222 * Calculate factor residual
223 *
224  fresid = pslange( 'I', m, n, a, ia, ja, desca, work ) /
225  $ ( max( m, n ) * eps * anorm )
226 *
227  RETURN
228 *
229 * End PSLAFCHK
230 *
231  END
pslafchk
subroutine pslafchk(AFORM, DIAG, M, N, A, IA, JA, DESCA, IASEED, ANORM, FRESID, WORK)
Definition: pslafchk.f:3
max
#define max(A, B)
Definition: pcgemr.c:180
infog2l
subroutine infog2l(GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW, MYCOL, LRINDX, LCINDX, RSRC, CSRC)
Definition: infog2l.f:3
smatadd
subroutine smatadd(M, N, ALPHA, A, LDA, BETA, C, LDC)
Definition: smatadd.f:2
psmatgen
subroutine psmatgen(ICTXT, AFORM, DIAG, M, N, MB, NB, A, LDA, IAROW, IACOL, ISEED, IROFF, IRNUM, ICOFF, ICNUM, MYROW, MYCOL, NPROW, NPCOL)
Definition: psmatgen.f:4
min
#define min(A, B)
Definition: pcgemr.c:181