14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 char * A,
int IA,
int JA,
int * DESCA,
22 int IRPRNT,
int ICPRNT,
char * CMATNM )
28 int IA, ICPRNT, IRPRNT, JA, M, N;
159 int mycol, myrow, npcol, nprow, pcol, prow;
171 if( DESCA[
RSRC_ ] >= 0 )
176 if( DESCA[
CSRC_ ] >= 0 )
181 PB_Cplaprn2(
TYPE, M, N, A, IA, JA, DESCA, IRPRNT, ICPRNT, CMATNM,
189 for( pcol = 0; pcol < npcol; pcol++ )
191 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
192 (void) fprintf( stdout,
193 "Colum-replicated array -- copy in process column: %d\n", pcol );
194 PB_Cplaprn2(
TYPE, M, N, A, IA, JA, DESCA, IRPRNT, ICPRNT, CMATNM,
195 DESCA[
RSRC_ ], pcol );
204 if( DESCA[
CSRC_ ] >= 0 )
209 for( prow = 0; prow < nprow; prow++ )
211 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
212 (void) fprintf( stdout,
213 "Row-replicated array -- copy in process row: %d\n", prow );
214 PB_Cplaprn2(
TYPE, M, N, A, IA, JA, DESCA, IRPRNT, ICPRNT, CMATNM,
215 prow, DESCA[
CSRC_ ] );
223 for( prow = 0; prow < nprow; prow++ )
225 for( pcol = 0; pcol < npcol; pcol++ )
227 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
228 (void) fprintf( stdout,
229 "Replicated array -- copy in process (%d,%d)\n", prow, pcol );
231 CMATNM, prow, pcol );
243 int JA,
int * DESCA,
int IRPRNT,
int ICPRNT,
244 char * CMATNM,
int PROW,
int PCOL )
246 void PB_Cplaprn2(
TYPE, M, N, A, IA, JA, DESCA, IRPRNT, ICPRNT, CMATNM,
251 int IA, ICPRNT, IRPRNT, JA, M, N, PCOL, PROW;
264 int Acol, Aii, AisColRep, AisRowRep, Ajj, Ald, Arow, ctxt, h, i,
265 ib, icurcol, icurrow, ii, in, j, jb, jj, jn, ldw, mycol,
266 myrow, npcol, nprow, size, usiz;
283 PB_Cinfog2l( IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aii, &Ajj, &Arow,
294 if( Arow < 0 ) { AisRowRep = 1; icurrow = Arow = PROW; }
295 else { AisRowRep = 0; icurrow = Arow; }
301 if( Acol < 0 ) { AisColRep = 1; icurcol = Acol = PCOL; }
302 else { AisColRep = 0; icurcol = Acol; }
304 type =
TYPE->type; usiz =
TYPE->usiz; size =
TYPE->size;
309 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
317 for( h = 0; h < jb; h++ )
322 if( ( icurrow == IRPRNT ) && ( icurcol == ICPRNT ) )
324 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
326 PB_Cprnt( type, size, usiz, ib,
Mptr( A, ii, jj+h, Ald, size ),
327 IA+1, JA+h+1, CMATNM );
332 if( ( myrow == icurrow ) && ( mycol == icurcol ) )
334 TYPE->Cgesd2d( ctxt, ib, 1,
Mptr( A, ii, jj+h, Ald, size ), Ald,
337 else if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
339 TYPE->Cgerv2d( ctxt, ib, 1, buf, ldw, icurrow, icurcol );
340 PB_Cprnt( type, size, usiz, ib, buf, IA+1, JA+h+1, CMATNM );
346 if( myrow == icurrow ) ii += ib;
347 if( !( AisRowRep ) ) icurrow =
MModAdd1( icurrow, nprow );
353 for( i = in+1; i <= IA+M-1; i += DESCA[
MB_] )
355 ib =
MIN( DESCA[
MB_], IA+M-i );
356 if( ( icurrow == IRPRNT ) && ( icurcol == ICPRNT ) )
358 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
360 PB_Cprnt( type, size, usiz, ib,
Mptr( A, ii, jj+h, Ald, size ),
361 i+1, JA+h+1, CMATNM );
366 if( ( myrow == icurrow ) && ( mycol == icurcol ) )
368 TYPE->Cgesd2d( ctxt, ib, 1,
Mptr( A, ii, jj+h, Ald, size ), Ald,
371 else if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
373 TYPE->Cgerv2d( ctxt, ib, 1, buf, ldw, icurrow, icurcol );
374 PB_Cprnt( type, size, usiz, ib, buf, i+1, JA+h+1, CMATNM);
380 if( myrow == icurrow ) ii += ib;
381 if( !( AisRowRep ) ) icurrow =
MModAdd1( icurrow, nprow );
394 if( mycol == icurcol ) jj += jb;
395 if( !( AisColRep ) ) icurcol =
MModAdd1( icurcol, npcol );
401 for( j = jn+1; j <= JA+N-1; j += DESCA[
NB_] )
403 jb =
MIN( DESCA[
NB_], JA+N-j );
404 for( h = 0; h < jb; h++ )
409 if( ( icurrow == IRPRNT ) && ( icurcol == ICPRNT ) )
411 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
413 PB_Cprnt( type, size, usiz, ib,
Mptr( A, ii, jj+h, Ald, size ),
414 IA+1, j+h+1, CMATNM );
419 if( ( myrow == icurrow ) && ( mycol == icurcol ) )
421 TYPE->Cgesd2d( ctxt, ib, 1,
Mptr( A, ii, jj+h, Ald, size ), Ald,
424 else if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
426 TYPE->Cgerv2d( ctxt, ib, 1, buf, ldw, icurrow, icurcol );
427 PB_Cprnt( type, size, usiz, ib, buf, IA+1, j+h+1, CMATNM );
433 if( myrow == icurrow ) ii += ib;
434 if( !( AisRowRep ) ) icurrow =
MModAdd1( icurrow, nprow );
440 for( i = in+1; i <= IA+M-1; i += DESCA[
MB_] )
442 ib =
MIN( DESCA[
MB_], IA+M-i );
443 if( ( icurrow == IRPRNT ) && ( icurcol == ICPRNT ) )
445 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
448 size ), i+1, j+h+1, CMATNM );
453 if( ( myrow == icurrow ) && ( mycol == icurcol ) )
455 TYPE->Cgesd2d( ctxt, ib, 1,
Mptr( A, ii, jj+h, Ald, size ),
456 Ald, IRPRNT, ICPRNT );
458 else if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) )
460 TYPE->Cgerv2d( ctxt, ib, 1, buf, ldw, icurrow, icurcol );
461 PB_Cprnt( type, size, usiz, ib, buf, i+1, j+h+1, CMATNM );
467 if( myrow == icurrow ) ii += ib;
468 if( !( AisRowRep ) ) icurrow =
MModAdd1( icurrow, nprow );
481 if( mycol == icurcol ) jj += jb;
482 if( !( AisColRep ) ) icurcol =
MModAdd1( icurcol, npcol );
487 if( ( myrow == IRPRNT ) && ( mycol == ICPRNT ) && ( buf ) ) free( buf );
494 void PB_Cprnt(
char TYPE,
int SIZE,
int USIZ,
int N,
char * A,
int IA,
495 int JA,
char * CMATNM )
501 int IA, JA, N, SIZE,
TYPE, USIZ;
517 for( k = 0; k < N; k++ )
518 (
void) fprintf( stdout,
"%s(%6d,%6d)=%8d\n", CMATNM, IA+k, JA,
519 *((
int *)(&A[k*SIZE])) );
521 for( k = 0; k < N; k++ )
522 (
void) fprintf( stdout,
"%s(%6d,%6d)=%16.8f\n", CMATNM, IA+k, JA,
523 *((
float *)(&A[k*SIZE])) );
525 for( k = 0; k < N; k++ )
526 (
void) fprintf( stdout,
"%s(%6d,%6d)=%30.18f\n", CMATNM, IA+k, JA,
527 *((
double *)(&A[k*SIZE])) );
529 for( k = 0; k < N; k++ )
530 (
void) fprintf( stdout,
"%s(%6d,%6d)=%16.8f+i*(%16.8f)\n", CMATNM,
531 IA+k, JA, *((
float *)(&A[k*SIZE])),
532 *((
float *)(&A[k*SIZE+USIZ])) );
534 for( k = 0; k < N; k++ )
535 (
void) fprintf( stdout,
"%s(%6d,%6d)=%30.18f+i*(%30.18f)\n", CMATNM,
536 IA+k, JA, *((
double *)(&A[k*SIZE])),
537 *((
double *)(&A[k*SIZE+USIZ])) );