14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 char * UPLO,
char * TRANS,
int N,
int K,
char * ALPHA,
22 char * A,
int IA,
int JA,
int * DESCA,
char * BETA,
23 char * C,
int IC,
int JC,
int * DESCC )
25 void PB_CpsyrkAC(
TYPE, DIRECA, CONJUG, UPLO, TRANS, N, K, ALPHA, A, IA,
26 JA, DESCA, BETA, C, IC, JC, DESCC )
30 char * CONJUG, * DIRECA, * TRANS, * UPLO;
31 int IA, IC, JA, JC, K, N;
274 char GatherDir, ScatterDir, * one, top, tran, * zero;
275 int Acol, Acurcol, Acurimb1, Acurinb1, Acurrow, Afr, Aii, Aimb,
276 Aimb1, Ainb, Ainb1, Ajj, Ald, Am, Amb, Amp, Amp0, An, Anb,
277 Anq, Anq0, Arow, Ccsrc, Cimb, Cinb, Cmb, Cnb, Crsrc, WAfr,
278 WCfr, WCsum, conjg, ctxt, fwd, k, kb, kbb, kend, kstart,
279 kstep, ktmp, mycol, myrow, notran, npcol, nprow, size, upper;
286 char * Aptr = NULL, * Aptr0 = NULL, * WA = NULL, * WC = NULL;
307 gsum2d =
TYPE->Cgsum2d; gemm =
TYPE->Fgemm;
314 kstart = 0; kend = ( ( N - 1 ) / kb + 1 ) * kb; kstep = kb;
319 kstart = ( ( N - 1 ) / kb ) * kb; kend = kstep = -kb;
325 if( notran ) { Am = N; An = K; }
else { Am = K; An = N; }
326 PB_Cinfog2l( IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aii, &Ajj,
328 Aimb = DESCA[
IMB_]; Ainb = DESCA[
INB_];
329 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ]; Ald = DESCA[
LLD_];
332 Amp0 =
PB_Cnumroc( Am, 0, Aimb1, Amb, myrow, Arow, nprow );
334 Anq0 =
PB_Cnumroc( An, 0, Ainb1, Anb, mycol, Acol, npcol );
335 if( ( Amp0 > 0 ) && ( Anq0 > 0 ) ) Aptr0 =
Mptr( A, Aii, Ajj, Ald, size );
340 Cinb = DESCC[
INB_]; Cnb = DESCC[
NB_]; Ccsrc = DESCC[
CSRC_];
344 for( k = kstart; k != kend; k += kstep )
346 kbb = N - k; kbb =
MIN( kbb, kb ); ktmp = k + kbb;
351 ROW, &Aptr, DBUFA, &Afr );
355 PB_Cdescset( Ad0, ktmp, An, Aimb1, Ainb1, Amb, Anb, Arow, Acol,
357 PB_CInV(
TYPE,
NOCONJG,
ROW, ktmp, An, Ad0, kbb, Aptr, 0, 0, DBUFA,
358 ROW, &WA, WAd, &WAfr );
362 PB_COutV(
TYPE,
COLUMN,
INIT, ktmp, An, Ad0, kbb, &WC, WCd, &WCfr,
364 Amp =
PB_Cnumroc( ktmp, 0, Aimb1, Amb, myrow, Arow, nprow );
365 if( ( Amp > 0 ) && ( Anq0 > 0 ) )
367 ALPHA, Aptr0, &Ald, WA, &WAd[
LLD_], zero, WC, &WCd[
LLD_] );
368 if( WAfr ) free( WA );
369 if( Afr ) free( Aptr );
374 Cnb, Ccsrc, Ccsrc, npcol );
376 gsum2d( ctxt,
ROW, &top, Amp, kbb, WC, WCd[
LLD_], myrow,
392 one, C, IC, JC+k, DESCC,
COLUMN );
393 if( WCfr ) free( WC );
398 for( k = kstart; k != kend; k += kstep )
400 ktmp = N - k; kbb =
MIN( ktmp, kb );
405 ROW, &Aptr, DBUFA, &Afr );
410 Acurrow =
PB_Cindxg2p( k, Aimb1, Amb, Arow, Arow, nprow );
411 PB_Cdescset( Ad0, ktmp, An, Acurimb1, Ainb1, Amb, Anb, Acurrow,
413 PB_CInV(
TYPE,
NOCONJG,
ROW, ktmp, An, Ad0, kbb, Aptr, 0, 0, DBUFA,
414 ROW, &WA, WAd, &WAfr );
418 PB_COutV(
TYPE,
COLUMN,
INIT, ktmp, An, Ad0, kbb, &WC, WCd, &WCfr,
420 Amp =
PB_Cnumroc( ktmp, k, Aimb1, Amb, myrow, Arow, nprow );
421 if( ( Amp > 0 ) && ( Anq0 > 0 ) )
423 ALPHA,
Mptr( Aptr0, Amp0-Amp, 0, Ald, size ), &Ald, WA,
425 if( WAfr ) free( WA );
426 if( Afr ) free( Aptr );
431 Cnb, Ccsrc, Ccsrc, npcol );
433 gsum2d( ctxt,
ROW, &top, Amp, kbb, WC, WCd[
LLD_], myrow,
449 one, C, IC+k, JC+k, DESCC,
COLUMN );
450 if( WCfr ) free( WC );
457 Cimb = DESCC[
IMB_]; Cmb = DESCC[
MB_]; Crsrc = DESCC[
RSRC_];
461 for( k = kstart; k != kend; k += kstep )
463 ktmp = N - k; kbb =
MIN( ktmp, kb );
468 COLUMN, &Aptr, DBUFA, &Afr );
473 Acurcol =
PB_Cindxg2p( k, Ainb1, Anb, Acol, Acol, npcol );
474 PB_Cdescset( Ad0, Am, ktmp, Aimb1, Acurinb1, Amb, Anb, Arow,
475 Acurcol, ctxt, Ald );
476 PB_CInV(
TYPE,
NOCONJG,
COLUMN, Am, ktmp, Ad0, kbb, Aptr, 0, 0,
477 DBUFA,
COLUMN, &WA, WAd, &WAfr );
481 PB_COutV(
TYPE,
ROW,
INIT, Am, ktmp, Ad0, kbb, &WC, WCd, &WCfr,
483 Anq =
PB_Cnumroc( ktmp, k, Ainb1, Anb, mycol, Acol, npcol );
484 if( ( Anq > 0 ) && ( Amp0 > 0 ) )
486 ALPHA, WA, &WAd[
LLD_],
Mptr( Aptr0, 0, Anq0-Anq, Ald,
487 size ), &Ald, zero, WC, &WCd[
LLD_] );
488 if( WAfr ) free( WA );
489 if( Afr ) free( Aptr );
494 Cmb, Crsrc, Crsrc, nprow );
496 gsum2d( ctxt,
COLUMN, &top, kbb, Anq, WC, WCd[
LLD_],
511 PB_CScatterV(
TYPE, &ScatterDir, kbb, ktmp, WC, 0, 0, WCd,
ROW, one,
512 C, IC+k, JC+k, DESCC,
ROW );
513 if( WCfr ) free( WC );
518 for( k = kstart; k != kend; k += kstep )
520 kbb = N - k; kbb =
MIN( kbb, kb ); ktmp = k + kbb;
525 COLUMN, &Aptr, DBUFA, &Afr );
529 PB_Cdescset( Ad0, Am, ktmp, Aimb1, Ainb1, Amb, Anb, Arow, Acol,
531 PB_CInV(
TYPE,
NOCONJG,
COLUMN, Am, ktmp, Ad0, kbb, Aptr, 0, 0,
532 DBUFA,
COLUMN, &WA, WAd, &WAfr );
536 PB_COutV(
TYPE,
ROW,
INIT, Am, ktmp, Ad0, kbb, &WC, WCd, &WCfr,
538 Anq =
PB_Cnumroc( ktmp, 0, Ainb1, Anb, mycol, Acol, npcol );
539 if( ( Anq > 0 ) && ( Amp0 > 0 ) )
541 ALPHA, WA, &WAd[
LLD_], Aptr0, &Ald, zero, WC, &WCd[
LLD_] );
542 if( WAfr ) free( WA );
543 if( Afr ) free( Aptr );
548 Cmb, Crsrc, Crsrc, nprow );
550 gsum2d( ctxt,
COLUMN, &top, kbb, Anq, WC, WCd[
LLD_],
565 PB_CScatterV(
TYPE, &ScatterDir, kbb, ktmp, WC, 0, 0, WCd,
ROW, one,
566 C, IC+k, JC, DESCC,
ROW );
567 if( WCfr ) free( WC );