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_CpsyrkA(
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;
275 int AcurrocR, Afwd, AiD, AiR, AiiD, AiiR, AinbD, AinbR, Ainb1D,
276 Ainb1R, AisR, Ald, AmyprocD, AmyprocR, AnbD, AnbR, AnpR,
277 AnprocsD, AnprocsR, ArocD, ArocR, Arocs, AsrcR, Ccol, Cii,
278 Cimb1, Cinb1, Cjj, Clcmb, Cld, Clp, Clq, Cnq0, Cmb, Cmp,
279 Cmp0, Cnb, Cnq, Crow, WACfr, WACld, WACsum, WARfr, WARld,
280 WARsum, Wkbb=0, ctxt, k, kb, kbb, l, lb, ltmp, maxp, mycol,
281 myrow, notran, npcol, nprow, p=0, size, tmp, upper;
288 char * Aptr = NULL, * Cptr = NULL, * WAC = NULL, * WAR = NULL;
307 PB_Cdescribe( N, N, IC, JC, DESCC, nprow, npcol, myrow, mycol, &Cii, &Cjj,
308 &Cld, &Cimb1, &Cinb1, &Cmb, &Cnb, &Crow, &Ccol, Cd0 );
310 Cmp =
PB_Cnumroc( N, 0, Cimb1, Cmb, myrow, Crow, nprow );
311 Cnq =
PB_Cnumroc( N, 0, Cinb1, Cnb, mycol, Ccol, npcol );
313 if( ( Cmp > 0 ) && ( Cnq > 0 ) )
315 Cptr =
Mptr( C, Cii, Cjj, Cld, size );
322 Clcmb = 2 * kb *
PB_Clcm( ( Crow >= 0 ? nprow : 1 ),
323 ( Ccol >= 0 ? npcol : 1 ) );
330 AiR = JA; AnprocsR = npcol; AinbR = DESCA[
INB_]; AnbR = DESCA[
NB_];
331 AsrcR = DESCA[
CSRC_];
335 AiR = IA; AnprocsR = nprow; AinbR = DESCA[
IMB_]; AnbR = DESCA[
MB_];
336 AsrcR = DESCA[
RSRC_];
342 if( !(
PB_Cspan( K, AiR, AinbR, AnbR, AsrcR, AnprocsR ) ) )
349 PB_CInV(
TYPE,
NOCONJG,
COLUMN, N, N, Cd0, K, A, IA, JA, DESCA,
350 COLUMN, &WAC, WACd0, &WACfr );
351 PB_CInV(
TYPE, CONJUG,
ROW, N, N, Cd0, K, WAC, 0, 0, WACd0,
352 COLUMN, &WAR, WARd0, &WARfr );
356 PB_CInV(
TYPE,
NOCONJG,
ROW, N, N, Cd0, K, A, IA, JA, DESCA,
357 ROW, &WAR, WARd0, &WARfr );
358 PB_CInV(
TYPE, CONJUG,
COLUMN, N, N, Cd0, K, WAR, 0, 0, WARd0,
359 ROW, &WAC, WACd0, &WACfr );
364 if( ( Cmp > 0 ) && ( Cnq > 0 ) )
366 WACld = WACd0[
LLD_]; WARld = WARd0[
LLD_];
370 for( l = 0; l < N; l += Clcmb )
372 lb = N - l; lb =
MIN( lb, Clcmb );
373 Clp =
PB_Cnumroc( l, 0, Cimb1, Cmb, myrow, Crow, nprow );
374 Clq =
PB_Cnumroc( l, 0, Cinb1, Cnb, mycol, Ccol, npcol );
375 Cnq0 =
PB_Cnumroc( lb, l, Cinb1, Cnb, mycol, Ccol, npcol );
376 if( Clp > 0 && Cnq0 > 0 )
378 ALPHA, WAC, &WACld,
Mptr( WAR, 0, Clq, WARld, size ),
379 &WARld, one,
Mptr( Cptr, 0, Clq, Cld, size ), &Cld );
381 size ), WACld,
Mptr( WAR, 0, Clq, WARld, size ), WARld,
382 Cptr, l, l, Cd0, tzsyrk );
387 for( l = 0; l < N; l += Clcmb )
389 lb = N - l; ltmp = l + ( lb =
MIN( lb, Clcmb ) );
390 Clp =
PB_Cnumroc( l, 0, Cimb1, Cmb, myrow, Crow, nprow );
391 Clq =
PB_Cnumroc( l, 0, Cinb1, Cnb, mycol, Ccol, npcol );
393 size ), WACld,
Mptr( WAR, 0, Clq, WARld, size ), WARld,
394 Cptr, l, l, Cd0, tzsyrk );
395 Clp =
PB_Cnumroc( ltmp, 0, Cimb1, Cmb, myrow, Crow, nprow );
397 Cnq0 =
PB_Cnumroc( lb, l, Cinb1, Cnb, mycol, Ccol, npcol );
398 if( Cmp0 > 0 && Cnq0 > 0 )
400 &K, ALPHA,
Mptr( WAC, Clp, 0, WACld, size ), &WACld,
401 Mptr( WAR, 0, Clq, WARld, size ), &WARld, one,
402 Mptr( Cptr, Clp, Clq, Cld, size ), &Cld );
407 if( WACfr ) free( WAC );
408 if( WARfr ) free( WAR );
420 AiD = IA; AinbD = DESCA[
IMB_]; AnbD = DESCA[
MB_]; Ald = DESCA[
LLD_];
421 AmyprocD = myrow; AmyprocR = mycol; AnprocsD = nprow;
422 PB_Cinfog2l( IA, JA, DESCA, AnprocsD, AnprocsR, AmyprocD, AmyprocR,
423 &AiiD, &AiiR, &ArocD, &ArocR );
427 AiD = JA; AinbD = DESCA[
INB_]; AnbD = DESCA[
NB_]; Ald = DESCA[
LLD_];
428 AmyprocD = mycol; AmyprocR = myrow; AnprocsD = npcol;
429 PB_Cinfog2l( IA, JA, DESCA, AnprocsR, AnprocsD, AmyprocR, AmyprocD,
430 &AiiR, &AiiD, &ArocR, &ArocD );
434 AisR = ( ( AsrcR < 0 ) || ( AnprocsR == 1 ) );
439 if( !( AisR ) && !( Afwd ) )
441 tmp =
PB_Cindxg2p( K - 1, Ainb1R, AnbR, ArocR, ArocR, AnprocsR );
442 p =
MModSub( tmp, ArocR, AnprocsR );
447 PB_COutV(
TYPE,
COLUMN,
NOINIT, N, N, Cd0, kb, &WAC, WACd0, &WACfr,
449 PB_COutV(
TYPE,
ROW,
NOINIT, N, N, Cd0, kb, &WAR, WARd0, &WARfr,
454 maxp = ( AisR ? 1 : AnprocsR );
455 AcurrocR = ( AisR ? -1 :
MModAdd( ArocR, p, AnprocsR ) );
456 AnpR =
PB_Cnumroc( K, 0, Ainb1R, AnbR, AcurrocR, ArocR, AnprocsR );
458 for( k = 0; k < K; k += kb )
460 kbb = K - k; kbb =
MIN( kbb, kb );
471 AcurrocR = ( AisR ? -1 :
MModAdd( ArocR, p, AnprocsR ) );
472 AnpR =
PB_Cnumroc( K, 0, Ainb1R, AnbR, AcurrocR, ArocR,
479 if( Wkbb == 0 ) { Arocs = ( AnpR < kbb ? AnpR : kbb ); }
480 else { Arocs = kbb - Wkbb; Arocs =
MIN( Arocs, AnpR ); }
487 if( AisR || ( AmyprocR == AcurrocR ) )
488 { Aptr =
Mptr( A, AiiD, AiiR, Ald, size ); AiiR += Arocs; }
489 PB_Cdescset( DBUFA, N, Arocs, Ainb1D, Arocs, AnbD, Arocs,
490 ArocD, AcurrocR, ctxt, Ald );
494 PB_CInV2(
TYPE,
NOCONJG,
COLUMN, N, N, Cd0, Arocs, Aptr, 0, 0,
495 DBUFA,
COLUMN, WAC, Wkbb, WACd0 );
499 if( AisR || ( AmyprocR == AcurrocR ) )
500 { Aptr =
Mptr( A, AiiR, AiiD, Ald, size ); AiiR += Arocs; }
501 PB_Cdescset( DBUFA, Arocs, N, Arocs, Ainb1D, Arocs, AnbD,
502 AcurrocR, ArocD, ctxt, Ald );
506 PB_CInV2(
TYPE,
NOCONJG,
ROW, N, N, Cd0, Arocs, Aptr, 0, 0,
507 DBUFA,
ROW, WAR, Wkbb, WARd0 );
523 PB_CInV2(
TYPE, CONJUG,
ROW, N, N, Cd0, kbb, WAC, 0, 0, WACd0,
531 PB_CInV2(
TYPE, CONJUG,
COLUMN, N, N, Cd0, kbb, WAR, 0, 0, WARd0,
532 ROW, WAC, 0, WACd0 );
537 if( ( Cmp > 0 ) && ( Cnq > 0 ) )
539 WACld = WACd0[
LLD_]; WARld = WARd0[
LLD_];
543 for( l = 0; l < N; l += Clcmb )
545 lb = N - l; lb =
MIN( lb, Clcmb );
546 Clp =
PB_Cnumroc( l, 0, Cimb1, Cmb, myrow, Crow, nprow );
547 Clq =
PB_Cnumroc( l, 0, Cinb1, Cnb, mycol, Ccol, npcol );
548 Cnq0 =
PB_Cnumroc( lb, l, Cinb1, Cnb, mycol, Ccol, npcol );
549 if( Clp > 0 && Cnq0 > 0 )
551 &kbb, ALPHA, WAC, &WACld,
Mptr( WAR, 0, Clq, WARld,
552 size ), &WARld, one,
Mptr( Cptr, 0, Clq, Cld, size ),
555 size ), WACld,
Mptr( WAR, 0, Clq, WARld, size ), WARld,
556 Cptr, l, l, Cd0, tzsyrk );
561 for( l = 0; l < N; l += Clcmb )
563 lb = N - l; ltmp = l + ( lb =
MIN( lb, Clcmb ) );
564 Clp =
PB_Cnumroc( l, 0, Cimb1, Cmb, myrow, Crow, nprow );
565 Clq =
PB_Cnumroc( l, 0, Cinb1, Cnb, mycol, Ccol, npcol );
567 size ), WACld,
Mptr( WAR, 0, Clq, WARld, size ), WARld,
568 Cptr, l, l, Cd0, tzsyrk );
569 Clp =
PB_Cnumroc( ltmp, 0, Cimb1, Cmb, myrow, Crow, nprow );
571 Cnq0 =
PB_Cnumroc( lb, l, Cinb1, Cnb, mycol, Ccol, npcol );
572 if( Cmp0 > 0 && Cnq0 > 0 )
574 &kbb, ALPHA,
Mptr( WAC, Clp, 0, WACld, size ), &WACld,
575 Mptr( WAR, 0, Clq, WARld, size ), &WARld, one,
576 Mptr( Cptr, Clp, Clq, Cld, size ), &Cld );
584 if( WACfr ) free( WAC );
585 if( WARfr ) free( WAR );