66 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
67 $ lld_, mb_, m_, nb_, n_, rsrc_
68 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
69 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
70 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
71 INTEGER dblesz, intgsz, memsiz, ntests, totmem
72 DOUBLE PRECISION padval
73 parameter( dblesz = 8, intgsz = 4, totmem = 2000000,
74 $ memsiz = totmem / dblesz, ntests = 20,
75 $ padval = -9923.0d+0 )
84 INTEGER i, iam, iaseed, ictxt, imidpad, info, ipa,
85 $ ipostpad, ippiv, iprepad, iptau, ipw, j, k,
86 $ kfail, kpass, kskip, ktests, l, lipiv, ltau,
87 $ lwork, m, maxmn, mb, minmn, mnp, mnq, mp,
88 $ mycol, myrow, n, nb, nfact, ngrids, nmat, nnb,
89 $ nout, npcol, nprocs, nprow, nq, workfct,
92 DOUBLE PRECISION anorm, fresid, nops, tmflops
95 CHARACTER*2 factor( ntests )
96 INTEGER desca( dlen_ ), ierr( 1 ), mbval( ntests ),
97 $ mval( ntests ), nbval( ntests ),
98 $ nval( ntests ), pval( ntests ), qval( ntests )
99 DOUBLE PRECISION ctime( 1 ), mem( memsiz ), wtime( 1 )
102 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
103 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
122 DATA ktests, kpass, kfail, kskip /4*0/
128 CALL blacs_pinfo( iam, nprocs )
130 CALL pdqrinfo( outfile, nout, nfact, factor, ntests, nmat, mval,
131 $ ntests, nval, ntests, nnb, mbval, ntests, nbval,
132 $ ntests, ngrids, pval, ntests, qval, ntests,
133 $ thresh, mem, iam, nprocs )
134 check = ( thresh.GE.0.0e+0 )
145 WRITE( nout, fmt = * )
146 IF(
lsamen( 2, fact,
'QR' ) )
THEN
149 WRITE( nout, fmt = 9986 )
150 $
'QR factorization tests.'
151 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
154 WRITE( nout, fmt = 9986 )
155 $
'QL factorization tests.'
156 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
159 WRITE( nout, fmt = 9986 )
160 $
'LQ factorization tests.'
161 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
164 WRITE( nout, fmt = 9986 )
165 $
'RQ factorization tests.'
166 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
169 WRITE( nout, fmt = 9986 )
170 $
'QR factorization with column pivoting tests.'
171 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
174 WRITE( nout, fmt = 9986 )
175 $
'Complete orthogonal factorization tests.'
177 WRITE( nout, fmt = * )
178 WRITE( nout, fmt = 9995 )
179 WRITE( nout, fmt = 9994 )
180 WRITE( nout, fmt = * )
193 IF( nprow.LT.1 )
THEN
195 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
197 ELSE IF( npcol.LT.1 )
THEN
199 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
201 ELSE IF( nprow*npcol.GT.nprocs )
THEN
203 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
207 IF( ierr( 1 ).GT.0 )
THEN
209 $
WRITE( nout, fmt = 9997 )
'grid'
216 CALL blacs_get( -1, 0, ictxt )
217 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
218 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
222 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
235 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'M', m
237 ELSE IF( n.LT.1 )
THEN
239 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
245 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
247 IF( ierr( 1 ).GT.0 )
THEN
249 $
WRITE( nout, fmt = 9997 )
'matrix'
267 $
WRITE( nout, fmt = 9999 )
'MB',
'MB', mb
272 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
275 IF( ierr( 1 ).GT.0 )
THEN
277 $
WRITE( nout, fmt = 9997 )
'MB'
288 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
293 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
296 IF( ierr( 1 ).GT.0 )
THEN
298 $
WRITE( nout, fmt = 9997 )
'NB'
305 mp =
numroc( m, mb, myrow, 0, nprow )
306 nq =
numroc( n, nb, mycol, 0, npcol )
307 mnp =
numroc(
min( m, n ), mb, myrow, 0, nprow )
308 mnq =
numroc(
min( m, n ), nb, mycol, 0, npcol )
310 iprepad =
max( mb, mp )
312 ipostpad =
max( nb, nq )
321 CALL descinit( desca, m, n, mb, nb, 0, 0, ictxt,
322 $
max( 1, mp ) + imidpad, ierr( 1 ) )
326 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
329 IF( ierr( 1 ).LT.0 )
THEN
331 $
WRITE( nout, fmt = 9997 )
'descriptor'
340 iptau = ipa + desca( lld_ ) * nq + ipostpad + iprepad
342 IF(
lsamen( 2, fact,
'QR' ) )
THEN
345 ipw = iptau + ltau + ipostpad + iprepad
350 lwork = desca( nb_ ) * ( mp + nq + desca( nb_ ) )
351 workfct = lwork + ipostpad
360 worksiz = lwork + mp*desca( nb_ ) + ipostpad
364 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
367 ipw = iptau + ltau + ipostpad + iprepad
372 lwork = desca( nb_ ) * ( mp + nq + desca( nb_ ) )
373 workfct = lwork + ipostpad
382 worksiz = lwork + mp*desca( nb_ ) + ipostpad
386 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
389 ipw = iptau + ltau + ipostpad + iprepad
394 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
395 workfct = lwork + ipostpad
405 $
max( mp*desca( nb_ ), nq*desca( mb_ )
410 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
413 ipw = iptau + ltau + ipostpad + iprepad
418 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
419 workfct = lwork + ipostpad
429 $
max( mp*desca( nb_ ), nq*desca( mb_ )
434 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
437 ippiv = iptau + ltau + ipostpad + iprepad
438 lipiv =
iceil( intgsz*nq, dblesz )
439 ipw = ippiv + lipiv + ipostpad + iprepad
444 lwork =
max( 3, mp +
max( 1, nq ) ) + 2 * nq
445 workfct = lwork + ipostpad
454 worksiz =
max( worksiz - ipostpad,
455 $ desca( nb_ )*( 2*mp + nq + desca( nb_ ) ) ) +
459 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
462 ipw = iptau + ltau + ipostpad + iprepad
467 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
468 workfct = lwork + ipostpad
478 $
max( mp*desca( nb_ ), nq*desca( mb_ )
488 IF( ipw+worksiz.GT.memsiz )
THEN
490 $
WRITE( nout, fmt = 9996 )
491 $ fact //
' factorization',
492 $ ( ipw+worksiz )*dblesz
498 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
501 IF( ierr( 1 ).GT.0 )
THEN
503 $
WRITE( nout, fmt = 9997 )
'MEMORY'
510 CALL pdmatgen( ictxt,
'N',
'N', desca( m_ ),
511 $ desca( n_ ), desca( mb_ ),
512 $ desca( nb_ ), mem( ipa ),
513 $ desca( lld_ ), desca( rsrc_ ),
514 $ desca( csrc_ ), iaseed, 0, mp, 0, nq,
515 $ myrow, mycol, nprow, npcol )
520 CALL pdfillpad( ictxt, mp, nq, mem( ipa-iprepad ),
521 $ desca( lld_ ), iprepad, ipostpad,
523 IF(
lsamen( 2, fact,
'QP' ) )
THEN
525 $ mem( ippiv-iprepad ), lipiv,
526 $ iprepad, ipostpad, padval )
529 $ mem( iptau-iprepad ), ltau,
530 $ iprepad, ipostpad, padval )
531 CALL pdfillpad( ictxt, worksiz-ipostpad, 1,
532 $ mem( ipw-iprepad ),
534 $ iprepad, ipostpad, padval )
535 anorm =
pdlange(
'I', m, n, mem( ipa ), 1, 1,
536 $ desca, mem( ipw ) )
537 CALL pdchekpad( ictxt,
'PDLANGE', mp, nq,
538 $ mem( ipa-iprepad ), desca( lld_ ),
539 $ iprepad, ipostpad, padval )
541 $ worksiz-ipostpad, 1,
542 $ mem( ipw-iprepad ),
543 $ worksiz-ipostpad, iprepad,
545 CALL pdfillpad( ictxt, workfct-ipostpad, 1,
546 $ mem( ipw-iprepad ),
548 $ iprepad, ipostpad, padval )
552 CALL blacs_barrier( ictxt,
'All' )
556 IF(
lsamen( 2, fact,
'QR' ) )
THEN
558 CALL pdgeqrf( m, n, mem( ipa ), 1, 1, desca,
559 $ mem( iptau ), mem( ipw ), lwork,
562 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
564 CALL pdgeqlf( m, n, mem( ipa ), 1, 1, desca,
565 $ mem( iptau ), mem( ipw ), lwork,
568 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
570 CALL pdgelqf( m, n, mem( ipa ), 1, 1, desca,
571 $ mem( iptau ), mem( ipw ), lwork,
574 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
576 CALL pdgerqf( m, n, mem( ipa ), 1, 1, desca,
577 $ mem( iptau ), mem( ipw ), lwork,
580 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
582 CALL pdgeqpf( m, n, mem( ipa ), 1, 1, desca,
583 $ mem( ippiv ), mem( iptau ),
584 $ mem( ipw ), lwork, info )
586 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
589 $
CALL pdtzrzf( m, n, mem( ipa ), 1, 1, desca,
590 $ mem( iptau ), mem( ipw ), lwork,
600 $ mem( ipa-iprepad ), desca( lld_ ),
601 $ iprepad, ipostpad, padval )
603 $ mem( iptau-iprepad ), ltau,
604 $ iprepad, ipostpad, padval )
605 IF(
lsamen( 2, fact,
'QP' ) )
THEN
607 $ mem( ippiv-iprepad ), lipiv,
608 $ iprepad, ipostpad, padval )
610 CALL pdchekpad( ictxt, rout, workfct-ipostpad, 1,
611 $ mem( ipw-iprepad ),
612 $ workfct-ipostpad, iprepad,
614 CALL pdfillpad( ictxt, worksiz-ipostpad, 1,
615 $ mem( ipw-iprepad ),
617 $ iprepad, ipostpad, padval )
619 IF(
lsamen( 2, fact,
'QR' ) )
THEN
623 CALL pdgeqrrv( m, n, mem( ipa ), 1, 1, desca,
624 $ mem( iptau ), mem( ipw ) )
625 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
626 $ 1, desca, iaseed, anorm, fresid,
628 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
632 CALL pdgeqlrv( m, n, mem( ipa ), 1, 1, desca,
633 $ mem( iptau ), mem( ipw ) )
634 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
635 $ 1, desca, iaseed, anorm, fresid,
637 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
641 CALL pdgelqrv( m, n, mem( ipa ), 1, 1, desca,
642 $ mem( iptau ), mem( ipw ) )
643 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
644 $ 1, desca, iaseed, anorm, fresid,
646 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
650 CALL pdgerqrv( m, n, mem( ipa ), 1, 1, desca,
651 $ mem( iptau ), mem( ipw ) )
652 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
653 $ 1, desca, iaseed, anorm, fresid,
655 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
659 CALL pdgeqrrv( m, n, mem( ipa ), 1, 1, desca,
660 $ mem( iptau ), mem( ipw ) )
661 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
666 CALL pdtzrzrv( m, n, mem( ipa ), 1, 1, desca,
667 $ mem( iptau ), mem( ipw ) )
669 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
670 $ 1, desca, iaseed, anorm, fresid,
677 $ mem( ipa-iprepad ), desca( lld_ ),
678 $ iprepad, ipostpad, padval )
680 $ mem( iptau-iprepad ), ltau,
681 $ iprepad, ipostpad, padval )
682 CALL pdchekpad( ictxt, routchk, worksiz-ipostpad,
683 $ 1, mem( ipw-iprepad ),
684 $ worksiz-ipostpad, iprepad,
687 IF(
lsamen( 2, fact,
'QP' ) )
THEN
689 CALL pdqppiv( m, n, mem( ipa ), 1, 1, desca,
694 CALL pdchekpad( ictxt,
'PDQPPIV', mp, nq,
695 $ mem( ipa-iprepad ),
697 $ iprepad, ipostpad, padval )
698 CALL pdchekpad( ictxt,
'PDQPPIV', lipiv, 1,
699 $ mem( ippiv-iprepad ), lipiv,
700 $ iprepad, ipostpad, padval )
702 CALL pdlafchk(
'No',
'No', m, n, mem( ipa ), 1,
703 $ 1, desca, iaseed, anorm, fresid,
708 CALL pdchekpad( ictxt,
'PDLAFCHK', mp, nq,
709 $ mem( ipa-iprepad ),
711 $ iprepad, ipostpad, padval )
713 $ worksiz-ipostpad, 1,
714 $ mem( ipw-iprepad ),
715 $ worksiz-ipostpad, iprepad,
721 IF(
lsamen( 2, fact,
'TZ' ) .AND. n.LT.m )
THEN
725 IF( fresid.LE.thresh .AND.
726 $ (fresid-fresid).EQ.0.0d+0 )
THEN
740 fresid = fresid - fresid
747 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
748 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
752 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
757 IF(
lsamen( 2, fact,
'TZ' ) )
THEN
766 $ dble( n )*( dble( m )**2 ) -
768 $ dble( n )*dble( m ) ) +
769 $ dble( m )**2 ) / 2.0d+0
777 nops = 2.0d+0 * ( dble( minmn )**2 ) *
778 $ ( dble( maxmn )-dble( minmn ) / 3.0d+0 ) +
779 $ ( dble( maxmn )+dble( minmn ) )*dble( minmn )
784 IF( wtime( 1 ).GT.0.0d+0 )
THEN
785 tmflops = nops / ( wtime( 1 ) * 1.0d+6 )
789 IF( wtime( 1 ).GE.0.0d+0 )
790 $
WRITE( nout, fmt = 9993 )
'WALL', m, n, mb, nb,
791 $ nprow, npcol, wtime( 1 ), tmflops,
796 IF( ctime( 1 ).GT.0.0d+0 )
THEN
797 tmflops = nops / ( ctime( 1 ) * 1.0d+6 )
801 IF( ctime( 1 ).GE.0.0d+0 )
802 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n, mb, nb,
803 $ nprow, npcol, ctime( 1 ), tmflops,
812 CALL blacs_gridexit( ictxt )
821 ktests = kpass + kfail + kskip
822 WRITE( nout, fmt = * )
823 WRITE( nout, fmt = 9992 ) ktests
825 WRITE( nout, fmt = 9991 ) kpass
826 WRITE( nout, fmt = 9989 ) kfail
828 WRITE( nout, fmt = 9990 ) kpass
830 WRITE( nout, fmt = 9988 ) kskip
831 WRITE( nout, fmt = * )
832 WRITE( nout, fmt = * )
833 WRITE( nout, fmt = 9987 )
834 IF( nout.NE.6 .AND. nout.NE.0 )
840 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
841 $
'; It should be at least 1' )
842 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
844 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
845 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
847 9995
FORMAT(
'TIME M N MB NB P Q Fact Time ',
848 $
' MFLOPS CHECK Residual' )
849 9994
FORMAT(
'---- ------ ------ --- --- ----- ----- --------- ',
850 $
'----------- ------ --------' )
851 9993
FORMAT( a4, 1x, i6, 1x, i6, 1x, i3, 1x, i3, 1x, i5, 1x, i5, 1x,
852 $ f9.2, 1x, f11.2, 1x, a6, 2x, g8.1 )
853 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
854 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
855 9990
FORMAT( i5,
' tests completed without checking.' )
856 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
857 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
858 9987
FORMAT(
'END OF TESTS.' )
867 SUBROUTINE pdqppiv( M, N, A, IA, JA, DESCA, IPIV )
878 INTEGER DESCA( * ), IPIV( * )
879 DOUBLE PRECISION A( * )
978 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
979 $ LLD_, MB_, M_, NB_, N_, RSRC_
980 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
981 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
982 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
985 INTEGER IACOL, ICOFFA, ICTXT, IITMP, IPVT, IPCOL,
986 $ IPROW, ITMP, J, JJ, JJA, KK, MYCOL, MYROW,
990 EXTERNAL blacs_gridinfo, igebr2d, igebs2d, igerv2d,
991 $ igesd2d, igamn2d,
infog1l, pdswap
994 INTEGER INDXL2G, NUMROC
995 EXTERNAL indxl2g, numroc
1004 ictxt = desca( ctxt_ )
1005 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
1006 CALL infog1l( ja, desca( nb_ ), npcol, mycol, desca( csrc_ ), jja,
1008 icoffa = mod( ja-1, desca( nb_ ) )
1009 nq = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
1010 IF( mycol.EQ.iacol )
1013 DO 20 j = ja, ja+n-2
1020 CALL infog1l( j, desca( nb_ ), npcol, mycol, desca( csrc_ ),
1022 DO 10 kk = jj, jja+nq-1
1023 IF( ipiv( kk ).LT.ipvt )
THEN
1031 CALL igamn2d( ictxt,
'Rowwise',
' ', 1, 1, ipvt, 1, iprow,
1032 $ ipcol, 1, -1, mycol )
1036 IF( mycol.EQ.ipcol )
THEN
1037 itmp = indxl2g( iitmp, desca( nb_ ), mycol, desca( csrc_ ),
1039 CALL igebs2d( ictxt,
'Rowwise',
' ', 1, 1, itmp, 1 )
1040 IF( ipcol.NE.iacol )
THEN
1041 CALL igerv2d( ictxt, 1, 1, ipiv( iitmp ), 1, myrow,
1044 IF( mycol.EQ.iacol )
1045 $ ipiv( iitmp ) = ipiv( jj )
1048 CALL igebr2d( ictxt,
'Rowwise',
' ', 1, 1, itmp, 1, myrow,
1050 IF( mycol.EQ.iacol .AND. ipcol.NE.iacol )
1051 $
CALL igesd2d( ictxt, 1, 1, ipiv( jj ), 1, myrow, ipcol )
1056 CALL pdswap( m, a, ia, itmp, desca, 1, a, ia, j, desca, 1 )