ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
PB_CVMinit.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_CVMinit( PB_VM_T * VM, int OFFD, int M, int N, int IMB1, int INB1,
21  int MB, int NB, int MRROW, int MRCOL, int NPROW,
22  int NPCOL, int LCMB )
23 #else
24 void PB_CVMinit( VM, OFFD, M, N, IMB1, INB1, MB, NB, MRROW, MRCOL, NPROW,
25  NPCOL, LCMB )
26 /*
27 * .. Scalar Arguments ..
28 */
29  int IMB1, INB1, LCMB, M, MB, MRCOL, MRROW, N, NB, NPCOL,
30  NPROW, OFFD;
31 /*
32 * .. Array Arguments ..
33 */
34  PB_VM_T * VM;
35 #endif
36 {
37 /*
38 * Purpose
39 * =======
40 *
41 * PB_CVMinit initializes a virtual matrix with the information of an m
42 * by n local array owned by the process of relative coordinates
43 * ( MRROW, MRCOL ).
44 *
45 * Arguments
46 * =========
47 *
48 * VM (local output) pointer to a PB_VM_T structure
49 * On entry, VM is a pointer to a structure of type PB_VM_T.
50 * On exit, VM points to the initialized structure containing
51 * the virtual matrix information (see pblas.h).
52 *
53 * OFFD (global input) INTEGER
54 * On entry, OFFD specifies the off-diagonal of the underlying
55 * matrix of interest as follows:
56 * OFFD = 0 specifies the main diagonal,
57 * OFFD > 0 specifies lower subdiagonals, and
58 * OFFD < 0 specifies upper superdiagonals.
59 *
60 * M (local input) INTEGER
61 * On entry, M specifies the local number of rows of the under-
62 * lying matrix owned by the process of relative coordinates
63 * ( MRROW, MRCOL ). M must be at least zero.
64 *
65 * N (local input) INTEGER
66 * On entry, N specifies the local number of columns of the un-
67 * derlying matrix owned by the process of relative coordinates
68 * ( MRROW, MRCOL ). N must be at least zero.
69 *
70 * IMB1 (global input) INTEGER
71 * On input, IMB1 specifies the global true size of the first
72 * block of rows of the underlying global submatrix. IMB1 must
73 * be at least MIN( 1, M ).
74 *
75 * INB1 (global input) INTEGER
76 * On input, INB1 specifies the global true size of the first
77 * block of columns of the underlying global submatrix. INB1
78 * must be at least MIN( 1, N ).
79 *
80 * MB (global input) INTEGER
81 * On entry, MB specifies the blocking factor used to partition
82 * the rows of the matrix. MB must be at least one.
83 *
84 * NB (global input) INTEGER
85 * On entry, NB specifies the blocking factor used to partition
86 * the the columns of the matrix. NB must be at least one.
87 *
88 * MRROW (local input) INTEGER
89 * On entry, MRROW specifies the relative row coordinate of the
90 * process that possesses these M rows. MRROW must be least zero
91 * and strictly less than NPROW.
92 *
93 * MRCOL (local input) INTEGER
94 * On entry, MRCOL specifies the relative column coordinate of
95 * the process that possesses these N columns. MRCOL must be
96 * least zero and strictly less than NPCOL.
97 *
98 * NPROW (global input) INTEGER
99 * On entry, NPROW specifies the total number of process rows
100 * over which the matrix is distributed. NPROW must be at least
101 * one.
102 *
103 * NPCOL (global input) INTEGER
104 * On entry, NPCOL specifies the total number of process col-
105 * umns over which the matrix is distributed. NPCOL must be at
106 * least one.
107 *
108 * LCMB (global input) INTEGER
109 * On entry, LCMB specifies the least common multiple of
110 * NPROW * MB and NPCOL * NB.
111 *
112 * -- Written on April 1, 1998 by
113 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
114 *
115 * ---------------------------------------------------------------------
116 */
117 /*
118 * .. Local Scalars ..
119 */
120  int tmp1;
121 /* ..
122 * .. Executable Statements ..
123 *
124 */
125 /*
126 * Initialize the fields of the VM structure
127 */
128  VM->offd = OFFD;
129  VM->lcmt00 = OFFD;
130  VM->mp = M; VM->imb1 = IMB1; VM->mb = MB; VM->upp = MB - 1;
131  VM->prow = MRROW; VM->nprow = NPROW;
132  VM->nq = N; VM->inb1 = INB1; VM->nb = NB; VM->low = 1 - NB;
133  VM->pcol = MRCOL; VM->npcol = NPCOL;
134  VM->lcmb = LCMB;
135 
136  if( ( M <= 0 ) || ( N <= 0 ) )
137  {
138 /*
139 * If the local virtual array is empty, then simplify the remaining of the
140 * initialization.
141 */
142  VM->imbloc = 0; VM->lmbloc = 0; VM->mblks = 0;
143  VM->iupp = ( MRROW ? MB - 1 : ( IMB1 > 0 ? IMB1 - 1 : 0 ) );
144  VM->inbloc = 0; VM->lnbloc = 0; VM->nblks = 0;
145  VM->ilow = ( MRCOL ? 1 - NB : ( INB1 > 0 ? 1 - INB1 : 0 ) );
146  VM->lcmt00 += ( VM->low - VM->ilow + MRCOL * NB ) -
147  ( VM->iupp - VM->upp + MRROW * MB );
148  return;
149  }
150 
151  if( MRROW )
152  {
153 /*
154 * I am not in the first relative process row. Use the first local row block
155 * size MB to initialize the VM structure.
156 */
157  VM->lcmt00 -= IMB1 - MB + MRROW * MB;
158  VM->imbloc = MIN( M, MB );
159  VM->mblks = ( M - 1 ) / MB + 1;
160  VM->iupp = MB - 1;
161  VM->lmbloc = M - ( M / MB ) * MB;
162  if( !( VM->lmbloc ) ) VM->lmbloc = MB;
163 
164  if( MRCOL )
165  {
166 /*
167 * I am not in the first relative process column. Use the first local column
168 * block size NB to initialize the VM structure.
169 */
170  VM->inbloc = MIN( N, NB );
171  VM->ilow = 1 - NB;
172  VM->lcmt00 += INB1 - NB + MRCOL * NB;
173  VM->nblks = ( N - 1 ) / NB + 1;
174  VM->lnbloc = N - ( N / NB ) * NB;
175  if( !( VM->lnbloc ) ) VM->lnbloc = NB;
176  }
177  else
178  {
179 /*
180 * I am in the first relative process column. Use the first column block size
181 * INB1 to initialize the VM structure.
182 */
183  VM->inbloc = INB1;
184  VM->ilow = 1 - INB1;
185  tmp1 = N - INB1;
186  if( tmp1 )
187  {
188 /*
189 * There is more than one column block. Compute the number of local column
190 * blocks and the size of the last one.
191 */
192  VM->nblks = ( tmp1 - 1 ) / NB + 2;
193  VM->lnbloc = tmp1 - ( tmp1 / NB ) * NB;
194  if( !( VM->lnbloc ) ) VM->lnbloc = NB;
195  }
196  else
197  {
198 /*
199 * There is only one column block.
200 */
201  VM->nblks = 1;
202  VM->lnbloc = INB1;
203  }
204  }
205  }
206  else
207  {
208 /*
209 * I am in the first relative process row. Use the first row block size IMB1 to
210 * initialize the VM structure.
211 */
212  VM->imbloc = IMB1;
213  VM->iupp = IMB1 - 1;
214  tmp1 = M - IMB1;
215  if( tmp1 )
216  {
217 /*
218 * There is more than one row block. Compute the number of local row blocks and
219 * the size of the last one.
220 */
221  VM->mblks = ( tmp1 - 1 ) / MB + 2;
222  VM->lmbloc = tmp1 - ( tmp1 / MB ) * MB;
223  if( !( VM->lmbloc ) ) VM->lmbloc = MB;
224  }
225  else
226  {
227 /*
228 * There is only one row block.
229 */
230  VM->mblks = 1;
231  VM->lmbloc = IMB1;
232  }
233  if( MRCOL )
234  {
235 /*
236 * I am not in the first relative process column. Use the first local column
237 * block size NB to initialize the VM structure.
238 */
239  VM->inbloc = MIN( N, NB );
240  VM->ilow = 1 - NB;
241  VM->lcmt00 += INB1 - NB + MRCOL * NB;
242  VM->nblks = ( N - 1 ) / NB + 1;
243  VM->lnbloc = N - ( N / NB ) * NB;
244  if( !( VM->lnbloc ) ) VM->lnbloc = NB;
245  }
246  else
247  {
248 /*
249 * I am in the first relative process column. Use the first column block size
250 * INB1 to initialize the VM structure.
251 */
252  VM->inbloc = INB1;
253  VM->ilow = 1 - INB1;
254  tmp1 = N - INB1;
255  if( tmp1 )
256  {
257 /*
258 * There is more than one column block. Compute the number of local column
259 * blocks and the size of the last one.
260 */
261  VM->nblks = ( tmp1 - 1 ) / NB + 2;
262  VM->lnbloc = tmp1 - ( tmp1 / NB ) * NB;
263  if( !( VM->lnbloc ) ) VM->lnbloc = NB;
264  }
265  else
266  {
267 /*
268 * There is only one column block.
269 */
270  VM->nblks = 1;
271  VM->lnbloc = INB1;
272  }
273  }
274  }
275 /*
276 * End of PB_CVMinit
277 */
278 }
PB_VM_T::lcmb
int lcmb
Definition: pblas.h:459
PB_VM_T::imb1
int imb1
Definition: pblas.h:438
PB_VM_T::pcol
int pcol
Definition: pblas.h:456
PB_VM_T::lcmt00
int lcmt00
Definition: pblas.h:435
PB_VM_T::inbloc
int inbloc
Definition: pblas.h:450
PB_VM_T::iupp
int iupp
Definition: pblas.h:443
PB_VM_T::mp
int mp
Definition: pblas.h:437
PB_VM_T::imbloc
int imbloc
Definition: pblas.h:439
PB_VM_T::prow
int prow
Definition: pblas.h:445
PB_VM_T::inb1
int inb1
Definition: pblas.h:449
PB_VM_T::low
int low
Definition: pblas.h:455
PB_VM_T::npcol
int npcol
Definition: pblas.h:457
PB_VM_T::nq
int nq
Definition: pblas.h:448
PB_VM_T::mblks
int mblks
Definition: pblas.h:442
PB_VM_T::lmbloc
int lmbloc
Definition: pblas.h:441
PB_VM_T::upp
int upp
Definition: pblas.h:444
PB_VM_T::nprow
int nprow
Definition: pblas.h:446
PB_VM_T::nblks
int nblks
Definition: pblas.h:453
PB_CVMinit
void PB_CVMinit(PB_VM_T *VM, int OFFD, int M, int N, int IMB1, int INB1, int MB, int NB, int MRROW, int MRCOL, int NPROW, int NPCOL, int LCMB)
Definition: PB_CVMinit.c:24
PB_VM_T
Definition: pblas.h:432
MIN
#define MIN(a_, b_)
Definition: PBtools.h:76
PB_VM_T::lnbloc
int lnbloc
Definition: pblas.h:452
PB_VM_T::ilow
int ilow
Definition: pblas.h:454
PB_VM_T::offd
int offd
Definition: pblas.h:434
PB_VM_T::mb
int mb
Definition: pblas.h:440
PB_VM_T::nb
int nb
Definition: pblas.h:451