61 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
62 $ lld_, mb_, m_, nb_, n_, rsrc_
63 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
64 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
65 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
66 INTEGER memsiz, ntests, realsz, totmem
68 parameter( realsz = 4, totmem = 2000000,
69 $ memsiz = totmem / realsz, ntests = 20,
70 $ padval = -9923.0e+0 )
76 INTEGER i, iam, iaseed, ictxt, imidpad, info, ipa, ipd,
77 $ ipe, ipostpad, iprepad, iptp, iptq, ipw, j, k,
78 $ kfail, kpass, kskip, ktests, lwork, m, maxmn,
79 $ minmn, mnp, mnq, mp, mycol, myrow, n, nb,
80 $ ndiag, ngrids, nmat, nnb, noffd, nout, npcol,
81 $ nprocs, nprow, nq, workbrd, worksiz
82 REAL anorm, fresid, thresh
83 DOUBLE PRECISION nops, tmflops
86 INTEGER desca( dlen_ ), ierr( 1 ), nbval( ntests ),
87 $ mval( ntests ), nval( ntests ),
88 $ pval( ntests ), qval( ntests )
90 DOUBLE PRECISION ctime( 1 ), wtime( 1 )
93 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
94 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
109 DATA ktests, kpass, kfail, kskip / 4*0 /
115 CALL blacs_pinfo( iam, nprocs )
117 CALL psbrdinfo( outfile, nout, nmat, mval, ntests, nval, ntests,
118 $ nnb, nbval, ntests, ngrids, pval, ntests, qval,
119 $ ntests, thresh, mem, iam, nprocs )
120 check = ( thresh.GE.0.0e+0 )
125 WRITE( nout, fmt = * )
126 WRITE( nout, fmt = 9995 )
127 WRITE( nout, fmt = 9994 )
128 WRITE( nout, fmt = * )
141 IF( nprow.LT.1 )
THEN
143 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
145 ELSE IF( npcol.LT.1 )
THEN
147 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
149 ELSE IF( nprow*npcol.GT.nprocs )
THEN
151 $
WRITE( nout, fmt = 9998 ) nprow*npcol, nprocs
155 IF( ierr( 1 ).GT.0 )
THEN
157 $
WRITE( nout, fmt = 9997 )
'grid'
164 CALL blacs_get( -1, 0, ictxt )
165 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
166 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
168 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
183 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'M', m
185 ELSE IF( n.LT.1 )
THEN
187 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
193 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
195 IF( ierr( 1 ).GT.0 )
THEN
197 $
WRITE( nout, fmt = 9997 )
'matrix'
214 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
219 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
221 IF( ierr( 1 ).GT.0 )
THEN
223 $
WRITE( nout, fmt = 9997 )
'NB'
230 mp =
numroc( m, nb, myrow, 0, nprow )
231 nq =
numroc( n, nb, mycol, 0, npcol )
232 mnp =
numroc(
min( m, n ), nb, myrow, 0, nprow )
233 mnq =
numroc(
min( m, n ), nb, mycol, 0, npcol )
235 iprepad =
max( nb, mp )
237 ipostpad =
max( nb, nq )
246 CALL descinit( desca, m, n, nb, nb, 0, 0, ictxt,
247 $
max( 1, mp )+imidpad, ierr( 1 ) )
249 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
251 IF( ierr( 1 ).LT.0 )
THEN
253 $
WRITE( nout, fmt = 9997 )
'descriptor'
266 noffd =
numroc(
min( m, n )-1, nb, mycol, 0, npcol )
270 ipd = ipa + desca( lld_ )*nq + ipostpad + iprepad
271 ipe = ipd + ndiag + ipostpad + iprepad
272 iptq = ipe + noffd + ipostpad + iprepad
273 iptp = iptq + mnq + ipostpad + iprepad
274 ipw = iptp + mnp + ipostpad + iprepad
279 lwork = nb*( mp+nq+1 ) + nq
280 workbrd = lwork + ipostpad
286 worksiz =
max( lwork, 2*nb*( mp+nq+nb ) ) + ipostpad
292 IF( ipw+worksiz.GT.memsiz )
THEN
294 $
WRITE( nout, fmt = 9996 )
'Bidiagonal reduction',
295 $ ( ipw+worksiz )*realsz
301 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
303 IF( ierr( 1 ).GT.0 )
THEN
305 $
WRITE( nout, fmt = 9997 )
'MEMORY'
312 CALL psmatgen( ictxt,
'No',
'No', desca( m_ ),
313 $ desca( n_ ), desca( mb_ ), desca( nb_ ),
314 $ mem( ipa ), desca( lld_ ), desca( rsrc_ ),
315 $ desca( csrc_ ), iaseed, 0, mp, 0, nq,
316 $ myrow, mycol, nprow, npcol )
321 CALL psfillpad( ictxt, mp, nq, mem( ipa-iprepad ),
322 $ desca( lld_ ), iprepad, ipostpad,
324 CALL psfillpad( ictxt, ndiag, 1, mem( ipd-iprepad ),
325 $ ndiag, iprepad, ipostpad, padval )
326 CALL psfillpad( ictxt, noffd, 1, mem( ipe-iprepad ),
327 $ noffd, iprepad, ipostpad, padval )
328 CALL psfillpad( ictxt, mnq, 1, mem( iptq-iprepad ),
329 $ mnq, iprepad, ipostpad, padval )
330 CALL psfillpad( ictxt, mnp, 1, mem( iptp-iprepad ),
331 $ mnp, iprepad, ipostpad, padval )
332 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
333 $ mem( ipw-iprepad ), worksiz-ipostpad,
334 $ iprepad, ipostpad, padval )
335 anorm =
pslange(
'I', m, n, mem( ipa ), 1, 1, desca,
337 CALL pschekpad( ictxt,
'PSLANGE', mp, nq,
338 $ mem( ipa-iprepad ), desca( lld_ ),
339 $ iprepad, ipostpad, padval )
340 CALL pschekpad( ictxt,
'PSLANGE', worksiz-ipostpad,
341 $ 1, mem( ipw-iprepad ),
342 $ worksiz-ipostpad, iprepad, ipostpad,
344 CALL psfillpad( ictxt, workbrd-ipostpad, 1,
345 $ mem( ipw-iprepad ), workbrd-ipostpad,
346 $ iprepad, ipostpad, padval )
350 CALL blacs_barrier( ictxt,
'All' )
355 CALL psgebrd( m, n, mem( ipa ), 1, 1, desca, mem( ipd ),
356 $ mem( ipe ), mem( iptq ), mem( iptp ),
357 $ mem( ipw ), lwork, info )
365 CALL pschekpad( ictxt,
'PSGEBRD', mp, nq,
366 $ mem( ipa-iprepad ), desca( lld_ ),
367 $ iprepad, ipostpad, padval )
368 CALL pschekpad( ictxt,
'PSGEBRD', ndiag, 1,
369 $ mem( ipd-iprepad ), ndiag, iprepad,
371 CALL pschekpad( ictxt,
'PSGEBRD', noffd, 1,
372 $ mem( ipe-iprepad ), noffd, iprepad,
374 CALL pschekpad( ictxt,
'PSGEBRD', mnq, 1,
375 $ mem( iptq-iprepad ), mnq, iprepad,
377 CALL pschekpad( ictxt,
'PSGEBRD', mnp, 1,
378 $ mem( iptp-iprepad ), mnp, iprepad,
380 CALL pschekpad( ictxt,
'PSGEBRD', workbrd-ipostpad,
381 $ 1, mem( ipw-iprepad ),
382 $ workbrd-ipostpad, iprepad,
384 CALL psfillpad( ictxt, worksiz-ipostpad, 1,
385 $ mem( ipw-iprepad ), worksiz-ipostpad,
386 $ iprepad, ipostpad, padval )
390 CALL psgebdrv( m, n, mem( ipa ), 1, 1, desca,
391 $ mem( ipd ), mem( ipe ), mem( iptq ),
392 $ mem( iptp ), mem( ipw ), ierr( 1 ) )
393 CALL pslafchk(
'No',
'No', m, n, mem( ipa ), 1, 1,
394 $ desca, iaseed, anorm, fresid,
399 CALL pschekpad( ictxt,
'PSGEBDRV', mp, nq,
400 $ mem( ipa-iprepad ), desca( lld_ ),
401 $ iprepad, ipostpad, padval )
402 CALL pschekpad( ictxt,
'PSGEBDRV', ndiag, 1,
403 $ mem( ipd-iprepad ), ndiag, iprepad,
405 CALL pschekpad( ictxt,
'PSGEBDRV', noffd, 1,
406 $ mem( ipe-iprepad ), noffd, iprepad,
408 CALL pschekpad( ictxt,
'PSGEBDRV', worksiz-ipostpad,
409 $ 1, mem( ipw-iprepad ),
410 $ worksiz-ipostpad, iprepad,
415 IF( fresid.LE.thresh .AND. fresid-fresid.EQ.0.0e+0
416 $ .AND. ierr( 1 ).EQ.0 )
THEN
420 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
421 $
WRITE( nout, fmt = 9986 ) fresid
427 IF( myrow.EQ.0 .AND. mycol.EQ.0 .AND. ierr( 1 ).NE.0 )
428 $
WRITE( nout, fmt = * )
429 $
'D or E copies incorrect ...'
435 fresid = fresid - fresid
442 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
443 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
447 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
453 nops = 4.0d+0 * dble( minmn ) * dble( minmn ) *
454 $ ( dble( maxmn ) - dble( minmn ) / 3.0d+0 )
459 IF( wtime( 1 ).GT.0.0d+0 )
THEN
460 tmflops = nops / wtime( 1 )
464 IF( wtime( 1 ).GE.0.0d+0 )
465 $
WRITE( nout, fmt = 9993 )
'WALL', m, n, nb, nprow,
466 $ npcol, wtime( 1 ), tmflops, fresid, passed
470 IF( ctime( 1 ).GT.0.0d+0 )
THEN
471 tmflops = nops / ctime( 1 )
475 IF( ctime( 1 ).GE.0.0d+0 )
476 $
WRITE( nout, fmt = 9993 )
'CPU ', m, n, nb, nprow,
477 $ npcol, ctime( 1 ), tmflops, fresid, passed
482 CALL blacs_gridexit( ictxt )
488 ktests = kpass + kfail + kskip
489 WRITE( nout, fmt = * )
490 WRITE( nout, fmt = 9992 ) ktests
492 WRITE( nout, fmt = 9991 ) kpass
493 WRITE( nout, fmt = 9989 ) kfail
495 WRITE( nout, fmt = 9990 ) kpass
497 WRITE( nout, fmt = 9988 ) kskip
498 WRITE( nout, fmt = * )
499 WRITE( nout, fmt = * )
500 WRITE( nout, fmt = 9987 )
501 IF( nout.NE.6 .AND. nout.NE.0 )
CLOSE ( nout )
506 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
507 $
'; It should be at least 1' )
508 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
510 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
511 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
513 9995
FORMAT(
'TIME M N NB P Q BRD Time ',
514 $
' MFLOPS Residual CHECK' )
515 9994
FORMAT(
'---- ------ ------ --- ----- ----- --------- ',
516 $
'----------- -------- ------' )
517 9993
FORMAT( a4, 1x, i6, 1x, i6, 1x, i3, 1x, i5, 1x, i5, 1x, f9.2, 1x,
518 $ f11.2, 1x, f8.2, 1x, a6 )
519 9992
FORMAT(
'Finished', i4,
' tests, with the following results:' )
520 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
521 9990
FORMAT( i5,
' tests completed without checking.' )
522 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
523 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
524 9987
FORMAT(
'END OF TESTS.' )
525 9986
FORMAT(
'||A - Q*B*P|| / (||A|| * N * eps) = ', g25.7 )