OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
psgeqrrv.f
Go to the documentation of this file.
1 SUBROUTINE psgeqrrv( M, N, A, IA, JA, DESCA, TAU, WORK )
2*
3* -- ScaLAPACK routine (version 1.7) --
4* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5* and University of California, Berkeley.
6* May 28, 2001
7*
8* .. Scalar Arguments ..
9 INTEGER IA, JA, M, N
10* ..
11* .. Array Arguments ..
12 INTEGER DESCA( * )
13 REAL A( * ), TAU( * ), WORK( * )
14* ..
15*
16* Purpose
17* =======
18*
19* PSGEQRRV computes sub( A ) = A(IA:IA+M-1,JA:JA+N-1) from Q, R
20* computed by PSGEQRF.
21*
22* Notes
23* =====
24*
25* Each global data object is described by an associated description
26* vector. This vector stores the information required to establish
27* the mapping between an object element and its corresponding process
28* and memory location.
29*
30* Let A be a generic term for any 2D block cyclicly distributed array.
31* Such a global array has an associated description vector DESCA.
32* In the following comments, the character _ should be read as
33* "of the global array".
34*
35* NOTATION STORED IN EXPLANATION
36* --------------- -------------- --------------------------------------
37* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
38* DTYPE_A = 1.
39* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
40* the BLACS process grid A is distribu-
41* ted over. The context itself is glo-
42* bal, but the handle (the integer
43* value) may vary.
44* M_A (global) DESCA( M_ ) The number of rows in the global
45* array A.
46* N_A (global) DESCA( N_ ) The number of columns in the global
47* array A.
48* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
49* the rows of the array.
50* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
51* the columns of the array.
52* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
53* row of the array A is distributed.
54* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
55* first column of the array A is
56* distributed.
57* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
58* array. LLD_A >= MAX(1,LOCr(M_A)).
59*
60* Let K be the number of rows or columns of a distributed matrix,
61* and assume that its process grid has dimension p x q.
62* LOCr( K ) denotes the number of elements of K that a process
63* would receive if K were distributed over the p processes of its
64* process column.
65* Similarly, LOCc( K ) denotes the number of elements of K that a
66* process would receive if K were distributed over the q processes of
67* its process row.
68* The values of LOCr() and LOCc() may be determined via a call to the
69* ScaLAPACK tool function, NUMROC:
70* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
71* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
72* An upper bound for these quantities may be computed by:
73* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
74* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
75*
76* Arguments
77* =========
78*
79* M (global input) INTEGER
80* The number of rows to be operated on, i.e. the number of rows
81* of the distributed submatrix sub( A ). M >= 0.
82*
83* N (global input) INTEGER
84* The number of columns to be operated on, i.e. the number of
85* columns of the distributed submatrix sub( A ). N >= 0.
86*
87* A (local input/local output) REAL pointer into the
88* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
89* On entry, sub( A ) contains the the factors Q and R computed
90* by PSGEQRF. On exit, the original matrix is restored.
91*
92* IA (global input) INTEGER
93* The row index in the global array A indicating the first
94* row of sub( A ).
95*
96* JA (global input) INTEGER
97* The column index in the global array A indicating the
98* first column of sub( A ).
99*
100* DESCA (global and local input) INTEGER array of dimension DLEN_.
101* The array descriptor for the distributed matrix A.
102*
103* TAU (local input) REAL, array, dimension
104* LOCc(JA+MIN(M,N)-1). This array contains the scalar factors
105* TAU of the elementary reflectors computed by PSGEQRF. TAU
106* is tied to the distributed matrix A.
107*
108* WORK (local workspace) REAL array, dimension (LWORK)
109* LWORK = NB_A * ( 2*Mp0 + Nq0 + NB_A ), where
110* Mp0 = NUMROC( M+IROFF, MB_A, MYROW, IAROW, NPROW ) * NB_A,
111* Nq0 = NUMROC( N+ICOFF, NB_A, MYCOL, IACOL, NPCOL ) * MB_A,
112* IROFF = MOD( IA-1, MB_A ), ICOFF = MOD( JA-1, NB_A ),
113* IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ),
114* NPROW ),
115* IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
116* NPCOL ),
117* and NUMROC, INDXG2P are ScaLAPACK tool functions;
118* MYROW, MYCOL, NPROW and NPCOL can be determined by calling
119* the subroutine BLACS_GRIDINFO.
120*
121* =====================================================================
122*
123* .. Parameters ..
124 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
125 $ LLD_, MB_, M_, NB_, N_, RSRC_
126 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
127 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
128 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
129 REAL ONE, ZERO
130 parameter( one = 1.0e+0, zero = 0.0e+0 )
131* ..
132* .. Local Scalars ..
133 CHARACTER COLBTOP, ROWBTOP
134 INTEGER IACOL, IAROW, I, ICTXT, IIA, IPT, IPV, IPW,
135 $ IROFF, IV, J, JB, JJA, JL, JN, K, MP, MYCOL,
136 $ MYROW, NPCOL, NPROW
137* ..
138* .. Local Arrays ..
139 INTEGER DESCV( DLEN_ )
140* ..
141* .. External Subroutines ..
143 $ pslarfb, pslarft, pslaset, pb_topget,
144 $ pb_topset
145* ..
146* .. External Functions ..
147 INTEGER ICEIL, INDXG2P, NUMROC
148 EXTERNAL iceil, indxg2p, numroc
149* ..
150* .. Intrinsic Functions ..
151 INTRINSIC max, min, mod
152* ..
153* .. Executable Statements ..
154*
155* Get grid parameters
156*
157 ictxt = desca( ctxt_ )
158 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
159*
160 iroff = mod( ia-1, desca( mb_ ) )
161 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
162 $ iarow, iacol )
163 mp = numroc( m+iroff, desca( mb_ ), myrow, iarow, nprow )
164 ipv = 1
165 ipt = ipv + mp * desca( nb_ )
166 ipw = ipt + desca( nb_ ) * desca( nb_ )
167 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
168 CALL pb_topget( ictxt, 'broadcast', 'columnwise', COLBTOP )
169 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', 'd-ring' )
170 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', ' ' )
171*
172 K = MIN( M, N )
173 JN = MIN( ICEIL( JA, DESCA( NB_ ) ) * DESCA( NB_ ), JA+K-1 )
174 JL = MAX( ( (JA+K-2) / DESCA( NB_ ) ) * DESCA( NB_ ) + 1, JA )
175*
176 CALL DESCSET( DESCV, M+IROFF, DESCA( NB_ ), DESCA( MB_ ),
177 $ DESCA( NB_ ), IAROW, INDXG2P( JL, DESCA( NB_ ),
178 $ MYCOL, DESCA( CSRC_ ), NPCOL ), ICTXT,
179 $ MAX( 1, MP ) )
180*
181 DO 10 J = JL, JN+1, -DESCA( NB_ )
182 JB = MIN( JA+K-J, DESCA( NB_ ) )
183 I = IA + J - JA
184 IV = 1 + J - JA + IROFF
185*
186* Compute upper triangular matrix T
187*
188 CALL PSLARFT( 'forward', 'columnwise', M-I+IA, JB, A, I, J,
189 $ DESCA, TAU, WORK( IPT ), WORK( IPW ) )
190*
191* Copy Householder vectors into workspace
192*
193 CALL PSLACPY( 'lower', M-I+IA, JB, A, I, J, DESCA, WORK( IPV ),
194 $ IV, 1, DESCV )
195 CALL PSLASET( 'upper', M-I+IA, JB, ZERO, ONE, WORK( IPV ), IV,
196 $ 1, DESCV )
197*
198* Zeroes the strict lower triangular part of sub( A ) to get
199* block column of R
200*
201 CALL PSLASET( 'lower', M-I+IA-1, JB, ZERO, ZERO, A, I+1, J,
202 $ DESCA )
203*
204* Apply block Householder transformation
205*
206 CALL PSLARFB( 'left', 'no transpose', 'forward', 'columnwise',
207 $ M-I+IA, N-J+JA, JB, WORK( IPV ), IV, 1, DESCV,
208 $ WORK( IPT ), A, I, J, DESCA, WORK( IPW ) )
209*
210 DESCV( CSRC_ ) = MOD( DESCV( CSRC_ ) + NPCOL - 1, NPCOL )
211*
212 10 CONTINUE
213*
214* Handle first block separately
215*
216 JB = JN - JA + 1
217*
218* Compute upper triangular matrix T
219*
220 CALL PSLARFT( 'forward', 'columnwise', M, JB, A, IA, JA, DESCA,
221 $ TAU, WORK( IPT ), WORK( IPW ) )
222*
223* Copy Householder vectors into workspace
224*
225 CALL PSLACPY( 'lower', M, JB, A, IA, JA, DESCA, WORK( IPV ),
226 $ IROFF+1, 1, DESCV )
227 CALL PSLASET( 'upper', M, JB, ZERO, ONE, WORK, IROFF+1, 1, DESCV )
228*
229* Zeroes the strict lower triangular part of sub( A ) to get block
230* column of R
231*
232 CALL PSLASET( 'lower', M-1, JB, ZERO, ZERO, A, IA+1, JA, DESCA )
233*
234* Apply block Householder transformation
235*
236 CALL PSLARFB( 'left', 'no transpose', 'forward', 'columnwise', M,
237 $ N, JB, WORK( IPV ), IROFF+1, 1, DESCV, WORK( IPT ),
238 $ A, IA, JA, DESCA, WORK( IPW ) )
239*
240 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
241 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
242*
243 RETURN
244*
245* End of PSGEQRRV
246*
247 END
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21
subroutine descset(desc, m, n, mb, nb, irsrc, icsrc, ictxt, lld)
Definition mpi.f:1610
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition mpi.f:937
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
subroutine pslaset(uplo, m, n, alpha, beta, a, ia, ja, desca)
Definition psblastst.f:6863
subroutine psgeqrrv(m, n, a, ia, ja, desca, tau, work)
Definition psgeqrrv.f:2
subroutine pslacpy(uplo, m, n, a, ia, ja, desca, b, ib, jb, descb)
Definition pslacpy.f:3
subroutine pslarfb(side, trans, direct, storev, m, n, k, v, iv, jv, descv, t, c, ic, jc, descc, work)
Definition pslarfb.f:3
subroutine pslarft(direct, storev, n, k, v, iv, jv, descv, tau, t, work)
Definition pslarft.f:3