14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 char * DIAG,
int M,
int N,
char * ALPHA,
char * A,
int IA,
22 int JA,
int * DESCA,
char * B,
int IB,
int JB,
int * DESCB,
23 char * C,
int * DESCC )
25 void PB_CptrsmAB1(
TYPE, SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, IA, JA,
26 DESCA, B, IB, JB, DESCB, C, DESCC )
30 char * DIAG, * SIDE, * TRANSA, * UPLO;
31 int IA, IB, JA, JB, M, N;
37 int * DESCA, * DESCB, * DESCC;
45 int Acol, Acurcol, Acurrow, Aii, Aimb, Aimb1, Ainb, Ainb1, Ajj,
46 Ald, Almb1, Alnb1, Amb, Amp0, An, Anb, Anq0, Anxtrow, Anxtcol,
47 Arow, Bcol, Bii, Bimb, Binb, Bjj, Bld, Bmb, Bmp0, Bnb, Bnq0,
48 Brow, Cld, ctxt, k=1, kb, kblks, lside, mycol, myrow, npcol,
58 char * Aptr = NULL, * Aptr0 = NULL, * Bptr = NULL, * Bptr0 = NULL,
74 PB_Cinfog2l( IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aii, &Ajj,
79 Bimb = DESCB[
IMB_]; Binb = DESCB[
INB_];
80 Bmb = DESCB[
MB_ ]; Bnb = DESCB[
NB_ ]; Bld = DESCB[
LLD_];
81 PB_Cinfog2l( IB, JB, DESCB, nprow, npcol, myrow, mycol, &Bii, &Bjj,
89 if( Bnq0 <= 0 )
return;
97 Bptr0 =
Mptr( B, Bii, Bjj, Bld, size );
98 TYPE->Fmmadd( &M, &Bnq0,
TYPE->negone, C, &DESCC[
LLD_], ALPHA,
102 Ajj, Ald, size ), &Ald, Bptr0, &Bld );
106 if( Bmp0 > 0 ) Bptr0 =
Mptr( B, Bii, Bjj, Bld, size );
111 if( Bmp0 <= 0 )
return;
119 Bptr0 =
Mptr( B, Bii, Bjj, Bld, size );
120 TYPE->Fmmadd( &Bmp0, &N,
TYPE->negone, C, &DESCC[
LLD_], ALPHA,
124 Ajj, Ald, size ), &Ald, Bptr0, &Bld );
128 if( Bnq0 > 0 ) Bptr0 =
Mptr( B, Bii, Bjj, Bld, size );
133 An = ( lside ? M : N );
135 negone =
TYPE->negone; one =
TYPE->one;
136 recv =
TYPE->Cgerv2d; send =
TYPE->Cgesd2d;
137 mmadd =
TYPE->Fmmadd; gemm =
TYPE->Fgemm; trsm =
TYPE->Ftrsm;
141 Aimb = DESCA[
IMB_]; Ainb = DESCA[
INB_];
142 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ];
145 Amp0 =
PB_Cnumroc( An, 0, Aimb1, Amb, myrow, Arow, nprow );
148 Anq0 =
PB_Cnumroc( An, 0, Ainb1, Anb, mycol, Acol, npcol );
149 if( ( Amp0 > 0 ) && ( Anq0 > 0 ) ) Aptr0 =
Mptr( A, Aii, Ajj, Ald, size );
155 kblks = ( An > Aimb1 ? ( An - Aimb1 - 1 ) / Amb + 2 : 1 );
160 Anxtrow =
MModAdd1( Acurrow, nprow );
167 kb = ( k == 1 ? Aimb1 : ( k == kblks ? Almb1 : Amb ) );
170 if( myrow == Acurrow )
176 mmadd( &kb, &Bnq0, negone, Cptr, &Cld, ALPHA, Bptr, &Bld );
181 C2F_CHAR( DIAG ), &kb, &Bnq0, one, Aptr, &Ald, Bptr,
191 one,
Mptr( Aptr, 0, kb, Ald, size ), &Ald, Bptr, &Bld,
192 one,
Mptr( Cptr, kb, 0, Cld, size ), &Cld );
193 send( ctxt, An, Bnq0,
Mptr( Cptr, kb, 0, Cld, size ), Cld,
196 Aptr =
Mptr( Aptr, kb, 0, Ald, size );
197 Bptr =
Mptr( Bptr, kb, 0, Bld, size );
200 else if( myrow == Anxtrow )
206 if( An > 0 ) recv( ctxt, An, Bnq0, Cptr, Cld, Acurrow, mycol );
209 Aptr =
Mptr( Aptr, 0, kb, Ald, size );
211 Anxtrow =
MModAdd1( Acurrow, nprow );
218 Acurrow =
PB_Cindxg2p( An-1, Aimb1, Amb, Arow, Arow, nprow );
219 Anxtrow =
MModSub1( Acurrow, nprow );
223 kb = ( k == 1 ? Aimb1 : ( k == kblks ? Almb1 : Amb ) );
226 if( myrow == Acurrow )
228 Aptr =
Mptr( Aptr0, Amp0 - kb, 0, Ald, size );
229 Bptr =
Mptr( Bptr0, Bmp0 - kb, 0, Bld, size );
230 Cptr =
Mptr( C, An, 0, Cld, size );
235 mmadd( &kb, &Bnq0, negone, Cptr, &Cld, ALPHA, Bptr, &Bld );
240 C2F_CHAR( DIAG ), &kb, &Bnq0, one,
Mptr( Aptr, 0, Anq0-kb,
241 Ald, size ), &Ald, Bptr, &Bld );
250 one, Aptr, &Ald, Bptr, &Bld, one, C, &Cld );
251 send( ctxt, An, Bnq0, C, Cld, Anxtrow, mycol );
256 else if( myrow == Anxtrow )
262 if( An > 0 ) recv( ctxt, An, Bnq0, C, Cld, Acurrow, mycol );
267 Anxtrow =
MModSub1( Acurrow, nprow );
274 kblks = ( An > Ainb1 ? ( An - Ainb1 - 1 ) / Anb + 2 : 1 );
279 Acurcol =
PB_Cindxg2p( An-1, Ainb1, Anb, Acol, Acol, npcol );
280 Anxtcol =
MModSub1( Acurcol, npcol );
284 kb = ( k == 1 ? Ainb1 : ( k == kblks ? Alnb1 : Anb ) );
287 if( mycol == Acurcol )
289 Aptr =
Mptr( Aptr0, 0, Anq0 - kb, Ald, size );
290 Bptr =
Mptr( Bptr0, 0, Bnq0 - kb, Bld, size );
291 Cptr =
Mptr( C, 0, An, Cld, size );
296 mmadd( &Bmp0, &kb, negone, Cptr, &Cld, ALPHA, Bptr, &Bld );
301 C2F_CHAR( DIAG ), &Bmp0, &kb, one,
Mptr( Aptr, Amp0-kb, 0,
302 Ald, size ), &Ald, Bptr, &Bld );
311 one, Bptr, &Bld, Aptr, &Ald, one, C, &Cld );
312 send( ctxt, Bmp0, An, C, Cld, myrow, Anxtcol );
317 else if( mycol == Anxtcol )
323 if( An > 0 ) recv( ctxt, Bmp0, An, C, Cld, myrow, Acurcol );
328 Anxtcol =
MModSub1( Acurcol, npcol );
335 Anxtcol =
MModAdd1( Acurcol, npcol );
342 kb = ( k == 1 ? Ainb1 : ( k == kblks ? Alnb1 : Anb ) );
345 if( mycol == Acurcol )
351 mmadd( &Bmp0, &kb, negone, Cptr, &Cld, ALPHA, Bptr, &Bld );
356 C2F_CHAR( DIAG ), &Bmp0, &kb, one, Aptr, &Ald, Bptr,
366 one, Bptr, &Bld,
Mptr( Aptr, kb, 0, Ald, size ), &Ald,
367 one,
Mptr( Cptr, 0, kb, Cld, size ), &Cld );
368 send( ctxt, Bmp0, An,
Mptr( Cptr, 0, kb, Cld, size ), Cld,
371 Aptr =
Mptr( Aptr, 0, kb, Ald, size );
372 Bptr =
Mptr( Bptr, 0, kb, Bld, size );
375 else if( mycol == Anxtcol )
381 if( An > 0 ) recv( ctxt, Bmp0, An, Cptr, Cld, myrow, Acurcol );
384 Aptr =
Mptr( Aptr, kb, 0, Ald, size );
386 Anxtcol =
MModAdd1( Acurcol, npcol );