62 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dtype_,
63 $ lld_, mb_, m_, nb_, n_, rsrc_
64 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
65 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
66 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
67 INTEGER cplxsz, memsiz, ntests, totmem
69 parameter( cplxsz = 8, totmem = 2000000,
70 $ memsiz = totmem / cplxsz, ntests = 20,
71 $ padval = ( -9923.0e+0, -9923.0e+0 ) )
77 INTEGER i, iam, iaseed, ictxt, ihi, ihip, ihlp, ihlq,
78 $ ilcol, ilo, ilrow, info, inlq, imidpad, ipa,
79 $ ipt, ipw, ipostpad, iprepad, itemp, j, k,
80 $ kfail, kpass, kskip, ktests, lcm, lcmq, loff,
81 $ lwork, mycol, myrow, n, nb, ngrids, nmat, nnb,
82 $ nprocs, nout, np, npcol, nprow, nq, workhrd,
84 REAL anorm, fresid, thresh
85 DOUBLE PRECISION nops, tmflops
88 INTEGER desca( dlen_ ), ierr( 1 ), nbval( ntests ),
89 $ nval( ntests ), nvhi( ntests ), nvlo( ntests ),
90 $ pval( ntests ), qval( ntests )
91 DOUBLE PRECISION ctime( 1 ), wtime( 1 )
95 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
96 $ blacs_gridexit, blacs_gridinit, blacs_gridinfo,
111 DATA ktests, kpass, kfail, kskip / 4*0 /
117 CALL blacs_pinfo( iam, nprocs )
119 CALL pchrdinfo( outfile, nout, nmat, nval, nvlo, nvhi, ntests,
120 $ nnb, nbval, ntests, ngrids, pval, ntests, qval,
121 $ ntests, thresh, mem, iam, nprocs )
122 check = ( thresh.GE.0.0e+0 )
127 WRITE( nout, fmt = * )
128 WRITE( nout, fmt = 9995 )
129 WRITE( nout, fmt = 9994 )
130 WRITE( nout, fmt = * )
143 IF( nprow.LT.1 )
THEN
145 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
147 ELSE IF( npcol.LT.1 )
THEN
149 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
151 ELSE IF( nprow*npcol.GT.nprocs )
THEN
153 $
WRITE( nout, fmt = 9998 )nprow*npcol, nprocs
157 IF( ierr( 1 ).GT.0 )
THEN
159 $
WRITE( nout, fmt = 9997 )
'grid'
166 CALL blacs_get( -1, 0, ictxt )
167 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
168 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
172 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
186 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
192 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
194 IF( ierr( 1 ).GT.0 )
THEN
196 $
WRITE( nout, fmt = 9997 )
'matrix'
210 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
215 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
217 IF( ierr( 1 ).GT.0 )
THEN
219 $
WRITE( nout, fmt = 9997 )
'NB'
224 np =
numroc( n, nb, myrow, 0, nprow )
225 nq =
numroc( n, nb, mycol, 0, npcol )
227 iprepad =
max( nb, np )
229 ipostpad =
max( nb, nq )
238 CALL descinit( desca, n, n, nb, nb, 0, 0, ictxt,
239 $
max( 1, np ) + imidpad, info )
243 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
245 IF( ierr( 1 ).LT.0 )
THEN
247 $
WRITE( nout, fmt = 9997 )
'descriptor'
256 ipt = ipa + desca( lld_ )*nq + ipostpad + iprepad
257 ipw = ipt + nq + ipostpad + iprepad
262 ihip =
numroc( ihi, nb, myrow, desca( rsrc_ ), nprow )
263 loff = mod( ilo-1, nb )
264 ilrow =
indxg2p( ilo, nb, myrow, desca( rsrc_ ), nprow )
265 ilcol =
indxg2p( ilo, nb, mycol, desca( csrc_ ), npcol )
266 ihlp =
numroc( ihi-ilo+loff+1, nb, myrow, ilrow, nprow )
267 inlq =
numroc( n-ilo+loff+1, nb, mycol, ilcol, npcol )
268 lwork = nb*( nb +
max( ihip+1, ihlp+inlq ) )
269 workhrd = lwork + ipostpad
275 lcm =
ilcm( nprow, npcol )
277 ihlq =
numroc( ihi-ilo+loff+1, nb, mycol, ilcol,
279 itemp = nb*
max( ihlp+inlq, ihlq+
max( ihip,
281 $ npcol ), nb, 0, 0, lcmq ) ) )
282 worksiz =
max( nb*nb + nb*ihlp + itemp, nb * np ) +
289 IF( ipw+worksiz.GT.memsiz )
THEN
291 $
WRITE( nout, fmt = 9996 )
'Hessenberg reduction',
292 $ ( ipw+worksiz )*cplxsz
298 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
300 IF( ierr( 1 ).GT.0 )
THEN
302 $
WRITE( nout, fmt = 9997 )
'MEMORY'
309 CALL pcmatgen( ictxt,
'No',
'No', desca( m_ ),
310 $ desca( n_ ), desca( mb_ ), desca( nb_ ),
311 $ mem( ipa ), desca( lld_ ), desca( rsrc_ ),
313 $ iaseed, 0, np, 0, nq, myrow, mycol,
319 CALL pcfillpad( ictxt, np, nq, mem( ipa-iprepad ),
320 $ desca( lld_ ), iprepad, ipostpad,
322 CALL pcfillpad( ictxt, nq, 1, mem( ipt-iprepad ),
323 $ nq, iprepad, ipostpad, padval )
324 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
325 $ mem( ipw-iprepad ), worksiz-ipostpad,
326 $ iprepad, ipostpad, padval )
327 anorm =
pclange(
'I', n, n, mem( ipa ), 1, 1, desca,
329 CALL pcchekpad( ictxt,
'PCLANGE', np, nq,
330 $ mem( ipa-iprepad ), desca( lld_ ),
331 $ iprepad, ipostpad, padval )
333 $ worksiz-ipostpad, 1,
334 $ mem( ipw-iprepad ), worksiz-ipostpad,
335 $ iprepad, ipostpad, padval )
336 CALL pcfillpad( ictxt, workhrd-ipostpad, 1,
337 $ mem( ipw-iprepad ), workhrd-ipostpad,
338 $ iprepad, ipostpad, padval )
342 CALL blacs_barrier( ictxt,
'All' )
347 CALL pcgehrd( n, ilo, ihi, mem( ipa ), 1, 1, desca,
348 $ mem( ipt ), mem( ipw ), lwork, info )
355 CALL pcchekpad( ictxt,
'PCGEHRD', np, nq,
356 $ mem( ipa-iprepad ), desca( lld_ ),
357 $ iprepad, ipostpad, padval )
359 $ mem( ipt-iprepad ), nq, iprepad,
361 CALL pcchekpad( ictxt,
'PCGEHRD', workhrd-ipostpad,
362 $ 1, mem( ipw-iprepad ),
363 $ workhrd-ipostpad, iprepad,
365 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
366 $ mem( ipw-iprepad ), worksiz-ipostpad,
367 $ iprepad, ipostpad, padval )
371 CALL pcgehdrv( n, ilo, ihi, mem( ipa ), 1, 1, desca,
372 $ mem( ipt ), mem( ipw ) )
373 CALL pclafchk(
'No',
'No', n, n, mem( ipa ), 1, 1,
374 $ desca, iaseed, anorm, fresid,
379 CALL pcchekpad( ictxt,
'PCGEHDRV', np, nq,
380 $ mem( ipa-iprepad ), desca( lld_ ),
381 $ iprepad, ipostpad, padval )
382 CALL pcchekpad( ictxt,
'PCGEHDRV', nq, 1,
383 $ mem( ipt-iprepad ), nq, iprepad,
386 $ worksiz-ipostpad, 1,
387 $ mem( ipw-iprepad ), worksiz-ipostpad,
388 $ iprepad, ipostpad, padval )
392 IF( fresid.LE.thresh .AND. fresid-fresid.EQ.0.0e+0 )
397 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
398 $
WRITE( nout, fmt = 9986 ) fresid
407 fresid = fresid - fresid
413 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
414 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
418 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
424 nops = dble( ihi-ilo )
426 $ ( 8.0d0*dble( ihi ) + (16.0d0/3.0d0)*nops )
431 IF( wtime( 1 ).GT.0.0d+0 )
THEN
432 tmflops = nops / wtime( 1 )
436 IF( wtime( 1 ).GE.0.0d+0 )
437 $
WRITE( nout, fmt = 9993 )
'WALL', n, ilo, ihi, nb,
438 $ nprow, npcol, wtime( 1 ), tmflops, fresid,
443 IF( ctime( 1 ).GT.0.0d+0 )
THEN
444 tmflops = nops / ctime( 1 )
448 IF( ctime( 1 ).GE.0.0d+0 )
449 $
WRITE( nout, fmt = 9993 )
'CPU ', n, ilo, ihi, nb,
450 $ nprow, npcol, ctime( 1 ), tmflops, fresid,
456 CALL blacs_gridexit( ictxt )
462 ktests = kpass + kfail + kskip
463 WRITE( nout, fmt = * )
464 WRITE( nout, fmt = 9992 ) ktests
466 WRITE( nout, fmt = 9991 ) kpass
467 WRITE( nout, fmt = 9989 ) kfail
469 WRITE( nout, fmt = 9990 ) kpass
471 WRITE( nout, fmt = 9988 ) kskip
472 WRITE( nout, fmt = * )
473 WRITE( nout, fmt = * )
474 WRITE( nout, fmt = 9987 )
475 IF( nout.NE.6 .AND. nout.NE.0 )
481 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
482 $
'; It should be at least 1' )
483 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
485 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
486 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
488 9995
FORMAT(
'TIME N ILO IHI NB P Q HRD Time ',
489 $
' MFLOPS Residual CHECK' )
490 9994
FORMAT(
'---- ------ ------ ------ --- ----- ----- --------- ',
491 $
'----------- -------- ------' )
492 9993
FORMAT( a4, 1x, i6, 1x, i6, 1x, i6, 1x, i3, 1x, i5, 1x, i5, 1x,
493 $ f9.2, 1x, f11.2, 1x, f8.2, 1x, a6 )
494 9992
FORMAT(
'Finished', i4,
' tests, with the following results:' )
495 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
496 9990
FORMAT( i5,
' tests completed without checking.' )
497 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
498 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
499 9987
FORMAT(
'END OF TESTS.' )
500 9986
FORMAT(
'||A - Q*H*Q''|| / (||A|| * N * eps) = ', g25.7 )