69 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
70 $ lld_, mb_, m_, nb_, n_, rsrc_
71 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
72 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
73 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
74 INTEGER intgsz, memsiz, ntests, realsz, totmem
76 parameter( intgsz = 4, realsz = 4, totmem = 2000000,
77 $ memsiz = totmem / realsz, ntests = 20,
78 $ padval = -9923.0e+0, zero = 0.0e+0 )
84 INTEGER hh, i, iam, iaseed, ibseed, ictxt, imidpad,
85 $ info, ipa, ipa0, ipb, ipb0, ipberr, ipferr,
86 $ ipostpad, ippiv, iprepad, ipw, ipw2, j, k,
87 $ kfail, kk, kpass, kskip, ktests, lcm, lcmq,
88 $ lipiv, liwork, lwork, lw2, m, maxmn,
89 $ minmn, mp, mycol, myrhs, myrow, n, nb, nbrhs,
90 $ ngrids, nmat, nnb, nnbr, nnr, nout, np, npcol,
91 $ nprocs, nprow, nq, nrhs, worksiz
92 REAL anorm, anorm1, fresid, rcond, sresid, sresid2,
94 DOUBLE PRECISION nops, tmflops
97 INTEGER desca( dlen_ ), descb( dlen_ ), ierr( 1 ),
98 $ mval( ntests ), nbrval( ntests ),
99 $ nbval( ntests ), nrval( ntests ),
100 $ nval( ntests ), pval( ntests ),
103 DOUBLE PRECISION ctime( 2 ), wtime( 2 )
106 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
107 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
123 DATA kfail, kpass, kskip, ktests / 4*0 /
129 CALL blacs_pinfo( iam, nprocs )
132 CALL psluinfo( outfile, nout, nmat, mval, nval, ntests, nnb,
133 $ nbval, ntests, nnr, nrval, ntests, nnbr, nbrval,
134 $ ntests, ngrids, pval, ntests, qval, ntests, thresh,
135 $ est, mem, iam, nprocs )
136 check = ( thresh.GE.0.0e+0 )
141 WRITE( nout, fmt = * )
142 WRITE( nout, fmt = 9995 )
143 WRITE( nout, fmt = 9994 )
144 WRITE( nout, fmt = * )
157 IF( nprow.LT.1 )
THEN
159 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
161 ELSE IF( npcol.LT.1 )
THEN
163 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
165 ELSE IF( nprow*npcol.GT.nprocs )
THEN
167 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
171 IF( ierr( 1 ).GT.0 )
THEN
173 $
WRITE( nout, fmt = 9997 )
'grid'
180 CALL blacs_get( -1, 0, ictxt )
181 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
182 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
187 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
200 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'M', m
202 ELSE IF( n.LT.1 )
THEN
204 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
210 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
212 IF( ierr( 1 ).GT.0 )
THEN
214 $
WRITE( nout, fmt = 9997 )
'matrix'
229 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
234 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
236 IF( ierr( 1 ).GT.0 )
THEN
238 $
WRITE( nout, fmt = 9997 )
'NB'
245 mp =
numroc( m, nb, myrow, 0, nprow )
246 np =
numroc( n, nb, myrow, 0, nprow )
247 nq =
numroc( n, nb, mycol, 0, npcol )
249 iprepad =
max( nb, mp )
251 ipostpad =
max( nb, nq )
260 CALL descinit( desca, m, n, nb, nb, 0, 0, ictxt,
261 $
max( 1, mp )+imidpad, ierr( 1 ) )
265 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
267 IF( ierr( 1 ).LT.0 )
THEN
269 $
WRITE( nout, fmt = 9997 )
'descriptor'
278 IF( est .AND. m.EQ.n )
THEN
279 ipa0 = ipa + desca( lld_ )*nq + ipostpad + iprepad
280 ippiv = ipa0 + desca( lld_ )*nq + ipostpad + iprepad
282 ippiv = ipa + desca( lld_ )*nq + ipostpad + iprepad
284 lipiv =
iceil( intgsz*( mp+nb ), realsz )
285 ipw = ippiv + lipiv + ipostpad + iprepad
293 worksiz =
max( 2, nq )
295 worksiz =
max( worksiz, mp*desca( nb_ )+
298 worksiz =
max( worksiz, mp * desca( nb_ ) )
300 worksiz = worksiz + ipostpad
311 IF( ipw+worksiz.GT.memsiz )
THEN
313 $
WRITE( nout, fmt = 9996 )
'factorization',
314 $ ( ipw+worksiz )*realsz
320 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
322 IF( ierr( 1 ).GT.0 )
THEN
324 $
WRITE( nout, fmt = 9997 )
'MEMORY'
331 CALL psmatgen( ictxt,
'No transpose',
'No transpose',
332 $ desca( m_ ), desca( n_ ), desca( mb_ ),
333 $ desca( nb_ ), mem( ipa ), desca( lld_ ),
334 $ desca( rsrc_ ), desca( csrc_ ), iaseed, 0,
335 $ mp, 0, nq, myrow, mycol, nprow, npcol )
340 CALL psfillpad( ictxt, mp, nq, mem( ipa-iprepad ),
341 $ desca( lld_ ), iprepad, ipostpad,
343 CALL psfillpad( ictxt, lipiv, 1, mem( ippiv-iprepad ),
344 $ lipiv, iprepad, ipostpad, padval )
345 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
346 $ mem( ipw-iprepad ), worksiz-ipostpad,
347 $ iprepad, ipostpad, padval )
348 anorm =
pslange(
'I', m, n, mem( ipa ), 1, 1, desca,
350 anorm1 =
pslange(
'1', m, n, mem( ipa ), 1, 1, desca,
352 CALL pschekpad( ictxt,
'PSLANGE', mp, nq,
353 $ mem( ipa-iprepad ), desca( lld_ ),
354 $ iprepad, ipostpad, padval )
355 CALL pschekpad( ictxt,
'PSLANGE', worksiz-ipostpad,
356 $ 1, mem( ipw-iprepad ),
357 $ worksiz-ipostpad, iprepad, ipostpad,
361 IF( est .AND. m.EQ.n )
THEN
362 CALL psmatgen( ictxt,
'No transpose',
'No transpose',
363 $ desca( m_ ), desca( n_ ), desca( mb_ ),
364 $ desca( nb_ ), mem( ipa0 ),
365 $ desca( lld_ ), desca( rsrc_ ),
366 $ desca( csrc_ ), iaseed, 0, mp, 0, nq,
367 $ myrow, mycol, nprow, npcol )
369 $
CALL psfillpad( ictxt, mp, nq, mem( ipa0-iprepad ),
370 $ desca( lld_ ), iprepad, ipostpad,
375 CALL blacs_barrier( ictxt,
'All' )
380 CALL psgetrf( m, n, mem( ipa ), 1, 1, desca,
381 $ mem( ippiv ), info )
387 $
WRITE( nout, fmt = * )
'PSGETRF INFO=', info
397 CALL pschekpad( ictxt,
'PSGETRF', mp, nq,
398 $ mem( ipa-iprepad ), desca( lld_ ),
399 $ iprepad, ipostpad, padval )
400 CALL pschekpad( ictxt,
'PSGETRF', lipiv, 1,
401 $ mem( ippiv-iprepad ), lipiv, iprepad,
416 CALL psgetrrv( m, n, mem( ipa ), 1, 1, desca,
417 $ mem( ippiv ), mem( ipw ) )
418 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1, 1,
419 $ desca, iaseed, anorm, fresid,
424 CALL pschekpad( ictxt,
'PSGETRRV', mp, nq,
425 $ mem( ipa-iprepad ), desca( lld_ ),
426 $ iprepad, ipostpad, padval )
427 CALL pschekpad( ictxt,
'PSGETRRV', lipiv, 1,
428 $ mem( ippiv-iprepad ), lipiv,
429 $ iprepad, ipostpad, padval )
431 $ worksiz-ipostpad, 1,
432 $ mem( ipw-iprepad ),
433 $ worksiz-ipostpad, iprepad,
438 IF( ( fresid.LE.thresh ) .AND.
439 $ ( (fresid-fresid).EQ.0.0e+0 ) )
THEN
445 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
446 $
WRITE( nout, fmt = 9986 ) fresid
454 fresid = fresid - fresid
461 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1,
463 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1,
468 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
476 nops = dble( maxmn )*( dble( minmn )**2 ) -
477 $ (1.0d+0 / 3.0d+0)*( dble( minmn )**3 ) -
478 $ (1.0d+0 / 2.0d+0)*( dble( minmn )**2 )
485 IF( wtime( 1 ).GT.0.0d+0 )
THEN
486 tmflops = nops / ( wtime( 1 ) * 1.0d+6 )
492 IF( wtime( 1 ).GE.0.0d+0 )
493 $
WRITE( nout, fmt = 9993 )
'WALL', m, n, nb,
494 $ nrhs, nbrhs, nprow, npcol, wtime( 1 ),
495 $ wtime( 2 ), tmflops, passed
499 IF( ctime( 1 ).GT.0.0d+0 )
THEN
500 tmflops = nops / ( ctime( 1 ) * 1.0d+6 )
506 IF( ctime( 1 ).GE.0.0d+0 )
507 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n, nb,
508 $ nrhs, nbrhs, nprow, npcol, ctime( 1 ),
509 $ ctime( 2 ), tmflops, passed
520 lwork =
max( 1, 2*np ) +
max( 1, 2*nq ) +
521 $
max( 2, desca( nb_ )*
522 $
max( 1,
iceil( nprow-1, npcol ) ),
524 $
max( 1,
iceil( npcol-1, nprow ) ) )
525 ipw2 = ipw + lwork + ipostpad + iprepad
526 liwork =
max( 1, np )
527 lw2 =
iceil( liwork*intgsz, realsz ) + ipostpad
530 IF( ipw2+lw2.GT.memsiz )
THEN
532 $
WRITE( nout, fmt = 9996 )
'cond est',
533 $ ( ipw2+lw2 )*realsz
539 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
542 IF( ierr( 1 ).GT.0 )
THEN
544 $
WRITE( nout, fmt = 9997 )
'MEMORY'
551 $ mem( ipw-iprepad ), lwork,
552 $ iprepad, ipostpad, padval )
554 $ mem( ipw2-iprepad ),
555 $ lw2-ipostpad, iprepad,
561 CALL psgecon(
'1', n, mem( ipa ), 1, 1, desca,
562 $ anorm1, rcond, mem( ipw ), lwork,
563 $ mem( ipw2 ), liwork, info )
566 CALL pschekpad( ictxt,
'PSGECON', np, nq,
567 $ mem( ipa-iprepad ),
568 $ desca( lld_ ), iprepad,
570 CALL pschekpad( ictxt,
'PSGECON', lwork, 1,
571 $ mem( ipw-iprepad ), lwork,
572 $ iprepad, ipostpad, padval )
575 $ mem( ipw2-iprepad ),
576 $ lw2-ipostpad, iprepad,
593 CALL descinit( descb, n, nrhs, nb, nbrhs, 0, 0,
594 $ ictxt,
max( 1, np )+imidpad,
599 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
602 IF( ierr( 1 ).LT.0 )
THEN
604 $
WRITE( nout, fmt = 9997 )
'descriptor'
611 myrhs =
numroc( descb( n_ ), descb( nb_ ),
612 $ mycol, descb( csrc_ ), npcol )
616 ipb0 = ipb + descb( lld_ )*myrhs + ipostpad +
618 ipferr = ipb0 + descb( lld_ )*myrhs +
620 ipberr = myrhs + ipferr + ipostpad + iprepad
621 ipw = myrhs + ipberr + ipostpad + iprepad
623 ipw = ipb + descb( lld_ )*myrhs + ipostpad +
631 lcm =
ilcm( nprow, npcol )
633 worksiz =
max( worksiz-ipostpad,
634 $ nq * nbrhs + np * nbrhs +
635 $
max(
max( nq*nb, 2*nbrhs ),
638 worksiz = ipostpad + worksiz
644 IF( ipw+worksiz.GT.memsiz )
THEN
646 $
WRITE( nout, fmt = 9996 )
'solve',
647 $ ( ipw+worksiz )*realsz
653 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
656 IF( ierr( 1 ).GT.0 )
THEN
658 $
WRITE( nout, fmt = 9997 )
'MEMORY'
665 CALL psmatgen( ictxt,
'No',
'No', descb( m_ ),
666 $ descb( n_ ), descb( mb_ ),
667 $ descb( nb_ ), mem( ipb ),
668 $ descb( lld_ ), descb( rsrc_ ),
669 $ descb( csrc_ ), ibseed, 0, np, 0,
670 $ myrhs, myrow, mycol, nprow,
675 $ mem( ipb-iprepad ),
676 $ descb( lld_ ), iprepad,
681 $ descb( m_ ), descb( n_ ),
682 $ descb( mb_ ), descb( nb_ ),
683 $ mem( ipb0 ), descb( lld_ ),
685 $ descb( csrc_ ), ibseed, 0, np,
686 $ 0, myrhs, myrow, mycol, nprow,
690 $ mem( ipb0-iprepad ),
691 $ descb( lld_ ), iprepad,
694 $ mem( ipferr-iprepad ), 1,
698 $ mem( ipberr-iprepad ), 1,
704 CALL blacs_barrier( ictxt,
'All' )
709 CALL psgetrs(
'No', n, nrhs, mem( ipa ), 1, 1,
710 $ desca, mem( ippiv ), mem( ipb ),
711 $ 1, 1, descb, info )
719 CALL pschekpad( ictxt,
'PSGETRS', np, nq,
720 $ mem( ipa-iprepad ),
721 $ desca( lld_ ), iprepad,
723 CALL pschekpad( ictxt,
'PSGETRS', lipiv, 1,
724 $ mem( ippiv-iprepad ), lipiv,
725 $ iprepad, ipostpad, padval )
727 $ myrhs, mem( ipb-iprepad ),
728 $ descb( lld_ ), iprepad,
732 $ 1, mem( ipw-iprepad ),
733 $ worksiz-ipostpad, iprepad,
739 $ mem( ipb ), 1, 1, descb,
740 $ iaseed, 1, 1, desca, ibseed,
741 $ anorm, sresid, mem( ipw ) )
743 IF( iam.EQ.0 .AND. sresid.GT.thresh )
744 $
WRITE( nout, fmt = 9985 ) sresid
749 $ myrhs, mem( ipb-iprepad ),
750 $ descb( lld_ ), iprepad,
753 $ worksiz-ipostpad, 1,
754 $ mem( ipw-iprepad ),
756 $ iprepad, ipostpad, padval )
760 IF( sresid.LE.thresh .AND.
761 $ ( sresid-sresid ).EQ.0.0e+0 )
THEN
770 sresid = sresid - sresid
778 lwork =
max( 1, 3*np )
779 ipw2 = ipw + lwork + ipostpad + iprepad
780 liwork =
max( 1, np )
781 lw2 =
iceil( liwork*intgsz, realsz ) +
785 IF( ipw2+lw2.GT.memsiz )
THEN
787 $
WRITE( nout, fmt = 9996 )
788 $
'iter ref', ( ipw2+lw2 )*realsz
794 CALL igsum2d( ictxt,
'All',
' ', 1, 1,
797 IF( ierr( 1 ).GT.0 )
THEN
799 $
WRITE( nout, fmt = 9997 )
807 $ mem( ipw-iprepad ),
808 $ lwork, iprepad, ipostpad,
811 $ mem( ipw2-iprepad ),
812 $ lw2-ipostpad, iprepad,
819 CALL psgerfs(
'No', n, nrhs, mem( ipa0 ), 1,
820 $ 1, desca, mem( ipa ), 1, 1,
821 $ desca, mem( ippiv ),
822 $ mem( ipb0 ), 1, 1, descb,
823 $ mem( ipb ), 1, 1, descb,
824 $ mem( ipferr ), mem( ipberr ),
825 $ mem( ipw ), lwork, mem( ipw2 ),
830 $ nq, mem( ipa0-iprepad ),
831 $ desca( lld_ ), iprepad,
834 $ nq, mem( ipa-iprepad ),
835 $ desca( lld_ ), iprepad,
838 $ 1, mem( ippiv-iprepad ),
842 $ myrhs, mem( ipb-iprepad ),
843 $ descb( lld_ ), iprepad,
847 $ mem( ipb0-iprepad ),
848 $ descb( lld_ ), iprepad,
852 $ mem( ipferr-iprepad ), 1,
857 $ mem( ipberr-iprepad ), 1,
861 $ 1, mem( ipw-iprepad ),
862 $ lwork, iprepad, ipostpad,
866 $ mem( ipw2-iprepad ),
867 $ lw2-ipostpad, iprepad,
871 $ 1, mem( ipw-iprepad ),
872 $ worksiz-ipostpad, iprepad,
878 $ mem( ipb ), 1, 1, descb,
879 $ iaseed, 1, 1, desca,
880 $ ibseed, anorm, sresid2,
883 IF( iam.EQ.0 .AND. sresid2.GT.thresh )
884 $
WRITE( nout, fmt = 9985 ) sresid2
889 $ myrhs, mem( ipb-iprepad ),
890 $ descb( lld_ ), iprepad,
893 $ worksiz-ipostpad, 1,
894 $ mem( ipw-iprepad ),
895 $ worksiz-ipostpad, iprepad,
902 CALL slcombine( ictxt,
'All',
'>',
'W', 2, 1,
904 CALL slcombine( ictxt,
'All',
'>',
'C', 2, 1,
909 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
913 nops = (2.0d+0/3.0d+0)*( dble(n)**3 ) -
914 $ (1.0d+0/2.0d+0)*( dble(n)**2 )
918 nops = nops + 2.0d+0*(dble(n)**2)*dble(nrhs)
926 IF( wtime( 1 ) + wtime( 2 ) .GT. 0.0d+0 )
929 $ ( ( wtime( 1 )+wtime( 2 ) ) * 1.0d+6 )
936 IF( wtime( 2 ).GE.0.0d+0 )
937 $
WRITE( nout, fmt = 9993 )
'WALL', m, n,
938 $ nb, nrhs, nbrhs, nprow, npcol,
939 $ wtime( 1 ), wtime( 2 ), tmflops,
944 IF( ctime( 1 )+ctime( 2 ).GT.0.0d+0 )
947 $ ( ( ctime( 1 )+ctime( 2 ) ) * 1.0d+6 )
952 IF( ctime( 2 ).GE.0.0d+0 )
953 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n,
954 $ nb, nrhs, nbrhs, nprow, npcol,
955 $ ctime( 1 ), ctime( 2 ), tmflops,
961 IF( check.AND.( sresid.GT.thresh ) )
THEN
965 CALL psgetrrv( m, n, mem( ipa ), 1, 1, desca,
966 $ mem( ippiv ), mem( ipw ) )
967 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
968 $ 1, desca, iaseed, anorm, fresid,
973 CALL pschekpad( ictxt,
'PSGETRRV', np, nq,
974 $ mem( ipa-iprepad ), desca( lld_ ),
975 $ iprepad, ipostpad, padval )
976 CALL pschekpad( ictxt,
'PSGETRRV', lipiv,
977 $ 1, mem( ippiv-iprepad ), lipiv,
978 $ iprepad, ipostpad, padval )
980 $ worksiz-ipostpad, 1,
981 $ mem( ipw-iprepad ),
982 $ worksiz-ipostpad, iprepad,
985 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
986 $
WRITE( nout, fmt = 9986 ) fresid
991 CALL blacs_gridexit( ictxt )
998 ktests = kpass + kfail + kskip
999 WRITE( nout, fmt = * )
1000 WRITE( nout, fmt = 9992 ) ktests
1002 WRITE( nout, fmt = 9991 ) kpass
1003 WRITE( nout, fmt = 9989 ) kfail
1005 WRITE( nout, fmt = 9990 ) kpass
1007 WRITE( nout, fmt = 9988 ) kskip
1008 WRITE( nout, fmt = * )
1009 WRITE( nout, fmt = * )
1010 WRITE( nout, fmt = 9987 )
1011 IF( nout.NE.6 .AND. nout.NE.0 )
1015 CALL blacs_exit( 0 )
1017 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
1018 $
'; It should be at least 1' )
1019 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
1021 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
1022 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
1024 9995
FORMAT(
'TIME M N NB NRHS NBRHS P Q LU Time ',
1025 $
'Sol Time MFLOPS CHECK' )
1026 9994
FORMAT(
'---- ----- ----- --- ---- ----- ---- ---- -------- ',
1027 $
'-------- -------- ------' )
1028 9993
FORMAT( a4, 1x, i5, 1x, i5, 1x, i3, 1x, i5, 1x, i4, 1x, i4, 1x,
1029 $ i4, 1x, f8.2, 1x, f8.2, 1x, f8.2, 1x, a6 )
1030 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
1031 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
1032 9990
FORMAT( i5,
' tests completed without checking.' )
1033 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
1034 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
1035 9987
FORMAT(
'END OF TESTS.' )
1036 9986
FORMAT(
'||A - P*L*U|| / (||A|| * N * eps) = ', g25.7 )
1037 9985
FORMAT(
'||Ax-b||/(||x||*||A||*eps*N) ', f25.7 )