70 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
71 $ lld_, mb_, m_, nb_, n_, rsrc_
72 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
73 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
74 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
75 INTEGER cplxsz, intgsz, memsiz, ntests, realsz, totmem
78 parameter( cplxsz = 8, intgsz = 4, realsz = 4,
80 $ memsiz = totmem / cplxsz, ntests = 20,
81 $ padval = ( -9923.0e+0, -9923.0e+0 ),
88 INTEGER hh, i, iam, iaseed, ibseed, ictxt, imidpad,
89 $ info, ipa, ipa0, ipb, ipb0, ipberr, ipferr,
90 $ ipostpad, ippiv, iprepad, ipw, ipw2, j, k,
91 $ kfail, kk, kpass, kskip, ktests, lcm, lcmq,
92 $ lipiv, lrwork, lwork, lw2, m, maxmn,
93 $ minmn, mp, mycol, myrhs, myrow, n, nb, nbrhs,
94 $ ngrids, nmat, nnb, nnbr, nnr, nout, np, npcol,
95 $ nprocs, nprow, nq, nrhs, worksiz
96 REAL anorm, anorm1, fresid, rcond, sresid, sresid2,
98 DOUBLE PRECISION nops, tmflops
101 INTEGER desca( dlen_ ), descb( dlen_ ), ierr( 1 ),
102 $ mval( ntests ), nbrval( ntests ),
103 $ nbval( ntests ), nrval( ntests ),
104 $ nval( ntests ), pval( ntests ),
106 DOUBLE PRECISION ctime( 2 ), wtime( 2 )
107 COMPLEX mem( memsiz )
110 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
111 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
127 DATA kfail, kpass, kskip, ktests / 4*0 /
133 CALL blacs_pinfo( iam, nprocs )
136 CALL pcluinfo( outfile, nout, nmat, mval, nval, ntests, nnb,
137 $ nbval, ntests, nnr, nrval, ntests, nnbr, nbrval,
138 $ ntests, ngrids, pval, ntests, qval, ntests, thresh,
139 $ est, mem, iam, nprocs )
140 check = ( thresh.GE.0.0e+0 )
145 WRITE( nout, fmt = * )
146 WRITE( nout, fmt = 9995 )
147 WRITE( nout, fmt = 9994 )
148 WRITE( nout, fmt = * )
161 IF( nprow.LT.1 )
THEN
163 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
165 ELSE IF( npcol.LT.1 )
THEN
167 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
169 ELSE IF( nprow*npcol.GT.nprocs )
THEN
171 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
175 IF( ierr( 1 ).GT.0 )
THEN
177 $
WRITE( nout, fmt = 9997 )
'grid'
184 CALL blacs_get( -1, 0, ictxt )
185 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
186 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
191 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
204 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'M', m
206 ELSE IF( n.LT.1 )
THEN
208 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
214 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
216 IF( ierr( 1 ).GT.0 )
THEN
218 $
WRITE( nout, fmt = 9997 )
'matrix'
233 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
238 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
240 IF( ierr( 1 ).GT.0 )
THEN
242 $
WRITE( nout, fmt = 9997 )
'NB'
249 mp =
numroc( m, nb, myrow, 0, nprow )
250 np =
numroc( n, nb, myrow, 0, nprow )
251 nq =
numroc( n, nb, mycol, 0, npcol )
253 iprepad =
max( nb, mp )
255 ipostpad =
max( nb, nq )
264 CALL descinit( desca, m, n, nb, nb, 0, 0, ictxt,
265 $
max( 1, mp )+imidpad, ierr( 1 ) )
269 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
271 IF( ierr( 1 ).LT.0 )
THEN
273 $
WRITE( nout, fmt = 9997 )
'descriptor'
282 IF( est .AND. m.EQ.n )
THEN
283 ipa0 = ipa + desca( lld_ )*nq + ipostpad + iprepad
284 ippiv = ipa0 + desca( lld_ )*nq + ipostpad + iprepad
286 ippiv = ipa + desca( lld_ )*nq + ipostpad + iprepad
288 lipiv =
iceil( intgsz*( mp+nb ), cplxsz )
289 ipw = ippiv + lipiv + ipostpad + iprepad
297 worksiz =
max( 2, nq )
299 worksiz =
max( worksiz, mp*desca( nb_ )+
302 worksiz =
max( worksiz, mp * desca( nb_ ) )
304 worksiz = worksiz + ipostpad
315 IF( ipw+worksiz.GT.memsiz )
THEN
317 $
WRITE( nout, fmt = 9996 )
'factorization',
318 $ ( ipw+worksiz )*cplxsz
324 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
326 IF( ierr( 1 ).GT.0 )
THEN
328 $
WRITE( nout, fmt = 9997 )
'MEMORY'
335 CALL pcmatgen( ictxt,
'No transpose',
'No transpose',
336 $ desca( m_ ), desca( n_ ), desca( mb_ ),
337 $ desca( nb_ ), mem( ipa ), desca( lld_ ),
338 $ desca( rsrc_ ), desca( csrc_ ), iaseed, 0,
339 $ mp, 0, nq, myrow, mycol, nprow, npcol )
344 CALL pcfillpad( ictxt, mp, nq, mem( ipa-iprepad ),
345 $ desca( lld_ ), iprepad, ipostpad,
347 CALL pcfillpad( ictxt, lipiv, 1, mem( ippiv-iprepad ),
348 $ lipiv, iprepad, ipostpad, padval )
349 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
350 $ mem( ipw-iprepad ), worksiz-ipostpad,
351 $ iprepad, ipostpad, padval )
352 anorm =
pclange(
'I', m, n, mem( ipa ), 1, 1, desca,
354 anorm1 =
pclange(
'1', m, n, mem( ipa ), 1, 1, desca,
356 CALL pcchekpad( ictxt,
'PCLANGE', mp, nq,
357 $ mem( ipa-iprepad ), desca( lld_ ),
358 $ iprepad, ipostpad, padval )
359 CALL pcchekpad( ictxt,
'PCLANGE', worksiz-ipostpad,
360 $ 1, mem( ipw-iprepad ),
361 $ worksiz-ipostpad, iprepad, ipostpad,
365 IF( est .AND. m.EQ.n )
THEN
366 CALL pcmatgen( ictxt,
'No transpose',
'No transpose',
367 $ desca( m_ ), desca( n_ ), desca( mb_ ),
368 $ desca( nb_ ), mem( ipa0 ),
369 $ desca( lld_ ), desca( rsrc_ ),
370 $ desca( csrc_ ), iaseed, 0, mp, 0, nq,
371 $ myrow, mycol, nprow, npcol )
373 $
CALL pcfillpad( ictxt, mp, nq, mem( ipa0-iprepad ),
374 $ desca( lld_ ), iprepad, ipostpad,
379 CALL blacs_barrier( ictxt,
'All' )
384 CALL pcgetrf( m, n, mem( ipa ), 1, 1, desca,
385 $ mem( ippiv ), info )
391 $
WRITE( nout, fmt = * )
'PCGETRF INFO=', info
401 CALL pcchekpad( ictxt,
'PCGETRF', mp, nq,
402 $ mem( ipa-iprepad ), desca( lld_ ),
403 $ iprepad, ipostpad, padval )
404 CALL pcchekpad( ictxt,
'PCGETRF', lipiv, 1,
405 $ mem( ippiv-iprepad ), lipiv, iprepad,
420 CALL pcgetrrv( m, n, mem( ipa ), 1, 1, desca,
421 $ mem( ippiv ), mem( ipw ) )
422 CALL pclafchk(
'No',
'No', m, n, mem( ipa ), 1, 1,
423 $ desca, iaseed, anorm, fresid,
428 CALL pcchekpad( ictxt,
'PCGETRRV', mp, nq,
429 $ mem( ipa-iprepad ), desca( lld_ ),
430 $ iprepad, ipostpad, padval )
431 CALL pcchekpad( ictxt,
'PCGETRRV', lipiv, 1,
432 $ mem( ippiv-iprepad ), lipiv,
433 $ iprepad, ipostpad, padval )
435 $ worksiz-ipostpad, 1,
436 $ mem( ipw-iprepad ),
437 $ worksiz-ipostpad, iprepad,
442 IF( ( fresid.LE.thresh ) .AND.
443 $ ( (fresid-fresid).EQ.0.0e+0 ) )
THEN
449 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
450 $
WRITE( nout, fmt = 9986 ) fresid
458 fresid = fresid - fresid
465 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1,
467 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1,
472 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
480 nops = 4.0d+0*dble(maxmn)*(dble(minmn)**2) -
481 $ (4.0d+0 / 3.0d+0)*( dble( minmn )**3 ) +
482 $ (2.0d+0)*dble( maxmn )*dble( minmn ) -
483 $ (3.0d+0)*( dble( minmn )**2 )
490 IF( wtime( 1 ).GT.0.0d+0 )
THEN
491 tmflops = nops / ( wtime( 1 ) * 1.0d+6 )
497 IF( wtime( 1 ).GE.0.0d+0 )
498 $
WRITE( nout, fmt = 9993 )
'WALL', m, n, nb,
499 $ nrhs, nbrhs, nprow, npcol, wtime( 1 ),
500 $ wtime( 2 ), tmflops, passed
504 IF( ctime( 1 ).GT.0.0d+0 )
THEN
505 tmflops = nops / ( ctime( 1 ) * 1.0d+6 )
511 IF( ctime( 1 ).GE.0.0d+0 )
512 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n, nb,
513 $ nrhs, nbrhs, nprow, npcol, ctime( 1 ),
514 $ ctime( 2 ), tmflops, passed
525 lwork =
max( 1, 2*np ) +
526 $
max( 2, desca( nb_ )*
527 $
max( 1,
iceil( nprow-1, npcol ) ),
529 $
max( 1,
iceil( npcol-1, nprow ) ) )
530 ipw2 = ipw + lwork + ipostpad + iprepad
531 lrwork =
max( 1, 2*nq )
532 lw2 =
iceil( lrwork*realsz, cplxsz ) + ipostpad
535 IF( ipw2+lw2.GT.memsiz )
THEN
537 $
WRITE( nout, fmt = 9996 )
'cond est',
538 $ ( ipw2+lw2 )*cplxsz
544 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
547 IF( ierr( 1 ).GT.0 )
THEN
549 $
WRITE( nout, fmt = 9997 )
'MEMORY'
556 $ mem( ipw-iprepad ), lwork,
557 $ iprepad, ipostpad, padval )
559 $ mem( ipw2-iprepad ),
560 $ lw2-ipostpad, iprepad,
566 CALL pcgecon(
'1', n, mem( ipa ), 1, 1, desca,
567 $ anorm1, rcond, mem( ipw ), lwork,
568 $ mem( ipw2 ), lrwork, info )
571 CALL pcchekpad( ictxt,
'PCGECON', np, nq,
572 $ mem( ipa-iprepad ),
573 $ desca( lld_ ), iprepad,
575 CALL pcchekpad( ictxt,
'PCGECON', lwork, 1,
576 $ mem( ipw-iprepad ), lwork,
577 $ iprepad, ipostpad, padval )
580 $ mem( ipw2-iprepad ),
581 $ lw2-ipostpad, iprepad,
598 CALL descinit( descb, n, nrhs, nb, nbrhs, 0, 0,
599 $ ictxt,
max( 1, np )+imidpad,
604 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
607 IF( ierr( 1 ).LT.0 )
THEN
609 $
WRITE( nout, fmt = 9997 )
'descriptor'
616 myrhs =
numroc( descb( n_ ), descb( nb_ ),
617 $ mycol, descb( csrc_ ), npcol )
621 ipb0 = ipb + descb( lld_ )*myrhs + ipostpad +
623 ipferr = ipb0 + descb( lld_ )*myrhs +
625 ipberr = myrhs + ipferr + ipostpad + iprepad
626 ipw = myrhs + ipberr + ipostpad + iprepad
628 ipw = ipb + descb( lld_ )*myrhs + ipostpad +
636 lcm =
ilcm( nprow, npcol )
638 worksiz =
max( worksiz-ipostpad,
639 $ nq * nbrhs + np * nbrhs +
640 $
max(
max( nq*nb, 2*nbrhs ),
643 worksiz = ipostpad + worksiz
649 IF( ipw+worksiz.GT.memsiz )
THEN
651 $
WRITE( nout, fmt = 9996 )
'solve',
652 $ ( ipw+worksiz )*cplxsz
658 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1,
661 IF( ierr( 1 ).GT.0 )
THEN
663 $
WRITE( nout, fmt = 9997 )
'MEMORY'
670 CALL pcmatgen( ictxt,
'No',
'No', descb( m_ ),
671 $ descb( n_ ), descb( mb_ ),
672 $ descb( nb_ ), mem( ipb ),
673 $ descb( lld_ ), descb( rsrc_ ),
674 $ descb( csrc_ ), ibseed, 0, np, 0,
675 $ myrhs, myrow, mycol, nprow,
680 $ mem( ipb-iprepad ),
681 $ descb( lld_ ), iprepad,
686 $ descb( m_ ), descb( n_ ),
687 $ descb( mb_ ), descb( nb_ ),
688 $ mem( ipb0 ), descb( lld_ ),
690 $ descb( csrc_ ), ibseed, 0, np,
691 $ 0, myrhs, myrow, mycol, nprow,
695 $ mem( ipb0-iprepad ),
696 $ descb( lld_ ), iprepad,
699 $ mem( ipferr-iprepad ), 1,
703 $ mem( ipberr-iprepad ), 1,
709 CALL blacs_barrier( ictxt,
'All' )
714 CALL pcgetrs(
'No', n, nrhs, mem( ipa ), 1, 1,
715 $ desca, mem( ippiv ), mem( ipb ),
716 $ 1, 1, descb, info )
724 CALL pcchekpad( ictxt,
'PCGETRS', np, nq,
725 $ mem( ipa-iprepad ),
726 $ desca( lld_ ), iprepad,
728 CALL pcchekpad( ictxt,
'PCGETRS', lipiv, 1,
729 $ mem( ippiv-iprepad ), lipiv,
730 $ iprepad, ipostpad, padval )
732 $ myrhs, mem( ipb-iprepad ),
733 $ descb( lld_ ), iprepad,
737 $ 1, mem( ipw-iprepad ),
738 $ worksiz-ipostpad, iprepad,
744 $ mem( ipb ), 1, 1, descb,
745 $ iaseed, 1, 1, desca, ibseed,
746 $ anorm, sresid, mem( ipw ) )
748 IF( iam.EQ.0 .AND. sresid.GT.thresh )
749 $
WRITE( nout, fmt = 9985 ) sresid
754 $ myrhs, mem( ipb-iprepad ),
755 $ descb( lld_ ), iprepad,
758 $ worksiz-ipostpad, 1,
759 $ mem( ipw-iprepad ),
761 $ iprepad, ipostpad, padval )
765 IF( sresid.LE.thresh .AND.
766 $ ( sresid-sresid ).EQ.0.0e+0 )
THEN
775 sresid = sresid - sresid
783 lwork =
max( 1, 2*np )
784 ipw2 = ipw + lwork + ipostpad + iprepad
785 lrwork =
max( 1, np )
786 lw2 =
iceil( lrwork*realsz, cplxsz ) +
790 IF( ipw2+lw2.GT.memsiz )
THEN
792 $
WRITE( nout, fmt = 9996 )
793 $
'iter ref', ( ipw2+lw2 )*cplxsz
799 CALL igsum2d( ictxt,
'All',
' ', 1, 1,
802 IF( ierr( 1 ).GT.0 )
THEN
804 $
WRITE( nout, fmt = 9997 )
812 $ mem( ipw-iprepad ),
813 $ lwork, iprepad, ipostpad,
816 $ mem( ipw2-iprepad ),
817 $ lw2-ipostpad, iprepad,
824 CALL pcgerfs(
'No', n, nrhs, mem( ipa0 ), 1,
825 $ 1, desca, mem( ipa ), 1, 1,
826 $ desca, mem( ippiv ),
827 $ mem( ipb0 ), 1, 1, descb,
828 $ mem( ipb ), 1, 1, descb,
829 $ mem( ipferr ), mem( ipberr ),
830 $ mem( ipw ), lwork, mem( ipw2 ),
835 $ nq, mem( ipa0-iprepad ),
836 $ desca( lld_ ), iprepad,
839 $ nq, mem( ipa-iprepad ),
840 $ desca( lld_ ), iprepad,
843 $ 1, mem( ippiv-iprepad ),
847 $ myrhs, mem( ipb-iprepad ),
848 $ descb( lld_ ), iprepad,
852 $ mem( ipb0-iprepad ),
853 $ descb( lld_ ), iprepad,
857 $ mem( ipferr-iprepad ), 1,
862 $ mem( ipberr-iprepad ), 1,
866 $ 1, mem( ipw-iprepad ),
867 $ lwork, iprepad, ipostpad,
871 $ mem( ipw2-iprepad ),
872 $ lw2-ipostpad, iprepad,
876 $ 1, mem( ipw-iprepad ),
877 $ worksiz-ipostpad, iprepad,
883 $ mem( ipb ), 1, 1, descb,
884 $ iaseed, 1, 1, desca,
885 $ ibseed, anorm, sresid2,
888 IF( iam.EQ.0 .AND. sresid2.GT.thresh )
889 $
WRITE( nout, fmt = 9985 ) sresid2
894 $ myrhs, mem( ipb-iprepad ),
895 $ descb( lld_ ), iprepad,
898 $ worksiz-ipostpad, 1,
899 $ mem( ipw-iprepad ),
900 $ worksiz-ipostpad, iprepad,
907 CALL slcombine( ictxt,
'All',
'>',
'W', 2, 1,
909 CALL slcombine( ictxt,
'All',
'>',
'C', 2, 1,
914 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
918 nops = (8.0d+0/3.0d+0)*( dble(n)**3 ) -
923 nops = nops + 8.0d+0*(dble(n)**2)*dble(nrhs)
931 IF( wtime( 1 ) + wtime( 2 ) .GT. 0.0d+0 )
934 $ ( ( wtime( 1 )+wtime( 2 ) ) * 1.0d+6 )
941 IF( wtime( 2 ).GE.0.0d+0 )
942 $
WRITE( nout, fmt = 9993 )
'WALL', m, n,
943 $ nb, nrhs, nbrhs, nprow, npcol,
944 $ wtime( 1 ), wtime( 2 ), tmflops,
949 IF( ctime( 1 )+ctime( 2 ).GT.0.0d+0 )
952 $ ( ( ctime( 1 )+ctime( 2 ) ) * 1.0d+6 )
957 IF( ctime( 2 ).GE.0.0d+0 )
958 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n,
959 $ nb, nrhs, nbrhs, nprow, npcol,
960 $ ctime( 1 ), ctime( 2 ), tmflops,
966 IF( check.AND.( sresid.GT.thresh ) )
THEN
970 CALL pcgetrrv( m, n, mem( ipa ), 1, 1, desca,
971 $ mem( ippiv ), mem( ipw ) )
972 CALL pclafchk(
'No',
'No', m, n, mem( ipa ), 1,
973 $ 1, desca, iaseed, anorm, fresid,
978 CALL pcchekpad( ictxt,
'PCGETRRV', np, nq,
979 $ mem( ipa-iprepad ), desca( lld_ ),
980 $ iprepad, ipostpad, padval )
981 CALL pcchekpad( ictxt,
'PCGETRRV', lipiv,
982 $ 1, mem( ippiv-iprepad ), lipiv,
983 $ iprepad, ipostpad, padval )
985 $ worksiz-ipostpad, 1,
986 $ mem( ipw-iprepad ),
987 $ worksiz-ipostpad, iprepad,
990 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
991 $
WRITE( nout, fmt = 9986 ) fresid
996 CALL blacs_gridexit( ictxt )
1003 ktests = kpass + kfail + kskip
1004 WRITE( nout, fmt = * )
1005 WRITE( nout, fmt = 9992 ) ktests
1007 WRITE( nout, fmt = 9991 ) kpass
1008 WRITE( nout, fmt = 9989 ) kfail
1010 WRITE( nout, fmt = 9990 ) kpass
1012 WRITE( nout, fmt = 9988 ) kskip
1013 WRITE( nout, fmt = * )
1014 WRITE( nout, fmt = * )
1015 WRITE( nout, fmt = 9987 )
1016 IF( nout.NE.6 .AND. nout.NE.0 )
1020 CALL blacs_exit( 0 )
1022 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
1023 $
'; It should be at least 1' )
1024 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
1026 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
1027 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
1029 9995
FORMAT(
'TIME M N NB NRHS NBRHS P Q LU Time ',
1030 $
'Sol Time MFLOPS CHECK' )
1031 9994
FORMAT(
'---- ----- ----- --- ---- ----- ---- ---- -------- ',
1032 $
'-------- -------- ------' )
1033 9993
FORMAT( a4, 1x, i5, 1x, i5, 1x, i3, 1x, i5, 1x, i4, 1x, i4, 1x,
1034 $ i4, 1x, f8.2, 1x, f8.2, 1x, f8.2, 1x, a6 )
1035 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
1036 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
1037 9990
FORMAT( i5,
' tests completed without checking.' )
1038 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
1039 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
1040 9987
FORMAT(
'END OF TESTS.' )
1041 9986
FORMAT(
'||A - P*L*U|| / (||A|| * N * eps) = ', g25.7 )
1042 9985
FORMAT(
'||Ax-b||/(||x||*||A||*eps*N) ', f25.7 )