ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
PB_Cdescribe.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2 *
3 * -- PBLAS auxiliary routine (version 2.0) --
4 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5 * and University of California, Berkeley.
6 * April 1, 1998
7 *
8 * ---------------------------------------------------------------------
9 */
10 /*
11 * Include files
12 */
13 #include "../pblas.h"
14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
18 
19 #ifdef __STDC__
20 void PB_Cdescribe( int M, int N, int IA, int JA, int * DA, int NPROW,
21  int NPCOL, int MYROW, int MYCOL, int * II, int * JJ,
22  int * LDA, int * IMB, int * INB, int * MB, int * NB,
23  int * PROW, int * PCOL, int * DA0 )
24 #else
25 void PB_Cdescribe( M, N, IA, JA, DA, NPROW, NPCOL, MYROW, MYCOL, II, JJ,
26  LDA, IMB, INB, MB, NB, PROW, PCOL, DA0 )
27 /*
28 * .. Scalar Arguments ..
29 */
30  int IA, *II, * IMB, * INB, JA, * JJ, * LDA, M, * MB, MYCOL,
31  MYROW, N, * NB, NPCOL, NPROW, * PCOL, * PROW;
32 /*
33 * .. Array Arguments ..
34 */
35  int * DA, * DA0;
36 #endif
37 {
38 /*
39 * Purpose
40 * =======
41 *
42 * PB_Cdescribe returns the global descriptor of a submatrix. This rou-
43 * tine also computes the starting local index II, JJ corresponding to
44 * the submatrix starting globally at the entry pointed by IA, JA. This
45 * routine returns the coordinates in the grid of the process owning the
46 * matrix entry of global indexes I, J, namely PROW and PCOL. The true
47 * global block sizes IMB, INB, MB and NB are also returned.
48 *
49 * Notes
50 * =====
51 *
52 * A description vector is associated with each 2D block-cyclicly dis-
53 * tributed matrix. This vector stores the information required to
54 * establish the mapping between a matrix entry and its corresponding
55 * process and memory location.
56 *
57 * In the following comments, the character _ should be read as
58 * "of the distributed matrix". Let A be a generic term for any 2D
59 * block cyclicly distributed matrix. Its description vector is DESC_A:
60 *
61 * NOTATION STORED IN EXPLANATION
62 * ---------------- --------------- ------------------------------------
63 * DTYPE_A (global) DESCA[ DTYPE_ ] The descriptor type.
64 * CTXT_A (global) DESCA[ CTXT_ ] The BLACS context handle, indicating
65 * the NPROW x NPCOL BLACS process grid
66 * A is distributed over. The context
67 * itself is global, but the handle
68 * (the integer value) may vary.
69 * M_A (global) DESCA[ M_ ] The number of rows in the distribu-
70 * ted matrix A, M_A >= 0.
71 * N_A (global) DESCA[ N_ ] The number of columns in the distri-
72 * buted matrix A, N_A >= 0.
73 * IMB_A (global) DESCA[ IMB_ ] The number of rows of the upper left
74 * block of the matrix A, IMB_A > 0.
75 * INB_A (global) DESCA[ INB_ ] The number of columns of the upper
76 * left block of the matrix A,
77 * INB_A > 0.
78 * MB_A (global) DESCA[ MB_ ] The blocking factor used to distri-
79 * bute the last M_A-IMB_A rows of A,
80 * MB_A > 0.
81 * NB_A (global) DESCA[ NB_ ] The blocking factor used to distri-
82 * bute the last N_A-INB_A columns of
83 * A, NB_A > 0.
84 * RSRC_A (global) DESCA[ RSRC_ ] The process row over which the first
85 * row of the matrix A is distributed,
86 * NPROW > RSRC_A >= 0.
87 * CSRC_A (global) DESCA[ CSRC_ ] The process column over which the
88 * first column of A is distributed.
89 * NPCOL > CSRC_A >= 0.
90 * LLD_A (local) DESCA[ LLD_ ] The leading dimension of the local
91 * array storing the local blocks of
92 * the distributed matrix A,
93 * IF( Lc( 1, N_A ) > 0 )
94 * LLD_A >= MAX( 1, Lr( 1, M_A ) )
95 * ELSE
96 * LLD_A >= 1.
97 *
98 * Let K be the number of rows of a matrix A starting at the global in-
99 * dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
100 * that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
101 * receive if these K rows were distributed over NPROW processes. If K
102 * is the number of columns of a matrix A starting at the global index
103 * JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
104 * lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
105 * these K columns were distributed over NPCOL processes.
106 *
107 * The values of Lr() and Lc() may be determined via a call to the func-
108 * tion PB_Cnumroc:
109 * Lr( IA, K ) = PB_Cnumroc( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
110 * Lc( JA, K ) = PB_Cnumroc( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
111 *
112 * Arguments
113 * =========
114 *
115 * M (global input) INTEGER
116 * On entry, M specifies the number of rows being dealt out
117 * starting from global index IA. M is also the number of rows
118 * of the submatrix of interest. M must be at least zero.
119 *
120 * N (global input) INTEGER
121 * On entry, N specifies the number of columns being dealt out
122 * starting from global index JA. N is also the number of col-
123 * umns of the submatrix of interest. M must be at least zero.
124 *
125 * IA (global input) INTEGER
126 * On entry, IA specifies the global starting row index of the
127 * submatrix. IA must at least zero.
128 *
129 * JA (global input) INTEGER
130 * On entry, JA specifies the global starting column index of
131 * the submatrix. JA must at least zero.
132 *
133 * DA (global and local input) INTEGER array
134 * On entry, DA is an integer array of dimension DLEN_. This is
135 * the array descriptor of the underlying matrix.
136 *
137 * NPROW (global input) INTEGER
138 * On entry, NPROW specifies the total number of process rows
139 * over which the matrix is distributed. NPROW must be at least
140 * one.
141 *
142 * NPCOL (global input) INTEGER
143 * On entry, NPCOL specifies the total number of process columns
144 * over which the matrix is distributed. NPCOL must be at least
145 * one.
146 *
147 * MYROW (local input) INTEGER
148 * On entry, MYROW specifies the row coordinate of the process
149 * whose local index II is determined. MYROW must be at least
150 * zero and strictly less than NPROW.
151 *
152 * II (local output) INTEGER
153 * On exit, II specifies the local starting row index of the
154 * submatrix. On exit, II is at least zero.
155 *
156 * JJ (local output) INTEGER
157 * On exit, JJ specifies the local starting column index of the
158 * submatrix. On exit, JJ is at least zero.
159 *
160 * LDA (local output) INTEGER
161 * On exit, LDA specifies the local leading dimension of the lo-
162 * cal array containing the distributed matrix entries. LDA must
163 * be at least one.
164 *
165 * IMB (global output) INTEGER
166 * On exit, IMB specifies the true global number of matrix rows
167 * of the first block, if M rows are given out starting from the
168 * global index IA. If M is equal zero, IMB is set to zero.
169 *
170 * INB (global output) INTEGER
171 * On exit, INB specifies the true global number of matrix col-
172 * umns of the first block, if N columns are given out starting
173 * from the global index JA. If N is equal zero, INB is set to
174 * zero.
175 *
176 * MB (global output) INTEGER
177 * On exit, MB specifies the size of the blocks used to parti-
178 * tion the matrix rows. MB is at least one.
179 *
180 * NB (global output) INTEGER
181 * On exit, NB specifies the size of the blocks used to parti-
182 * tion the matrix columns. NB is at least one.
183 *
184 * PROW (global output) INTEGER
185 * On exit, PROW specifies the row coordinate of the process
186 * that possesses the first row of the submatrix. On exit, PROW
187 * is -1 if DESC( RSRC_ ) is -1 on input, and, at least zero
188 * and strictly less than NPROW otherwise.
189 *
190 * PCOL (global output) INTEGER
191 * On exit, PCOL specifies the column coordinate of the process
192 * that possesses the first column of the submatrix. On exit,
193 * PCOL is -1 if DESC( CSRC_ ) is -1 on input, and, at least
194 * zero and strictly less than NPCOL otherwise.
195 *
196 * DA0 (global and local output) INTEGER array
197 * On exit, DA0 is an integer array of dimension DLEN_. This is
198 * the array descriptor of the submatrix A(IA:IA+M-1,JA:JA+N-1).
199 *
200 * -- Written on April 1, 1998 by
201 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
202 *
203 * ---------------------------------------------------------------------
204 */
205 /* ..
206 * .. Executable Statements ..
207 *
208 */
209  *MB = DA[MB_]; Mfirstnb( *IMB, M, IA, DA[IMB_], *MB );
210  *NB = DA[NB_]; Mfirstnb( *INB, N, JA, DA[INB_], *NB ); *LDA = DA[LLD_];
211  Minfog2l( IA, JA, DA, NPROW, NPCOL, MYROW, MYCOL, *II, *JJ, *PROW, *PCOL );
212  MDescSet( DA0, M, N, *IMB, *INB, *MB, *NB, *PROW, *PCOL, DA[CTXT_], *LDA );
213 /*
214 * End of PB_Cdescribe
215 */
216 }
MB_
#define MB_
Definition: PBtools.h:43
MDescSet
#define MDescSet(desc, m, n, imb, inb, mb, nb, rsrc, csrc, ictxt, lld)
Definition: PBtools.h:499
NB_
#define NB_
Definition: PBtools.h:44
LLD_
#define LLD_
Definition: PBtools.h:47
IMB_
#define IMB_
Definition: PBtools.h:41
PB_Cdescribe
void PB_Cdescribe(int M, int N, int IA, int JA, int *DA, int NPROW, int NPCOL, int MYROW, int MYCOL, int *II, int *JJ, int *LDA, int *IMB, int *INB, int *MB, int *NB, int *PROW, int *PCOL, int *DA0)
Definition: PB_Cdescribe.c:25
Minfog2l
#define Minfog2l(i_, j_, desc_, nr_, nc_, r_, c_, ii_, jj_, pr_, pc_)
Definition: PBtools.h:428
Mfirstnb
#define Mfirstnb(inbt_, n_, i_, inb_, nb_)
Definition: PBtools.h:139
INB_
#define INB_
Definition: PBtools.h:42
CTXT_
#define CTXT_
Definition: PBtools.h:38