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__
PB_Cdescset(int * DESC,int M,int N,int IMB,int INB,int MB,int NB,int RSRC,int CSRC,int CTXT,int LLD)20 void PB_Cdescset( int * DESC, int M, int N, int IMB, int INB, int MB, int NB,
21                   int RSRC, int CSRC, int CTXT, int LLD )
22 #else
23 void PB_Cdescset( DESC, M, N, IMB, INB, MB, NB, RSRC, CSRC, CTXT, LLD )
24 /*
25 *  .. Scalar Arguments ..
26 */
27    int            CSRC, CTXT, IMB, INB, LLD, M, MB, N, NB, RSRC;
28 /*
29 *  .. Array Arguments ..
30 */
31    int            * DESC;
32 #endif
33 {
34 /*
35 *  Purpose
36 *  =======
37 *
38 *  PB_Cdescset uses  its  10  input  arguments  M,  N, IMB, INB, MB, NB,
39 *  RSRC,  CSRC,  CTXT  and LLD to initialize a descriptor vector of type
40 *  BLOCK_CYCLIC_2D_INB.
41 *
42 *  Notes
43 *  =====
44 *
45 *  A description  vector  is associated with each 2D block-cyclicly dis-
46 *  tributed matrix.  This  vector  stores  the  information  required to
47 *  establish the  mapping  between a  matrix entry and its corresponding
48 *  process and memory location.
49 *
50 *  In  the  following  comments,   the character _  should  be  read  as
51 *  "of  the  distributed  matrix".  Let  A  be a generic term for any 2D
52 *  block cyclicly distributed matrix.  Its description vector is DESC_A:
53 *
54 *  NOTATION         STORED IN       EXPLANATION
55 *  ---------------- --------------- ------------------------------------
56 *  DTYPE_A (global) DESCA[ DTYPE_ ] The descriptor type.
57 *  CTXT_A  (global) DESCA[ CTXT_  ] The BLACS context handle, indicating
58 *                                   the NPROW x NPCOL BLACS process grid
59 *                                   A  is  distributed over. The context
60 *                                   itself  is  global,  but  the handle
61 *                                   (the integer value) may vary.
62 *  M_A     (global) DESCA[ M_     ] The  number of rows in the distribu-
63 *                                   ted matrix A, M_A >= 0.
64 *  N_A     (global) DESCA[ N_     ] The number of columns in the distri-
65 *                                   buted matrix A, N_A >= 0.
66 *  IMB_A   (global) DESCA[ IMB_   ] The number of rows of the upper left
67 *                                   block of the matrix A, IMB_A > 0.
68 *  INB_A   (global) DESCA[ INB_   ] The  number  of columns of the upper
69 *                                   left   block   of   the  matrix   A,
70 *                                   INB_A > 0.
71 *  MB_A    (global) DESCA[ MB_    ] The blocking factor used to  distri-
72 *                                   bute the last  M_A-IMB_A  rows of A,
73 *                                   MB_A > 0.
74 *  NB_A    (global) DESCA[ NB_    ] The blocking factor used to  distri-
75 *                                   bute the last  N_A-INB_A  columns of
76 *                                   A, NB_A > 0.
77 *  RSRC_A  (global) DESCA[ RSRC_  ] The process row over which the first
78 *                                   row of the matrix  A is distributed,
79 *                                   NPROW > RSRC_A >= 0.
80 *  CSRC_A  (global) DESCA[ CSRC_  ] The  process column  over  which the
81 *                                   first column of  A  is  distributed.
82 *                                   NPCOL > CSRC_A >= 0.
83 *  LLD_A   (local)  DESCA[ LLD_   ] The  leading dimension  of the local
84 *                                   array  storing  the  local blocks of
85 *                                   the distributed matrix A,
86 *                                   IF( Lc( 1, N_A ) > 0 )
87 *                                      LLD_A >= MAX( 1, Lr( 1, M_A ) )
88 *                                   ELSE
89 *                                      LLD_A >= 1.
90 *
91 *  Let K be the number of  rows of a matrix A starting at the global in-
92 *  dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
93 *  that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
94 *  receive if these K rows were distributed over NPROW processes.  If  K
95 *  is the number of columns of a matrix  A  starting at the global index
96 *  JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number  of co-
97 *  lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would  receive if
98 *  these K columns were distributed over NPCOL processes.
99 *
100 *  The values of Lr() and Lc() may be determined via a call to the func-
101 *  tion PB_Cnumroc:
102 *  Lr( IA, K ) = PB_Cnumroc( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
103 *  Lc( JA, K ) = PB_Cnumroc( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
104 *
105 *  Arguments
106 *  =========
107 *
108 *  DESC    (global and local output) INTEGER array
109 *          On entry, DESC is an array of  dimension  DLEN_.  DESC is the
110 *          array descriptor to be set.
111 *
112 *  M       (global input) INTEGER
113 *          On entry,  M  specifies  the  number  of  rows of the matrix.
114 *          M must be at least zero.
115 *
116 *  N       (global input) INTEGER
117 *          On entry,  N  specifies  the number of columns of the matrix.
118 *          N must be at least zero.
119 *
120 *  IMB     (global input) INTEGER
121 *          On entry,  IMB  specifies  the row size of the first block of
122 *          the global matrix distribution. IMB must be at least one.
123 *
124 *  INB     (global input) INTEGER
125 *          On entry,  INB  specifies  the column size of the first block
126 *          of the global matrix distribution. INB must be at least one.
127 *
128 *  MB      (global input) INTEGER
129 *          On entry,  MB  specifies  the  row size of the blocks used to
130 *          partition the matrix. MB must be at least one.
131 *
132 *  NB      (global input) INTEGER
133 *          On entry, NB  specifies the column size of the blocks used to
134 *          partition the matrix. NB must be at least one.
135 *
136 *  RSRC    (global input) INTEGER
137 *          On entry,  RSRC  specifies  the row coordinate of the process
138 *          that possesses the first row of the matrix.  When  RSRC = -1,
139 *          the data is not  distributed but replicated,  otherwise  RSRC
140 *          must be at least zero and strictly less than NPROW.
141 *
142 *  CSRC    (global input) INTEGER
143 *          On entry,  CSRC  specifies  the column coordinate of the pro-
144 *          cess  that  possesses  the  first column of the matrix.  When
145 *          CSRC = -1, the data is not distributed but replicated, other-
146 *          wise CSRC must be at least zero and strictly less than NPCOL.
147 *
148 *  CTXT    (local input) INTEGER
149 *          On entry, CTXT specifies the BLACS context handle, indicating
150 *          the global  communication  context.  The value of the context
151 *          itself is local.
152 *
153 *  LLD     (local input)  INTEGER
154 *          On entry, LLD  specifies  the  leading dimension of the local
155 *          array storing the local entries of the matrix. LLD must be at
156 *          least MAX( 1, Lr(1,M) ).
157 *
158 *  -- Written on April 1, 1998 by
159 *     Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
160 *
161 *  ---------------------------------------------------------------------
162 */
163 /* ..
164 *  .. Executable Statements ..
165 *
166 */
167    DESC[DTYPE_] = BLOCK_CYCLIC_2D_INB;
168    DESC[CTXT_ ] = CTXT;
169    DESC[M_    ] = M;
170    DESC[N_    ] = N;
171    DESC[IMB_  ] = IMB;
172    DESC[INB_  ] = INB;
173    DESC[MB_   ] = MB;
174    DESC[NB_   ] = NB;
175    DESC[RSRC_ ] = RSRC;
176    DESC[CSRC_ ] = CSRC;
177    DESC[LLD_  ] = LLD;
178 /*
179 *  End of PB_Cdescset
180 */
181 }
182