62 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
63 $ lld_, mb_, m_, nb_, n_, rsrc_
64 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
65 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
66 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
67 INTEGER dblesz, intgsz, memsiz, ntests, totmem
68 DOUBLE PRECISION padval, zero
69 parameter( dblesz = 8, intgsz = 4, totmem = 2000000,
70 $ memsiz = totmem / dblesz, ntests = 20,
71 $ padval = -9923.0d+0, zero = 0.0d+0 )
79 INTEGER i, iam, iaseed, ictxt, imidpad, info, ipa,
80 $ ippiv, iprepad, ipostpad, ipiw, ipw, itemp, j,
81 $ k, ktests, kpass, kfail, kskip, l, lcm, lipiv,
82 $ liwork, lwork, mycol, myrow, n, nb, ngrids,
83 $ nmat, nmtyp, nnb, nout, np, npcol, nprocs,
84 $ nprow, nq, workiinv, workinv, worksiz
86 DOUBLE PRECISION anorm, fresid, nops, rcond, tmflops
89 CHARACTER*3 mattyp( ntests )
90 INTEGER desca( dlen_ ), ierr( 1 ), nbval( ntests ),
91 $ nval( ntests ), pval( ntests ),
93 DOUBLE PRECISION mem( memsiz ), ctime( 2 ), wtime( 2 )
96 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
97 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
112 INTRINSIC dble,
max, mod
115 DATA ktests, kpass, kfail, kskip /4*0/
121 CALL blacs_pinfo( iam, nprocs )
123 CALL pdinvinfo( outfile, nout, nmtyp, mattyp, ntests, nmat, nval,
124 $ ntests, nnb, nbval, ntests, ngrids, pval, ntests,
125 $ qval, ntests, thresh, mem, iam, nprocs )
126 check = ( thresh.GE.0.0e+0 )
137 WRITE( nout, fmt = * )
138 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
139 WRITE( nout, fmt = 9986 )
140 $
'A is a general matrix.'
141 ELSE IF(
lsamen( 3, mtyp,
'UTR' ) )
THEN
142 WRITE( nout, fmt = 9986 )
143 $
'A is an upper triangular matrix.'
144 ELSE IF(
lsamen( 3, mtyp,
'LTR' ) )
THEN
145 WRITE( nout, fmt = 9986 )
146 $
'A is a lower triangular matrix.'
147 ELSE IF(
lsamen( 3, mtyp,
'UPD' ) )
THEN
148 WRITE( nout, fmt = 9986 )
149 $
'A is a symmetric positive definite matrix.'
150 WRITE( nout, fmt = 9986 )
151 $
'Only the upper triangular part will be '//
153 ELSE IF(
lsamen( 3, mtyp,
'LPD' ) )
THEN
154 WRITE( nout, fmt = 9986 )
155 $
'A is a symmetric positive definite matrix.'
156 WRITE( nout, fmt = 9986 )
157 $
'Only the lower triangular part will be '//
160 WRITE( nout, fmt = * )
161 WRITE( nout, fmt = 9995 )
162 WRITE( nout, fmt = 9994 )
163 WRITE( nout, fmt = * )
176 IF( nprow.LT.1 )
THEN
178 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
180 ELSE IF( npcol.LT.1 )
THEN
182 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
184 ELSE IF( nprow*npcol.GT.nprocs )
THEN
186 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
190 IF( ierr( 1 ).GT.0 )
THEN
192 $
WRITE( nout, fmt = 9997 )
'grid'
199 CALL blacs_get( -1, 0, ictxt )
200 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
201 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
205 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
217 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
223 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
225 IF( ierr( 1 ).GT.0 )
THEN
227 $
WRITE( nout, fmt = 9997 )
'matrix'
244 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
249 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
252 IF( ierr( 1 ).GT.0 )
THEN
254 $
WRITE( nout, fmt = 9997 )
'NB'
261 np =
numroc( n, nb, myrow, 0, nprow )
262 nq =
numroc( n, nb, mycol, 0, npcol )
264 iprepad =
max( nb, np )
266 ipostpad =
max( nb, nq )
275 CALL descinit( desca, n, n, nb, nb, 0, 0, ictxt,
276 $
max( 1, np ) + imidpad, ierr( 1 ) )
280 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
283 IF( ierr( 1 ).LT.0 )
THEN
285 $
WRITE( nout, fmt = 9997 )
'descriptor'
295 lcm =
ilcm( nprow, npcol )
296 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
300 ippiv = ipa + desca( lld_ ) * nq + ipostpad +
302 lipiv =
iceil( intgsz * ( np + nb ), dblesz )
303 ipw = ippiv + lipiv + ipostpad + iprepad
305 lwork =
max( 1, np * desca( nb_ ) )
306 workinv = lwork + ipostpad
311 IF( nprow.EQ.npcol )
THEN
312 liwork = nq + desca( nb_ )
320 liwork =
numroc( desca( m_ ) +
321 $ desca( mb_ ) * nprow
322 $ + mod( 1 - 1, desca( mb_ ) ), desca( nb_ ),
323 $ mycol, desca( csrc_ ), npcol ) +
325 $
numroc( desca( m_ ) + desca( mb_ ) * nprow,
326 $ desca( mb_ ), myrow, desca( rsrc_ ), nprow ),
327 $ desca( mb_ ) ), lcm / nprow ), desca( nb_ ) )
330 workiinv =
iceil( liwork*intgsz, dblesz ) +
332 ipiw = ipw + workinv + iprepad
333 worksiz = workinv + iprepad + workiinv
340 ipw = ipa + desca( lld_ ) * nq + ipostpad + iprepad
341 worksiz = 1 + ipostpad
350 IF(
lsamen( 3, mtyp,
'GEN' ).OR.
351 $
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
355 IF( nprow.NE.npcol )
THEN
361 worksiz =
max( worksiz-ipostpad, itemp )
366 worksiz =
max( worksiz, 2 * nb *
max( 1, np ) ) +
374 IF( ipw+worksiz.GT.memsiz )
THEN
376 $
WRITE( nout, fmt = 9996 )
'inversion',
377 $ ( ipw + worksiz ) * dblesz
383 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
386 IF( ierr( 1 ).GT.0 )
THEN
388 $
WRITE( nout, fmt = 9997 )
'MEMORY'
393 IF(
lsamen( 3, mtyp,
'GEN' ).OR.
394 $
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
398 CALL pdmatgen( ictxt,
'N',
'D', desca( m_ ),
399 $ desca( n_ ), desca( mb_ ),
400 $ desca( nb_ ), mem( ipa ),
401 $ desca( lld_ ), desca( rsrc_ ),
402 $ desca( csrc_ ), iaseed, 0, np, 0,
403 $ nq, myrow, mycol, nprow, npcol )
405 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
409 CALL pdmatgen( ictxt,
'S',
'D', desca( m_ ),
410 $ desca( n_ ), desca( mb_ ),
411 $ desca( nb_ ), mem( ipa ),
412 $ desca( lld_ ), desca( rsrc_ ),
413 $ desca( csrc_ ), iaseed, 0, np, 0,
414 $ nq, myrow, mycol, nprow, npcol )
420 IF(
lsamen( 1, mtyp,
'U' ) )
THEN
423 CALL pdlaset(
'Lower', n-1, n-1, zero, zero,
424 $ mem( ipa ), 2, 1, desca )
426 ELSE IF(
lsamen( 1, mtyp,
'L' ) )
THEN
429 CALL pdlaset(
'Upper', n-1, n-1, zero, zero,
430 $ mem( ipa ), 1, 2, desca )
442 CALL pdfillpad( ictxt, np, nq, mem( ipa-iprepad ),
443 $ desca( lld_ ), iprepad, ipostpad,
445 CALL pdfillpad( ictxt, worksiz-ipostpad, 1,
446 $ mem( ipw-iprepad ),
447 $ worksiz-ipostpad, iprepad,
450 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
453 $ mem( ippiv-iprepad ), lipiv,
454 $ iprepad, ipostpad, padval )
455 anorm =
pdlange(
'1', n, n, mem( ipa ), 1, 1,
456 $ desca, mem( ipw ) )
457 CALL pdchekpad( ictxt,
'PDLANGE', np, nq,
458 $ mem( ipa-iprepad ),
460 $ iprepad, ipostpad, padval )
462 $ worksiz-ipostpad, 1,
463 $ mem( ipw-iprepad ),
465 $ iprepad, ipostpad, padval )
466 CALL pdfillpad( ictxt, workinv-ipostpad, 1,
467 $ mem( ipw-iprepad ),
469 $ iprepad, ipostpad, padval )
470 CALL pdfillpad( ictxt, workiinv-ipostpad, 1,
471 $ mem( ipiw-iprepad ),
472 $ workiinv-ipostpad, iprepad,
474 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
476 anorm =
pdlantr(
'1', uplo,
'Non unit', n, n,
477 $ mem( ipa ), 1, 1, desca,
479 CALL pdchekpad( ictxt,
'PDLANTR', np, nq,
480 $ mem( ipa-iprepad ),
482 $ iprepad, ipostpad, padval )
484 $ worksiz-ipostpad, 1,
485 $ mem( ipw-iprepad ),
487 $ iprepad, ipostpad, padval )
489 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
491 anorm =
pdlansy(
'1', uplo, n, mem( ipa ), 1, 1,
492 $ desca, mem( ipw ) )
493 CALL pdchekpad( ictxt,
'PDLANSY', np, nq,
494 $ mem( ipa-iprepad ),
496 $ iprepad, ipostpad, padval )
498 $ worksiz-ipostpad, 1,
499 $ mem( ipw-iprepad ),
501 $ iprepad, ipostpad, padval )
503 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'SY' ) )
THEN
506 $ mem( ippiv-iprepad ), lipiv,
507 $ iprepad, ipostpad, padval )
508 anorm =
pdlansy(
'1', uplo, n, mem( ipa ), 1, 1,
509 $ desca, mem( ipw ) )
510 CALL pdchekpad( ictxt,
'PDLANSY', np, nq,
511 $ mem( ipa-iprepad ),
513 $ iprepad, ipostpad, padval )
515 $ worksiz-ipostpad, 1,
516 $ mem( ipw-iprepad ),
518 $ iprepad,ipostpad, padval )
525 CALL blacs_barrier( ictxt,
'All' )
527 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
532 CALL pdgetrf( n, n, mem( ipa ), 1, 1, desca,
533 $ mem( ippiv ), info )
540 CALL pdchekpad( ictxt,
'PDGETRF', np, nq,
541 $ mem( ipa-iprepad ),
543 $ iprepad, ipostpad, padval )
544 CALL pdchekpad( ictxt,
'PDGETRF', lipiv, 1,
545 $ mem( ippiv-iprepad ), lipiv,
546 $ iprepad, ipostpad, padval )
552 CALL pdgetri( n, mem( ipa ), 1, 1, desca,
553 $ mem( ippiv ), mem( ipw ), lwork,
554 $ mem( ipiw ), liwork, info )
561 CALL pdchekpad( ictxt,
'PDGETRI', np, nq,
562 $ mem( ipa-iprepad ),
564 $ iprepad, ipostpad, padval )
565 CALL pdchekpad( ictxt,
'PDGETRI', lipiv, 1,
566 $ mem( ippiv-iprepad ), lipiv,
567 $ iprepad, ipostpad, padval )
569 $ workiinv-ipostpad, 1,
570 $ mem( ipiw-iprepad ),
572 $ iprepad, ipostpad, padval )
574 $ workinv-ipostpad, 1,
575 $ mem( ipw-iprepad ),
577 $ iprepad, ipostpad, padval )
580 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
585 CALL pdtrtri( uplo,
'Non unit', n, mem( ipa ), 1,
593 CALL pdchekpad( ictxt,
'PDTRTRI', np, nq,
594 $ mem( ipa-iprepad ),
596 $ iprepad, ipostpad, padval )
599 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
604 CALL pdpotrf( uplo, n, mem( ipa ), 1, 1, desca,
612 CALL pdchekpad( ictxt,
'PDPOTRF', np, nq,
613 $ mem( ipa-iprepad ),
615 $ iprepad, ipostpad, padval )
622 CALL pdpotri( uplo, n, mem( ipa ), 1, 1, desca,
630 CALL pdchekpad( ictxt,
'PDPOTRI', np, nq,
631 $ mem( ipa-iprepad ),
633 $ iprepad, ipostpad, padval )
640 CALL pdfillpad( ictxt, worksiz-ipostpad, 1,
641 $ mem( ipw-iprepad ),
642 $ worksiz-ipostpad, iprepad,
647 CALL pdinvchk( mtyp, n, mem( ipa ), 1, 1, desca,
648 $ iaseed, anorm, fresid, rcond,
653 CALL pdchekpad( ictxt,
'PDINVCHK', np, nq,
654 $ mem( ipa-iprepad ),
656 $ iprepad, ipostpad, padval )
658 $ worksiz-ipostpad, 1,
659 $ mem( ipw-iprepad ),
660 $ worksiz-ipostpad, iprepad,
665 IF( fresid.LE.thresh .AND. info.EQ.0 .AND.
666 $ ( (fresid-fresid) .EQ. 0.0d+0 ) )
THEN
684 fresid = fresid - fresid
691 CALL slcombine( ictxt,
'All',
'>',
'W', 2, 1, wtime )
692 CALL slcombine( ictxt,
'All',
'>',
'C', 2, 1, ctime )
696 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
698 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
702 nops = ( 2.0d+0 / 3.0d+0 )*( dble( n )**3 ) -
703 $ ( 1.0d+0 / 2.0d+0 )*( dble( n )**2 )
708 $ ( 4.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) -
711 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
717 nops = ( 1.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
718 $ ( 2.0d+0 / 3.0d+0 ) * ( dble( n ) )
720 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
725 nops = ( 1.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
726 $ ( 1.0d+0 / 2.0d+0 ) * ( dble( n )**2 )
731 $ ( 2.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
732 $ ( 1.0d+0 / 2.0d+0 ) * ( dble( n )**2 )
742 IF( wtime( 1 ) + wtime( 2 ) .GT. 0.0d+0 )
THEN
744 $ ( ( wtime( 1 )+wtime( 2 ) ) * 1.0d+6 )
749 IF( wtime( 2 ) .GE. 0.0d+0 )
750 $
WRITE( nout, fmt = 9993 )
'WALL', n, nb, nprow,
751 $ npcol, wtime( 1 ), wtime( 2 ), tmflops,
752 $ rcond, fresid, passed
756 IF( ctime( 1 ) + ctime( 2 ) .GT. 0.0d+0 )
THEN
758 $ ( ( ctime( 1 )+ctime( 2 ) ) * 1.0d+6 )
763 IF( ctime( 2 ) .GE. 0.0d+0 )
764 $
WRITE( nout, fmt = 9993 )
'CPU ', n, nb, nprow,
765 $ npcol, ctime( 1 ), ctime( 2 ), tmflops,
766 $ rcond, fresid, passed
773 CALL blacs_gridexit( ictxt )
782 ktests = kpass + kfail + kskip
783 WRITE( nout, fmt = * )
784 WRITE( nout, fmt = 9992 ) ktests
786 WRITE( nout, fmt = 9991 ) kpass
787 WRITE( nout, fmt = 9989 ) kfail
789 WRITE( nout, fmt = 9990 ) kpass
791 WRITE( nout, fmt = 9988 ) kskip
792 WRITE( nout, fmt = * )
793 WRITE( nout, fmt = * )
794 WRITE( nout, fmt = 9987 )
795 IF( nout.NE.6 .AND. nout.NE.0 )
801 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
802 $
'; It should be at least 1' )
803 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
805 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
806 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
808 9995
FORMAT(
'TIME N NB P Q Fct Time Inv Time ',
809 $
' MFLOPS Cond Resid CHECK' )
810 9994
FORMAT(
'---- ----- --- ----- ----- -------- -------- ',
811 $
'----------- ------- ------- ------' )
812 9993
FORMAT( a4, 1x, i5, 1x, i3, 1x, i5, 1x, i5, 1x, f8.2, 1x, f8.2,
813 $ 1x, f11.2, 1x, f7.1, 1x, f7.2, 1x, a6 )
814 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
815 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
816 9990
FORMAT( i5,
' tests completed without checking.' )
817 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
818 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
819 9987
FORMAT(
'END OF TESTS.' )