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 intgsz, memsiz, ntests, realsz, totmem
69 parameter( intgsz = 4, realsz = 4, totmem = 2000000,
70 $ memsiz = totmem / realsz, ntests = 20,
71 $ padval = -9923.0e+0, zero = 0.0e+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
85 REAL anorm, fresid, rcond, thresh
86 DOUBLE PRECISION nops, tmflops
89 CHARACTER*3 mattyp( ntests )
90 INTEGER desca( dlen_ ), ierr( 1 ), nbval( ntests ),
91 $ nval( ntests ), pval( ntests ),
94 DOUBLE PRECISION ctime( 2 ), wtime( 2 )
97 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
98 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
116 DATA ktests, kpass, kfail, kskip /4*0/
122 CALL blacs_pinfo( iam, nprocs )
124 CALL psinvinfo( outfile, nout, nmtyp, mattyp, ntests, nmat, nval,
125 $ ntests, nnb, nbval, ntests, ngrids, pval, ntests,
126 $ qval, ntests, thresh, mem, iam, nprocs )
127 check = ( thresh.GE.0.0e+0 )
138 WRITE( nout, fmt = * )
139 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
140 WRITE( nout, fmt = 9986 )
141 $
'A is a general matrix.'
142 ELSE IF(
lsamen( 3, mtyp,
'UTR' ) )
THEN
143 WRITE( nout, fmt = 9986 )
144 $
'A is an upper triangular matrix.'
145 ELSE IF(
lsamen( 3, mtyp,
'LTR' ) )
THEN
146 WRITE( nout, fmt = 9986 )
147 $
'A is a lower triangular matrix.'
148 ELSE IF(
lsamen( 3, mtyp,
'UPD' ) )
THEN
149 WRITE( nout, fmt = 9986 )
150 $
'A is a symmetric positive definite matrix.'
151 WRITE( nout, fmt = 9986 )
152 $
'Only the upper triangular part will be '//
154 ELSE IF(
lsamen( 3, mtyp,
'LPD' ) )
THEN
155 WRITE( nout, fmt = 9986 )
156 $
'A is a symmetric positive definite matrix.'
157 WRITE( nout, fmt = 9986 )
158 $
'Only the lower triangular part will be '//
161 WRITE( nout, fmt = * )
162 WRITE( nout, fmt = 9995 )
163 WRITE( nout, fmt = 9994 )
164 WRITE( nout, fmt = * )
177 IF( nprow.LT.1 )
THEN
179 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
181 ELSE IF( npcol.LT.1 )
THEN
183 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
185 ELSE IF( nprow*npcol.GT.nprocs )
THEN
187 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
191 IF( ierr( 1 ).GT.0 )
THEN
193 $
WRITE( nout, fmt = 9997 )
'grid'
200 CALL blacs_get( -1, 0, ictxt )
201 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
202 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
206 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
218 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
224 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
226 IF( ierr( 1 ).GT.0 )
THEN
228 $
WRITE( nout, fmt = 9997 )
'matrix'
245 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
250 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
253 IF( ierr( 1 ).GT.0 )
THEN
255 $
WRITE( nout, fmt = 9997 )
'NB'
262 np =
numroc( n, nb, myrow, 0, nprow )
263 nq =
numroc( n, nb, mycol, 0, npcol )
265 iprepad =
max( nb, np )
267 ipostpad =
max( nb, nq )
276 CALL descinit( desca, n, n, nb, nb, 0, 0, ictxt,
277 $
max( 1, np ) + imidpad, ierr( 1 ) )
281 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
284 IF( ierr( 1 ).LT.0 )
THEN
286 $
WRITE( nout, fmt = 9997 )
'descriptor'
296 lcm =
ilcm( nprow, npcol )
297 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
301 ippiv = ipa + desca( lld_ ) * nq + ipostpad +
303 lipiv =
iceil( intgsz * ( np + nb ), realsz )
304 ipw = ippiv + lipiv + ipostpad + iprepad
306 lwork =
max( 1, np * desca( nb_ ) )
307 workinv = lwork + ipostpad
312 IF( nprow.EQ.npcol )
THEN
313 liwork = nq + desca( nb_ )
321 liwork =
numroc( desca( m_ ) +
322 $ desca( mb_ ) * nprow
323 $ + mod( 1 - 1, desca( mb_ ) ), desca( nb_ ),
324 $ mycol, desca( csrc_ ), npcol ) +
326 $
numroc( desca( m_ ) + desca( mb_ ) * nprow,
327 $ desca( mb_ ), myrow, desca( rsrc_ ), nprow ),
328 $ desca( mb_ ) ), lcm / nprow ), desca( nb_ ) )
331 workiinv =
iceil( liwork*intgsz, realsz ) +
333 ipiw = ipw + workinv + iprepad
334 worksiz = workinv + iprepad + workiinv
341 ipw = ipa + desca( lld_ ) * nq + ipostpad + iprepad
342 worksiz = 1 + ipostpad
351 IF(
lsamen( 3, mtyp,
'GEN' ).OR.
352 $
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
356 IF( nprow.NE.npcol )
THEN
362 worksiz =
max( worksiz-ipostpad, itemp )
367 worksiz =
max( worksiz, 2 * nb *
max( 1, np ) ) +
375 IF( ipw+worksiz.GT.memsiz )
THEN
377 $
WRITE( nout, fmt = 9996 )
'inversion',
378 $ ( ipw + worksiz ) * realsz
384 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
387 IF( ierr( 1 ).GT.0 )
THEN
389 $
WRITE( nout, fmt = 9997 )
'MEMORY'
394 IF(
lsamen( 3, mtyp,
'GEN' ).OR.
395 $
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
399 CALL psmatgen( ictxt,
'N',
'D', desca( m_ ),
400 $ desca( n_ ), desca( mb_ ),
401 $ desca( nb_ ), mem( ipa ),
402 $ desca( lld_ ), desca( rsrc_ ),
403 $ desca( csrc_ ), iaseed, 0, np, 0,
404 $ nq, myrow, mycol, nprow, npcol )
406 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
410 CALL psmatgen( ictxt,
'S',
'D', desca( m_ ),
411 $ desca( n_ ), desca( mb_ ),
412 $ desca( nb_ ), mem( ipa ),
413 $ desca( lld_ ), desca( rsrc_ ),
414 $ desca( csrc_ ), iaseed, 0, np, 0,
415 $ nq, myrow, mycol, nprow, npcol )
421 IF(
lsamen( 1, mtyp,
'U' ) )
THEN
424 CALL pslaset(
'Lower', n-1, n-1, zero, zero,
425 $ mem( ipa ), 2, 1, desca )
427 ELSE IF(
lsamen( 1, mtyp,
'L' ) )
THEN
430 CALL pslaset(
'Upper', n-1, n-1, zero, zero,
431 $ mem( ipa ), 1, 2, desca )
443 CALL psfillpad( ictxt, np, nq, mem( ipa-iprepad ),
444 $ desca( lld_ ), iprepad, ipostpad,
446 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
447 $ mem( ipw-iprepad ),
448 $ worksiz-ipostpad, iprepad,
451 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
454 $ mem( ippiv-iprepad ), lipiv,
455 $ iprepad, ipostpad, padval )
456 anorm =
pslange(
'1', n, n, mem( ipa ), 1, 1,
457 $ desca, mem( ipw ) )
458 CALL pschekpad( ictxt,
'PSLANGE', np, nq,
459 $ mem( ipa-iprepad ),
461 $ iprepad, ipostpad, padval )
463 $ worksiz-ipostpad, 1,
464 $ mem( ipw-iprepad ),
466 $ iprepad, ipostpad, padval )
467 CALL psfillpad( ictxt, workinv-ipostpad, 1,
468 $ mem( ipw-iprepad ),
470 $ iprepad, ipostpad, padval )
471 CALL psfillpad( ictxt, workiinv-ipostpad, 1,
472 $ mem( ipiw-iprepad ),
473 $ workiinv-ipostpad, iprepad,
475 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
477 anorm =
pslantr(
'1', uplo,
'Non unit', n, n,
478 $ mem( ipa ), 1, 1, desca,
480 CALL pschekpad( ictxt,
'PSLANTR', np, nq,
481 $ mem( ipa-iprepad ),
483 $ iprepad, ipostpad, padval )
485 $ worksiz-ipostpad, 1,
486 $ mem( ipw-iprepad ),
488 $ iprepad, ipostpad, padval )
490 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
492 anorm =
pslansy(
'1', uplo, n, mem( ipa ), 1, 1,
493 $ desca, mem( ipw ) )
494 CALL pschekpad( ictxt,
'PSLANSY', np, nq,
495 $ mem( ipa-iprepad ),
497 $ iprepad, ipostpad, padval )
499 $ worksiz-ipostpad, 1,
500 $ mem( ipw-iprepad ),
502 $ iprepad, ipostpad, padval )
504 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'SY' ) )
THEN
507 $ mem( ippiv-iprepad ), lipiv,
508 $ iprepad, ipostpad, padval )
509 anorm =
pslansy(
'1', uplo, n, mem( ipa ), 1, 1,
510 $ desca, mem( ipw ) )
511 CALL pschekpad( ictxt,
'PSLANSY', np, nq,
512 $ mem( ipa-iprepad ),
514 $ iprepad, ipostpad, padval )
516 $ worksiz-ipostpad, 1,
517 $ mem( ipw-iprepad ),
519 $ iprepad,ipostpad, padval )
526 CALL blacs_barrier( ictxt,
'All' )
528 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
533 CALL psgetrf( n, n, mem( ipa ), 1, 1, desca,
534 $ mem( ippiv ), info )
541 CALL pschekpad( ictxt,
'PSGETRF', np, nq,
542 $ mem( ipa-iprepad ),
544 $ iprepad, ipostpad, padval )
545 CALL pschekpad( ictxt,
'PSGETRF', lipiv, 1,
546 $ mem( ippiv-iprepad ), lipiv,
547 $ iprepad, ipostpad, padval )
553 CALL psgetri( n, mem( ipa ), 1, 1, desca,
554 $ mem( ippiv ), mem( ipw ), lwork,
555 $ mem( ipiw ), liwork, info )
562 CALL pschekpad( ictxt,
'PSGETRI', np, nq,
563 $ mem( ipa-iprepad ),
565 $ iprepad, ipostpad, padval )
566 CALL pschekpad( ictxt,
'PSGETRI', lipiv, 1,
567 $ mem( ippiv-iprepad ), lipiv,
568 $ iprepad, ipostpad, padval )
570 $ workiinv-ipostpad, 1,
571 $ mem( ipiw-iprepad ),
573 $ iprepad, ipostpad, padval )
575 $ workinv-ipostpad, 1,
576 $ mem( ipw-iprepad ),
578 $ iprepad, ipostpad, padval )
581 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
586 CALL pstrtri( uplo,
'Non unit', n, mem( ipa ), 1,
594 CALL pschekpad( ictxt,
'PSTRTRI', np, nq,
595 $ mem( ipa-iprepad ),
597 $ iprepad, ipostpad, padval )
600 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
605 CALL pspotrf( uplo, n, mem( ipa ), 1, 1, desca,
613 CALL pschekpad( ictxt,
'PSPOTRF', np, nq,
614 $ mem( ipa-iprepad ),
616 $ iprepad, ipostpad, padval )
623 CALL pspotri( uplo, n, mem( ipa ), 1, 1, desca,
631 CALL pschekpad( ictxt,
'PSPOTRI', np, nq,
632 $ mem( ipa-iprepad ),
634 $ iprepad, ipostpad, padval )
641 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
642 $ mem( ipw-iprepad ),
643 $ worksiz-ipostpad, iprepad,
648 CALL psinvchk( mtyp, n, mem( ipa ), 1, 1, desca,
649 $ iaseed, anorm, fresid, rcond,
654 CALL pschekpad( ictxt,
'PSINVCHK', np, nq,
655 $ mem( ipa-iprepad ),
657 $ iprepad, ipostpad, padval )
659 $ worksiz-ipostpad, 1,
660 $ mem( ipw-iprepad ),
661 $ worksiz-ipostpad, iprepad,
666 IF( fresid.LE.thresh .AND. info.EQ.0 .AND.
667 $ ( (fresid-fresid) .EQ. 0.0e+0 ) )
THEN
685 fresid = fresid - fresid
692 CALL slcombine( ictxt,
'All',
'>',
'W', 2, 1, wtime )
693 CALL slcombine( ictxt,
'All',
'>',
'C', 2, 1, ctime )
697 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
699 IF(
lsamen( 3, mtyp,
'GEN' ) )
THEN
703 nops = ( 2.0d+0 / 3.0d+0 )*( dble( n )**3 ) -
704 $ ( 1.0d+0 / 2.0d+0 )*( dble( n )**2 )
709 $ ( 4.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) -
712 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'TR' ) )
THEN
718 nops = ( 1.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
719 $ ( 2.0d+0 / 3.0d+0 ) * ( dble( n ) )
721 ELSE IF(
lsamen( 2, mtyp( 2:3 ),
'PD' ) )
THEN
726 nops = ( 1.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
727 $ ( 1.0d+0 / 2.0d+0 ) * ( dble( n )**2 )
732 $ ( 2.0d+0 / 3.0d+0 ) * ( dble( n )**3 ) +
733 $ ( 1.0d+0 / 2.0d+0 ) * ( dble( n )**2 )
743 IF( wtime( 1 ) + wtime( 2 ) .GT. 0.0d+0 )
THEN
745 $ ( ( wtime( 1 )+wtime( 2 ) ) * 1.0d+6 )
750 IF( wtime( 2 ) .GE. 0.0d+0 )
751 $
WRITE( nout, fmt = 9993 )
'WALL', n, nb, nprow,
752 $ npcol, wtime( 1 ), wtime( 2 ), tmflops,
753 $ rcond, fresid, passed
757 IF( ctime( 1 ) + ctime( 2 ) .GT. 0.0d+0 )
THEN
759 $ ( ( ctime( 1 )+ctime( 2 ) ) * 1.0d+6 )
764 IF( ctime( 2 ) .GE. 0.0d+0 )
765 $
WRITE( nout, fmt = 9993 )
'CPU ', n, nb, nprow,
766 $ npcol, ctime( 1 ), ctime( 2 ), tmflops,
767 $ rcond, fresid, passed
774 CALL blacs_gridexit( ictxt )
783 ktests = kpass + kfail + kskip
784 WRITE( nout, fmt = * )
785 WRITE( nout, fmt = 9992 ) ktests
787 WRITE( nout, fmt = 9991 ) kpass
788 WRITE( nout, fmt = 9989 ) kfail
790 WRITE( nout, fmt = 9990 ) kpass
792 WRITE( nout, fmt = 9988 ) kskip
793 WRITE( nout, fmt = * )
794 WRITE( nout, fmt = * )
795 WRITE( nout, fmt = 9987 )
796 IF( nout.NE.6 .AND. nout.NE.0 )
802 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
803 $
'; It should be at least 1' )
804 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
806 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
807 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
809 9995
FORMAT(
'TIME N NB P Q Fct Time Inv Time ',
810 $
' MFLOPS Cond Resid CHECK' )
811 9994
FORMAT(
'---- ----- --- ----- ----- -------- -------- ',
812 $
'----------- ------- ------- ------' )
813 9993
FORMAT( a4, 1x, i5, 1x, i3, 1x, i5, 1x, i5, 1x, f8.2, 1x, f8.2,
814 $ 1x, f11.2, 1x, f7.1, 1x, f7.2, 1x, a6 )
815 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
816 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
817 9990
FORMAT( i5,
' tests completed without checking.' )
818 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
819 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
820 9987
FORMAT(
'END OF TESTS.' )