|
ScaLAPACK
2.0.2
ScaLAPACK: Scalable Linear Algebra PACKage
|
00001 /* --------------------------------------------------------------------- 00002 * 00003 * -- PBLAS routine (version 2.0) -- 00004 * University of Tennessee, Knoxville, Oak Ridge National Laboratory, 00005 * and University of California, Berkeley. 00006 * April 1, 1998 00007 * 00008 * --------------------------------------------------------------------- 00009 */ 00010 /* 00011 * Include files 00012 */ 00013 #include "pblas.h" 00014 #include "PBpblas.h" 00015 #include "PBtools.h" 00016 #include "PBblacs.h" 00017 #include "PBblas.h" 00018 00019 #ifdef __STDC__ 00020 void pstran_( int * M, int * N, 00021 float * ALPHA, 00022 float * A, int * IA, int * JA, int * DESCA, 00023 float * BETA, 00024 float * C, int * IC, int * JC, int * DESCC ) 00025 #else 00026 void pstran_( M, N, ALPHA, A, IA, JA, DESCA, BETA, C, IC, JC, DESCC ) 00027 /* 00028 * .. Scalar Arguments .. 00029 */ 00030 int * IA, * IC, * JA, * JC, * M, * N; 00031 float * ALPHA, * BETA; 00032 /* 00033 * .. Array Arguments .. 00034 */ 00035 int * DESCA, * DESCC; 00036 float * A, * C; 00037 #endif 00038 { 00039 /* 00040 * Purpose 00041 * ======= 00042 * 00043 * PSTRAN transposes a matrix 00044 * 00045 * sub( C ) := beta*sub( C ) + alpha*op( sub( A ) ) 00046 * 00047 * where 00048 * 00049 * sub( C ) denotes C(IC:IC+M-1,JC:JC+N-1), 00050 * 00051 * sub( A ) denotes A(IA:IA+N-1,JA:JA+M-1), and, op( X ) = X'. 00052 * 00053 * Thus, op( sub( A ) ) denotes A(IA:IA+N-1,JA:JA+M-1)'. 00054 * 00055 * Beta is a scalar, sub( C ) is an m by n submatrix, and sub( A ) is an 00056 * n by m submatrix. 00057 * 00058 * Notes 00059 * ===== 00060 * 00061 * A description vector is associated with each 2D block-cyclicly dis- 00062 * tributed matrix. This vector stores the information required to 00063 * establish the mapping between a matrix entry and its corresponding 00064 * process and memory location. 00065 * 00066 * In the following comments, the character _ should be read as 00067 * "of the distributed matrix". Let A be a generic term for any 2D 00068 * block cyclicly distributed matrix. Its description vector is DESC_A: 00069 * 00070 * NOTATION STORED IN EXPLANATION 00071 * ---------------- --------------- ------------------------------------ 00072 * DTYPE_A (global) DESCA[ DTYPE_ ] The descriptor type. 00073 * CTXT_A (global) DESCA[ CTXT_ ] The BLACS context handle, indicating 00074 * the NPROW x NPCOL BLACS process grid 00075 * A is distributed over. The context 00076 * itself is global, but the handle 00077 * (the integer value) may vary. 00078 * M_A (global) DESCA[ M_ ] The number of rows in the distribu- 00079 * ted matrix A, M_A >= 0. 00080 * N_A (global) DESCA[ N_ ] The number of columns in the distri- 00081 * buted matrix A, N_A >= 0. 00082 * IMB_A (global) DESCA[ IMB_ ] The number of rows of the upper left 00083 * block of the matrix A, IMB_A > 0. 00084 * INB_A (global) DESCA[ INB_ ] The number of columns of the upper 00085 * left block of the matrix A, 00086 * INB_A > 0. 00087 * MB_A (global) DESCA[ MB_ ] The blocking factor used to distri- 00088 * bute the last M_A-IMB_A rows of A, 00089 * MB_A > 0. 00090 * NB_A (global) DESCA[ NB_ ] The blocking factor used to distri- 00091 * bute the last N_A-INB_A columns of 00092 * A, NB_A > 0. 00093 * RSRC_A (global) DESCA[ RSRC_ ] The process row over which the first 00094 * row of the matrix A is distributed, 00095 * NPROW > RSRC_A >= 0. 00096 * CSRC_A (global) DESCA[ CSRC_ ] The process column over which the 00097 * first column of A is distributed. 00098 * NPCOL > CSRC_A >= 0. 00099 * LLD_A (local) DESCA[ LLD_ ] The leading dimension of the local 00100 * array storing the local blocks of 00101 * the distributed matrix A, 00102 * IF( Lc( 1, N_A ) > 0 ) 00103 * LLD_A >= MAX( 1, Lr( 1, M_A ) ) 00104 * ELSE 00105 * LLD_A >= 1. 00106 * 00107 * Let K be the number of rows of a matrix A starting at the global in- 00108 * dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows 00109 * that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would 00110 * receive if these K rows were distributed over NPROW processes. If K 00111 * is the number of columns of a matrix A starting at the global index 00112 * JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co- 00113 * lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if 00114 * these K columns were distributed over NPCOL processes. 00115 * 00116 * The values of Lr() and Lc() may be determined via a call to the func- 00117 * tion PB_Cnumroc: 00118 * Lr( IA, K ) = PB_Cnumroc( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW ) 00119 * Lc( JA, K ) = PB_Cnumroc( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL ) 00120 * 00121 * Arguments 00122 * ========= 00123 * 00124 * M (global input) INTEGER 00125 * On entry, M specifies the number of rows of the submatrix 00126 * sub( C ) and the number of columns of the submatrix sub( A ). 00127 * M must be at least zero. 00128 * 00129 * N (global input) INTEGER 00130 * On entry, N specifies the number of columns of the submatrix 00131 * sub( C ) and the number of rows of the submatrix sub( A ). N 00132 * must be at least zero. 00133 * 00134 * ALPHA (global input) REAL 00135 * On entry, ALPHA specifies the scalar alpha. When ALPHA is 00136 * supplied as zero then the local entries of the array A 00137 * corresponding to the entries of the submatrix sub( A ) need 00138 * not be set on input. 00139 * 00140 * A (local input) REAL array 00141 * On entry, A is an array of dimension (LLD_A, Ka), where Ka is 00142 * at least Lc( 1, JA+M-1 ). Before entry, this array contains 00143 * the local entries of the matrix A. 00144 * 00145 * IA (global input) INTEGER 00146 * On entry, IA specifies A's global row index, which points to 00147 * the beginning of the submatrix sub( A ). 00148 * 00149 * JA (global input) INTEGER 00150 * On entry, JA specifies A's global column index, which points 00151 * to the beginning of the submatrix sub( A ). 00152 * 00153 * DESCA (global and local input) INTEGER array 00154 * On entry, DESCA is an integer array of dimension DLEN_. This 00155 * is the array descriptor for the matrix A. 00156 * 00157 * BETA (global input) REAL 00158 * On entry, BETA specifies the scalar beta. When BETA is 00159 * supplied as zero then the local entries of the array C 00160 * corresponding to the entries of the submatrix sub( C ) need 00161 * not be set on input. 00162 * 00163 * C (local input/local output) REAL array 00164 * On entry, C is an array of dimension (LLD_C, Kc), where Kc is 00165 * at least Lc( 1, JC+N-1 ). Before entry, this array contains 00166 * the local entries of the matrix C. 00167 * On exit, the entries of this array corresponding to the local 00168 * entries of the submatrix sub( C ) are overwritten by the 00169 * local entries of the m by n updated submatrix. 00170 * 00171 * IC (global input) INTEGER 00172 * On entry, IC specifies C's global row index, which points to 00173 * the beginning of the submatrix sub( C ). 00174 * 00175 * JC (global input) INTEGER 00176 * On entry, JC specifies C's global column index, which points 00177 * to the beginning of the submatrix sub( C ). 00178 * 00179 * DESCC (global and local input) INTEGER array 00180 * On entry, DESCC is an integer array of dimension DLEN_. This 00181 * is the array descriptor for the matrix C. 00182 * 00183 * -- Written on April 1, 1998 by 00184 * Antoine Petitet, University of Tennessee, Knoxville 37996, USA. 00185 * 00186 * --------------------------------------------------------------------- 00187 */ 00188 /* 00189 * .. Local Scalars .. 00190 */ 00191 int Ai, Aj, Ci, Cj, ctxt, info, mycol, myrow, npcol, nprow; 00192 /* 00193 * .. Local Arrays .. 00194 */ 00195 int Ad[DLEN_], Cd[DLEN_]; 00196 /* .. 00197 * .. Executable Statements .. 00198 * 00199 */ 00200 PB_CargFtoC( *IA, *JA, DESCA, &Ai, &Aj, Ad ); 00201 PB_CargFtoC( *IC, *JC, DESCC, &Ci, &Cj, Cd ); 00202 #ifndef NO_ARGCHK 00203 /* 00204 * Test the input parameters 00205 */ 00206 Cblacs_gridinfo( ( ctxt = Ad[CTXT_] ), &nprow, &npcol, &myrow, &mycol ); 00207 if( !( info = ( ( nprow == -1 ) ? -( 701 + CTXT_ ) : 0 ) ) ) 00208 { 00209 PB_Cchkmat( ctxt, "PSTRAN", "A", *N, 2, *M, 1, Ai, Aj, Ad, 7, &info ); 00210 PB_Cchkmat( ctxt, "PSTRAN", "C", *M, 1, *N, 2, Ci, Cj, Cd, 12, &info ); 00211 } 00212 if( info ) { PB_Cabort( ctxt, "PSTRAN", info ); return; } 00213 #endif 00214 /* 00215 * Quick return if possible 00216 */ 00217 if( ( *M == 0 ) || ( *N == 0 ) || 00218 ( ( ALPHA[REAL_PART] == ZERO ) && ( BETA[REAL_PART] == ONE ) ) ) 00219 return; 00220 /* 00221 * And when alpha is zero 00222 */ 00223 if( ALPHA[REAL_PART] == ZERO ) 00224 { 00225 if( BETA[REAL_PART] == ZERO ) 00226 { 00227 PB_Cplapad( PB_Cstypeset(), ALL, NOCONJG, *M, *N, ((char *)BETA), 00228 ((char *)BETA), ((char *) C), Ci, Cj, Cd ); 00229 } 00230 else 00231 { 00232 PB_Cplascal( PB_Cstypeset(), ALL, NOCONJG, *M, *N, ((char *)BETA), 00233 ((char * )C), Ci, Cj, Cd ); 00234 } 00235 return; 00236 } 00237 /* 00238 * Start the operations 00239 */ 00240 PB_Cptran( PB_Cstypeset(), NOCONJG, *M, *N, ((char *) ALPHA), 00241 ((char *) A), Ai, Aj, Ad, ((char *) BETA), ((char *) C), 00242 Ci, Cj, Cd ); 00243 /* 00244 * End of PSTRAN 00245 */ 00246 }