ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pcsscal_.c
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2 *
3 * -- PBLAS 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 pcsscal_( int * N,
21  float * ALPHA,
22  float * X, int * IX, int * JX, int * DESCX, int * INCX )
23 #else
24 void pcsscal_( N, ALPHA, X, IX, JX, DESCX, INCX )
25 /*
26 * .. Scalar Arguments ..
27 */
28  int * INCX, * IX, * JX, * N;
29  float * ALPHA;
30 /*
31 * .. Array Arguments ..
32 */
33  int * DESCX;
34  float * X;
35 #endif
36 {
37 /*
38 * Purpose
39 * =======
40 *
41 * PCSSCAL multiplies an n element subvector sub( X ) by the real scalar
42 * alpha,
43 *
44 * where
45 *
46 * sub( X ) denotes X(IX,JX:JX+N-1) if INCX = M_X,
47 * X(IX:IX+N-1,JX) if INCX = 1 and INCX <> M_X.
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 * N (global input) INTEGER
116 * On entry, N specifies the length of the subvector sub( X ).
117 * N must be at least zero.
118 *
119 * ALPHA (global input) REAL
120 * On entry, ALPHA specifies the scalar alpha. When ALPHA is
121 * supplied as zero then the local entries of the array X cor-
122 * responding to the entries of the subvector sub( X ) need not
123 * be set on input.
124 *
125 * X (local input/local output) COMPLEX array
126 * On entry, X is an array of dimension (LLD_X, Kx), where LLD_X
127 * is at least MAX( 1, Lr( 1, IX ) ) when INCX = M_X and
128 * MAX( 1, Lr( 1, IX+N-1 ) ) otherwise, and, Kx is at least
129 * Lc( 1, JX+N-1 ) when INCX = M_X and Lc( 1, JX ) otherwise.
130 * Before entry, this array contains the local entries of the
131 * matrix X. On exit, sub( X ) is overwritten with the scaled
132 * subvector.
133 *
134 * IX (global input) INTEGER
135 * On entry, IX specifies X's global row index, which points to
136 * the beginning of the submatrix sub( X ).
137 *
138 * JX (global input) INTEGER
139 * On entry, JX specifies X's global column index, which points
140 * to the beginning of the submatrix sub( X ).
141 *
142 * DESCX (global and local input) INTEGER array
143 * On entry, DESCX is an integer array of dimension DLEN_. This
144 * is the array descriptor for the matrix X.
145 *
146 * INCX (global input) INTEGER
147 * On entry, INCX specifies the global increment for the
148 * elements of X. Only two values of INCX are supported in
149 * this version, namely 1 and M_X. INCX must not be zero.
150 *
151 * -- Written on April 1, 1998 by
152 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
153 *
154 * ---------------------------------------------------------------------
155 */
156 /*
157 * .. Local Scalars ..
158 */
159  int Xcol, Xi, Xii, Xj, Xjj, Xld, Xnp, Xnq, Xrow, ctxt, info,
160  mycol, myrow, npcol, nprow;
161  PBTYP_T * type;
162 /*
163 * .. Local Arrays ..
164 */
165  int Xd[DLEN_];
166 /* ..
167 * .. Executable Statements ..
168 *
169 */
170  PB_CargFtoC( *IX, *JX, DESCX, &Xi, &Xj, Xd );
171 #ifndef NO_ARGCHK
172 /*
173 * Test the input parameters
174 */
175  Cblacs_gridinfo( ( ctxt = Xd[CTXT_] ), &nprow, &npcol, &myrow, &mycol );
176  if( !( info = ( ( nprow == -1 ) ? -( 601 + CTXT_ ) : 0 ) ) )
177  PB_Cchkvec( ctxt, "PCSSCAL", "X", *N, 1, Xi, Xj, Xd, *INCX, 6, &info );
178  if( info ) { PB_Cabort( ctxt, "PCSSCAL", info ); return; }
179 #endif
180 /*
181 * Quick return if possible
182 */
183  if( ( *N == 0 ) || ( ALPHA[REAL_PART] == ONE ) ) return;
184 /*
185 * Retrieve process grid information
186 */
187 #ifdef NO_ARGCHK
188  Cblacs_gridinfo( Xd[CTXT_], &nprow, &npcol, &myrow, &mycol );
189 #endif
190 /*
191 * Retrieve sub( X )'s local information: Xii, Xjj, Xrow, Xcol
192 */
193  PB_Cinfog2l( Xi, Xj, Xd, nprow, npcol, myrow, mycol, &Xii, &Xjj, &Xrow,
194  &Xcol );
195 /*
196 * Start the operations
197 */
198  if( *INCX == Xd[M_] )
199  {
200 /*
201 * sub( X ) resides in (a) process row(s)
202 */
203  if( ( myrow == Xrow ) || ( Xrow < 0 ) )
204  {
205 /*
206 * Make sure I own some data and scale sub( X )
207 */
208  Xnq = PB_Cnumroc( *N, Xj, Xd[INB_], Xd[NB_], mycol, Xd[CSRC_], npcol );
209  if( Xnq > 0 )
210  {
211  Xld = Xd[LLD_];
212  type = PB_Cctypeset();
213  if( ALPHA[REAL_PART] == ZERO )
214  {
215  cset_( &Xnq, type->zero, Mptr( ((char *) X), Xii, Xjj, Xld,
216  type->size ), &Xld );
217  }
218  else
219  {
220  csscal_( &Xnq, ((char *) ALPHA), Mptr( ((char *) X),
221  Xii, Xjj, Xld, type->size ), &Xld );
222  }
223  }
224  }
225  return;
226  }
227  else
228  {
229 /*
230 * sub( X ) resides in (a) process column(s)
231 */
232  if( ( mycol == Xcol ) || ( Xcol < 0 ) )
233  {
234 /*
235 * Make sure I own some data and scale sub( X )
236 */
237  Xnp = PB_Cnumroc( *N, Xi, Xd[IMB_], Xd[MB_], myrow, Xd[RSRC_], nprow );
238  if( Xnp > 0 )
239  {
240  type = PB_Cctypeset();
241  if( ALPHA[REAL_PART] == ZERO )
242  {
243  cset_( &Xnp, type->zero, Mptr( ((char *) X), Xii, Xjj,
244  Xd[LLD_], type->size ), INCX );
245  }
246  else
247  {
248  csscal_( &Xnp, ((char *) ALPHA), Mptr( ((char *) X),
249  Xii, Xjj, Xd[LLD_], type->size ), INCX );
250  }
251  }
252  }
253  return;
254  }
255 /*
256 * End of PCSSCAL
257 */
258 }
M_
#define M_
Definition: PBtools.h:39
pcsscal_
void pcsscal_(int *N, float *ALPHA, float *X, int *IX, int *JX, int *DESCX, int *INCX)
Definition: pcsscal_.c:24
MB_
#define MB_
Definition: PBtools.h:43
NB_
#define NB_
Definition: PBtools.h:44
CSRC_
#define CSRC_
Definition: PBtools.h:46
PBblacs.h
PBtools.h
PBblas.h
REAL_PART
#define REAL_PART
Definition: pblas.h:135
PBpblas.h
DLEN_
#define DLEN_
Definition: PBtools.h:48
LLD_
#define LLD_
Definition: PBtools.h:47
csscal_
F_VOID_FCT csscal_()
ZERO
#define ZERO
Definition: PBtools.h:66
PB_Cchkvec
void PB_Cchkvec()
IMB_
#define IMB_
Definition: PBtools.h:41
PB_Cabort
void PB_Cabort()
ONE
#define ONE
Definition: PBtools.h:64
RSRC_
#define RSRC_
Definition: PBtools.h:45
PB_CargFtoC
void PB_CargFtoC()
PBTYP_T::size
int size
Definition: pblas.h:329
PB_Cinfog2l
void PB_Cinfog2l()
PB_Cnumroc
int PB_Cnumroc()
cset_
F_VOID_FCT cset_()
INB_
#define INB_
Definition: PBtools.h:42
Cblacs_gridinfo
void Cblacs_gridinfo()
PBTYP_T
Definition: pblas.h:325
pblas.h
Mptr
#define Mptr(a_, i_, j_, lda_, siz_)
Definition: PBtools.h:132
CTXT_
#define CTXT_
Definition: PBtools.h:38
PB_Cctypeset
PBTYP_T * PB_Cctypeset()
Definition: PB_Cctypeset.c:19
PBTYP_T::zero
char * zero
Definition: pblas.h:331