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 intgsz, memsiz, ntests, realsz, totmem
73 parameter( intgsz = 4, realsz = 4, totmem = 2000000,
74 $ memsiz = totmem / realsz, ntests = 20,
75 $ padval = -9923.0e+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,
91 REAL anorm, fresid, thresh
92 DOUBLE PRECISION 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 )
100 DOUBLE PRECISION ctime( 1 ), wtime( 1 )
103 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
104 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
123 DATA ktests, kpass, kfail, kskip /4*0/
129 CALL blacs_pinfo( iam, nprocs )
131 CALL psqrinfo( outfile, nout, nfact, factor, ntests, nmat, mval,
132 $ ntests, nval, ntests, nnb, mbval, ntests, nbval,
133 $ ntests, ngrids, pval, ntests, qval, ntests,
134 $ thresh, mem, iam, nprocs )
135 check = ( thresh.GE.0.0e+0 )
146 WRITE( nout, fmt = * )
147 IF(
lsamen( 2, fact,
'QR' ) )
THEN
150 WRITE( nout, fmt = 9986 )
151 $
'QR factorization tests.'
152 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
155 WRITE( nout, fmt = 9986 )
156 $
'QL factorization tests.'
157 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
160 WRITE( nout, fmt = 9986 )
161 $
'LQ factorization tests.'
162 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
165 WRITE( nout, fmt = 9986 )
166 $
'RQ factorization tests.'
167 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
170 WRITE( nout, fmt = 9986 )
171 $
'QR factorization with column pivoting tests.'
172 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
175 WRITE( nout, fmt = 9986 )
176 $
'Complete orthogonal factorization tests.'
178 WRITE( nout, fmt = * )
179 WRITE( nout, fmt = 9995 )
180 WRITE( nout, fmt = 9994 )
181 WRITE( nout, fmt = * )
194 IF( nprow.LT.1 )
THEN
196 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
198 ELSE IF( npcol.LT.1 )
THEN
200 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
202 ELSE IF( nprow*npcol.GT.nprocs )
THEN
204 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
208 IF( ierr( 1 ).GT.0 )
THEN
210 $
WRITE( nout, fmt = 9997 )
'grid'
217 CALL blacs_get( -1, 0, ictxt )
218 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
219 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
223 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
236 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'M', m
238 ELSE IF( n.LT.1 )
THEN
240 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
246 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
248 IF( ierr( 1 ).GT.0 )
THEN
250 $
WRITE( nout, fmt = 9997 )
'matrix'
268 $
WRITE( nout, fmt = 9999 )
'MB',
'MB', mb
273 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
276 IF( ierr( 1 ).GT.0 )
THEN
278 $
WRITE( nout, fmt = 9997 )
'MB'
289 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
294 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
297 IF( ierr( 1 ).GT.0 )
THEN
299 $
WRITE( nout, fmt = 9997 )
'NB'
306 mp =
numroc( m, mb, myrow, 0, nprow )
307 nq =
numroc( n, nb, mycol, 0, npcol )
308 mnp =
numroc(
min( m, n ), mb, myrow, 0, nprow )
309 mnq =
numroc(
min( m, n ), nb, mycol, 0, npcol )
311 iprepad =
max( mb, mp )
313 ipostpad =
max( nb, nq )
322 CALL descinit( desca, m, n, mb, nb, 0, 0, ictxt,
323 $
max( 1, mp ) + imidpad, ierr( 1 ) )
327 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
330 IF( ierr( 1 ).LT.0 )
THEN
332 $
WRITE( nout, fmt = 9997 )
'descriptor'
341 iptau = ipa + desca( lld_ ) * nq + ipostpad + iprepad
343 IF(
lsamen( 2, fact,
'QR' ) )
THEN
346 ipw = iptau + ltau + ipostpad + iprepad
351 lwork = desca( nb_ ) * ( mp + nq + desca( nb_ ) )
352 workfct = lwork + ipostpad
361 worksiz = lwork + mp*desca( nb_ ) + ipostpad
365 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
368 ipw = iptau + ltau + ipostpad + iprepad
373 lwork = desca( nb_ ) * ( mp + nq + desca( nb_ ) )
374 workfct = lwork + ipostpad
383 worksiz = lwork + mp*desca( nb_ ) + ipostpad
387 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
390 ipw = iptau + ltau + ipostpad + iprepad
395 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
396 workfct = lwork + ipostpad
406 $
max( mp*desca( nb_ ), nq*desca( mb_ )
411 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
414 ipw = iptau + ltau + ipostpad + iprepad
419 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
420 workfct = lwork + ipostpad
430 $
max( mp*desca( nb_ ), nq*desca( mb_ )
435 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
438 ippiv = iptau + ltau + ipostpad + iprepad
439 lipiv =
iceil( intgsz*nq, realsz )
440 ipw = ippiv + lipiv + ipostpad + iprepad
445 lwork =
max( 3, mp +
max( 1, nq ) ) + 2 * nq
446 workfct = lwork + ipostpad
455 worksiz =
max( worksiz - ipostpad,
456 $ desca( nb_ )*( 2*mp + nq + desca( nb_ ) ) ) +
460 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
463 ipw = iptau + ltau + ipostpad + iprepad
468 lwork = desca( mb_ ) * ( mp + nq + desca( mb_ ) )
469 workfct = lwork + ipostpad
479 $
max( mp*desca( nb_ ), nq*desca( mb_ )
489 IF( ipw+worksiz.GT.memsiz )
THEN
491 $
WRITE( nout, fmt = 9996 )
492 $ fact //
' factorization',
493 $ ( ipw+worksiz )*realsz
499 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1,
502 IF( ierr( 1 ).GT.0 )
THEN
504 $
WRITE( nout, fmt = 9997 )
'MEMORY'
511 CALL psmatgen( ictxt,
'N',
'N', desca( m_ ),
512 $ desca( n_ ), desca( mb_ ),
513 $ desca( nb_ ), mem( ipa ),
514 $ desca( lld_ ), desca( rsrc_ ),
515 $ desca( csrc_ ), iaseed, 0, mp, 0, nq,
516 $ myrow, mycol, nprow, npcol )
521 CALL psfillpad( ictxt, mp, nq, mem( ipa-iprepad ),
522 $ desca( lld_ ), iprepad, ipostpad,
524 IF(
lsamen( 2, fact,
'QP' ) )
THEN
526 $ mem( ippiv-iprepad ), lipiv,
527 $ iprepad, ipostpad, padval )
530 $ mem( iptau-iprepad ), ltau,
531 $ iprepad, ipostpad, padval )
532 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
533 $ mem( ipw-iprepad ),
535 $ iprepad, ipostpad, padval )
536 anorm =
pslange(
'I', m, n, mem( ipa ), 1, 1,
537 $ desca, mem( ipw ) )
538 CALL pschekpad( ictxt,
'PSLANGE', mp, nq,
539 $ mem( ipa-iprepad ), desca( lld_ ),
540 $ iprepad, ipostpad, padval )
542 $ worksiz-ipostpad, 1,
543 $ mem( ipw-iprepad ),
544 $ worksiz-ipostpad, iprepad,
546 CALL psfillpad( ictxt, workfct-ipostpad, 1,
547 $ mem( ipw-iprepad ),
549 $ iprepad, ipostpad, padval )
553 CALL blacs_barrier( ictxt,
'All' )
557 IF(
lsamen( 2, fact,
'QR' ) )
THEN
559 CALL psgeqrf( m, n, mem( ipa ), 1, 1, desca,
560 $ mem( iptau ), mem( ipw ), lwork,
563 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
565 CALL psgeqlf( m, n, mem( ipa ), 1, 1, desca,
566 $ mem( iptau ), mem( ipw ), lwork,
569 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
571 CALL psgelqf( m, n, mem( ipa ), 1, 1, desca,
572 $ mem( iptau ), mem( ipw ), lwork,
575 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
577 CALL psgerqf( m, n, mem( ipa ), 1, 1, desca,
578 $ mem( iptau ), mem( ipw ), lwork,
581 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
583 CALL psgeqpf( m, n, mem( ipa ), 1, 1, desca,
584 $ mem( ippiv ), mem( iptau ),
585 $ mem( ipw ), lwork, info )
587 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
590 $
CALL pstzrzf( m, n, mem( ipa ), 1, 1, desca,
591 $ mem( iptau ), mem( ipw ), lwork,
601 $ mem( ipa-iprepad ), desca( lld_ ),
602 $ iprepad, ipostpad, padval )
604 $ mem( iptau-iprepad ), ltau,
605 $ iprepad, ipostpad, padval )
606 IF(
lsamen( 2, fact,
'QP' ) )
THEN
608 $ mem( ippiv-iprepad ), lipiv,
609 $ iprepad, ipostpad, padval )
611 CALL pschekpad( ictxt, rout, workfct-ipostpad, 1,
612 $ mem( ipw-iprepad ),
613 $ workfct-ipostpad, iprepad,
615 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
616 $ mem( ipw-iprepad ),
618 $ iprepad, ipostpad, padval )
620 IF(
lsamen( 2, fact,
'QR' ) )
THEN
624 CALL psgeqrrv( m, n, mem( ipa ), 1, 1, desca,
625 $ mem( iptau ), mem( ipw ) )
626 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
627 $ 1, desca, iaseed, anorm, fresid,
629 ELSE IF(
lsamen( 2, fact,
'QL' ) )
THEN
633 CALL psgeqlrv( m, n, mem( ipa ), 1, 1, desca,
634 $ mem( iptau ), mem( ipw ) )
635 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
636 $ 1, desca, iaseed, anorm, fresid,
638 ELSE IF(
lsamen( 2, fact,
'LQ' ) )
THEN
642 CALL psgelqrv( m, n, mem( ipa ), 1, 1, desca,
643 $ mem( iptau ), mem( ipw ) )
644 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
645 $ 1, desca, iaseed, anorm, fresid,
647 ELSE IF(
lsamen( 2, fact,
'RQ' ) )
THEN
651 CALL psgerqrv( m, n, mem( ipa ), 1, 1, desca,
652 $ mem( iptau ), mem( ipw ) )
653 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
654 $ 1, desca, iaseed, anorm, fresid,
656 ELSE IF(
lsamen( 2, fact,
'QP' ) )
THEN
660 CALL psgeqrrv( m, n, mem( ipa ), 1, 1, desca,
661 $ mem( iptau ), mem( ipw ) )
662 ELSE IF(
lsamen( 2, fact,
'TZ' ) )
THEN
667 CALL pstzrzrv( m, n, mem( ipa ), 1, 1, desca,
668 $ mem( iptau ), mem( ipw ) )
670 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
671 $ 1, desca, iaseed, anorm, fresid,
678 $ mem( ipa-iprepad ), desca( lld_ ),
679 $ iprepad, ipostpad, padval )
681 $ mem( iptau-iprepad ), ltau,
682 $ iprepad, ipostpad, padval )
683 CALL pschekpad( ictxt, routchk, worksiz-ipostpad,
684 $ 1, mem( ipw-iprepad ),
685 $ worksiz-ipostpad, iprepad,
688 IF(
lsamen( 2, fact,
'QP' ) )
THEN
690 CALL psqppiv( m, n, mem( ipa ), 1, 1, desca,
695 CALL pschekpad( ictxt,
'PSQPPIV', mp, nq,
696 $ mem( ipa-iprepad ),
698 $ iprepad, ipostpad, padval )
699 CALL pschekpad( ictxt,
'PSQPPIV', lipiv, 1,
700 $ mem( ippiv-iprepad ), lipiv,
701 $ iprepad, ipostpad, padval )
703 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1,
704 $ 1, desca, iaseed, anorm, fresid,
709 CALL pschekpad( ictxt,
'PSLAFCHK', mp, nq,
710 $ mem( ipa-iprepad ),
712 $ iprepad, ipostpad, padval )
714 $ worksiz-ipostpad, 1,
715 $ mem( ipw-iprepad ),
716 $ worksiz-ipostpad, iprepad,
722 IF(
lsamen( 2, fact,
'TZ' ) .AND. n.LT.m )
THEN
726 IF( fresid.LE.thresh .AND.
727 $ (fresid-fresid).EQ.0.0e+0 )
THEN
741 fresid = fresid - fresid
748 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
749 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
753 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
758 IF(
lsamen( 2, fact,
'TZ' ) )
THEN
767 $ dble( n )*( dble( m )**2 ) -
769 $ dble( n )*dble( m ) ) +
770 $ dble( m )**2 ) / 2.0d+0
778 nops = 2.0d+0 * ( dble( minmn )**2 ) *
779 $ ( dble( maxmn )-dble( minmn ) / 3.0d+0 ) +
780 $ ( dble( maxmn )+dble( minmn ) )*dble( minmn )
785 IF( wtime( 1 ).GT.0.0d+0 )
THEN
786 tmflops = nops / ( wtime( 1 ) * 1.0d+6 )
790 IF( wtime( 1 ).GE.0.0d+0 )
791 $
WRITE( nout, fmt = 9993 )
'WALL', m, n, mb, nb,
792 $ nprow, npcol, wtime( 1 ), tmflops,
797 IF( ctime( 1 ).GT.0.0d+0 )
THEN
798 tmflops = nops / ( ctime( 1 ) * 1.0d+6 )
802 IF( ctime( 1 ).GE.0.0d+0 )
803 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n, mb, nb,
804 $ nprow, npcol, ctime( 1 ), tmflops,
813 CALL blacs_gridexit( ictxt )
822 ktests = kpass + kfail + kskip
823 WRITE( nout, fmt = * )
824 WRITE( nout, fmt = 9992 ) ktests
826 WRITE( nout, fmt = 9991 ) kpass
827 WRITE( nout, fmt = 9989 ) kfail
829 WRITE( nout, fmt = 9990 ) kpass
831 WRITE( nout, fmt = 9988 ) kskip
832 WRITE( nout, fmt = * )
833 WRITE( nout, fmt = * )
834 WRITE( nout, fmt = 9987 )
835 IF( nout.NE.6 .AND. nout.NE.0 )
841 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
842 $
'; It should be at least 1' )
843 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
845 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
846 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
848 9995
FORMAT(
'TIME M N MB NB P Q Fact Time ',
849 $
' MFLOPS CHECK Residual' )
850 9994
FORMAT(
'---- ------ ------ --- --- ----- ----- --------- ',
851 $
'----------- ------ --------' )
852 9993
FORMAT( a4, 1x, i6, 1x, i6, 1x, i3, 1x, i3, 1x, i5, 1x, i5, 1x,
853 $ f9.2, 1x, f11.2, 1x, a6, 2x, g8.1 )
854 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
855 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
856 9990
FORMAT( i5,
' tests completed without checking.' )
857 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
858 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
859 9987
FORMAT(
'END OF TESTS.' )
868 SUBROUTINE psqppiv( M, N, A, IA, JA, DESCA, IPIV )
879 INTEGER DESCA( * ), IPIV( * )
979 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
980 $ LLD_, MB_, M_, NB_, N_, RSRC_
981 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
982 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
983 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
986 INTEGER IACOL, ICOFFA, ICTXT, IITMP, IPVT, IPCOL,
987 $ IPROW, ITMP, J, JJ, JJA, KK, MYCOL, MYROW,
991 EXTERNAL blacs_gridinfo, igebr2d, igebs2d, igerv2d,
992 $ igesd2d, igamn2d,
infog1l, psswap
995 INTEGER INDXL2G, NUMROC
996 EXTERNAL indxl2g, numroc
1005 ictxt = desca( ctxt_ )
1006 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
1007 CALL infog1l( ja, desca( nb_ ), npcol, mycol, desca( csrc_ ), jja,
1009 icoffa = mod( ja-1, desca( nb_ ) )
1010 nq = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
1011 IF( mycol.EQ.iacol )
1014 DO 20 j = ja, ja+n-2
1021 CALL infog1l( j, desca( nb_ ), npcol, mycol, desca( csrc_ ),
1023 DO 10 kk = jj, jja+nq-1
1024 IF( ipiv( kk ).LT.ipvt )
THEN
1032 CALL igamn2d( ictxt,
'Rowwise',
' ', 1, 1, ipvt, 1, iprow,
1033 $ ipcol, 1, -1, mycol )
1037 IF( mycol.EQ.ipcol )
THEN
1038 itmp = indxl2g( iitmp, desca( nb_ ), mycol, desca( csrc_ ),
1040 CALL igebs2d( ictxt,
'Rowwise',
' ', 1, 1, itmp, 1 )
1041 IF( ipcol.NE.iacol )
THEN
1042 CALL igerv2d( ictxt, 1, 1, ipiv( iitmp ), 1, myrow,
1045 IF( mycol.EQ.iacol )
1046 $ ipiv( iitmp ) = ipiv( jj )
1049 CALL igebr2d( ictxt,
'Rowwise',
' ', 1, 1, itmp, 1, myrow,
1051 IF( mycol.EQ.iacol .AND. ipcol.NE.iacol )
1052 $
CALL igesd2d( ictxt, 1, 1, ipiv( jj ), 1, myrow, ipcol )
1057 CALL psswap( m, a, ia, itmp, desca, 1, a, ia, j, desca, 1 )