66 INTEGER block_cyclic_2d, csrc_, ctxt_, dlen_, dt_,
67 $ lld_, mb_, m_, nb_, n_, rsrc_
68 parameter( block_cyclic_2d = 1, dlen_ = 9, dt_ = 1,
69 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
70 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
71 INTEGER cplxsz, totmem, memsiz, ntests
72 parameter( cplxsz = 8, totmem = 200000000,
73 $ memsiz = totmem / cplxsz, ntests = 20 )
74 COMPLEX padval, zero, one
75 parameter( padval = ( -9923.0e+0, -9923.0e+0 ),
76 $ zero = ( 0.0e+0, 0.0e+0 ),
77 $ one = ( 1.0e+0, 0.0e+0 ) )
83 INTEGER i, iam, iaseed, icol, ictxt, ii, iii, imidpad,
84 $ info, ipa, ipostpad, iprepad, ipvl, ipvr, ipw,
85 $ ipwr, ipc, irow, j, jj, jjj, k, kfail, kpass,
86 $ kskip, ktests, lda, ldz, lwork, m, mycol,
87 $ myrow, n, nb, ngrids, nmat, nnb, nout, np,
88 $ npcol, nprocs, nprow, nq, worksiz
90 REAL anorm, fresid, qresid
91 DOUBLE PRECISION nops, tmflops
95 INTEGER desca( dlen_ ), descz( dlen_ ), ierr( 2 ),
96 $ nbval( ntests ), nval( ntests ),
97 $ pval( ntests ), qval( ntests )
98 REAL result( 2 ), rwork( 5000 )
99 DOUBLE PRECISION ctime( 2 ), wtime( 2 )
100 COMPLEX mem( memsiz )
103 EXTERNAL blacs_barrier, blacs_exit, blacs_get,
104 $ blacs_gridexit, blacs_gridinfo, blacs_gridinit,
119 DATA kfail, kpass, kskip, ktests / 4*0 /
125 CALL blacs_pinfo( iam, nprocs )
127 CALL pcevcinfo( outfile, nout, nmat, nval, ntests, nnb, nbval,
128 $ ntests, ngrids, pval, ntests, qval, ntests,
129 $ thresh, mem, iam, nprocs )
130 check = ( thresh.GE.0.0e+0 )
135 WRITE( nout, fmt = * )
136 WRITE( nout, fmt = 9995 )
137 WRITE( nout, fmt = 9994 )
138 WRITE( nout, fmt = * )
151 IF( nprow.LT.1 )
THEN
153 $
WRITE( nout, fmt = 9999 )
'GRID',
'nprow', nprow
155 ELSE IF( npcol.LT.1 )
THEN
157 $
WRITE( nout, fmt = 9999 )
'GRID',
'npcol', npcol
159 ELSE IF( nprow*npcol.GT.nprocs )
THEN
161 $
WRITE( nout, fmt = 9998 )nprow*npcol, nprocs
165 IF( ierr( 1 ).GT.0 )
THEN
167 $
WRITE( nout, fmt = 9997 )
'grid'
174 CALL blacs_get( -1, 0, ictxt )
175 CALL blacs_gridinit( ictxt,
'Row-major', nprow, npcol )
176 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
181 IF( myrow.GE.nprow .OR. mycol.GE.npcol )
193 $
WRITE( nout, fmt = 9999 )
'MATRIX',
'N', n
199 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
201 IF( ierr( 1 ).GT.0 )
THEN
203 $
WRITE( nout, fmt = 9997 )
'matrix'
218 $
WRITE( nout, fmt = 9999 )
'NB',
'NB', nb
223 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
225 IF( ierr( 1 ).GT.0 )
THEN
227 $
WRITE( nout, fmt = 9997 )
'NB'
234 np =
numroc( n, nb, myrow, 0, nprow )
235 nq =
numroc( n, nb, mycol, 0, npcol )
237 iprepad =
max( nb, np )
239 ipostpad =
max( nb, nq )
240 iprepad = iprepad + 1000
241 imidpad = imidpad + 1000
242 ipostpad = ipostpad + 1000
251 CALL descinit( desca, n, n, nb, nb, 0, 0, ictxt,
252 $
max( 1, np )+imidpad, ierr( 1 ) )
256 CALL descinit( descz, n, n, nb, nb, 0, 0, ictxt,
257 $
max( 1, np )+imidpad, ierr( 2 ) )
264 CALL igsum2d( ictxt,
'All',
' ', 2, 1, ierr, 2, -1, 0 )
266 IF( ierr( 1 ).LT.0 .OR. ierr( 2 ).LT.0 )
THEN
268 $
WRITE( nout, fmt = 9997 )
'descriptor'
277 ipc = ipa + desca( lld_ )*nq + ipostpad + iprepad
278 ipwr = ipc + descz( lld_ )*nq + ipostpad + iprepad
279 ipvl = ipwr + n + ipostpad + iprepad
280 ipvr = ipvl + descz( lld_ )*nq + ipostpad + iprepad
281 ipw = ipvr + descz( lld_ )*nq + ipostpad + iprepad
285 iii = 7*iii /
ilcm( nprow, npcol )
288 lwork = 3*n +
max( 2*
max( lda, ldz )+2*nq, iii )
289 lwork = lwork +
max( 2*n, ( 8*
ilcm( nprow, npcol )+2 )**
297 worksiz = lwork +
max( np*desca( nb_ ),
298 $ desca( mb_ )*nq ) + ipostpad
302 worksiz = lwork + ipostpad
309 IF( ipw+worksiz.GT.memsiz )
THEN
311 $
WRITE( nout, fmt = 9996 )
'Schur reduction',
312 $ ( ipw+worksiz )*cplxsz
318 CALL igsum2d( ictxt,
'All',
' ', 1, 1, ierr, 1, -1, 0 )
320 IF( ierr( 1 ).GT.0 )
THEN
322 $
WRITE( nout, fmt = 9997 )
'MEMORY'
329 CALL pclaset(
'All', n, n, zero, one, mem( ipc ), 1, 1,
331 CALL pclaset(
'All', n, n, zero, zero, mem( ipvr ), 1, 1,
333 CALL pclaset(
'All', n, n, zero, zero, mem( ipvl ), 1, 1,
338 CALL pcmatgen( ictxt,
'No transpose',
'No transpose',
339 $ desca( m_ ), desca( n_ ), desca( mb_ ),
340 $ desca( nb_ ), mem( ipa ), desca( lld_ ),
341 $ desca( rsrc_ ), desca( csrc_ ), iaseed, 0,
342 $ np, 0, nq, myrow, mycol, nprow, npcol )
344 $ zero, zero, mem( ipa ),
min( n, 2 ), 1,
350 CALL pcfillpad( ictxt, np, nq, mem( ipa-iprepad ),
351 $ desca( lld_ ), iprepad, ipostpad,
353 CALL pcfillpad( ictxt, np, nq, mem( ipvr-iprepad ),
354 $ descz( lld_ ), iprepad, ipostpad,
356 CALL pcfillpad( ictxt, np, nq, mem( ipvl-iprepad ),
357 $ descz( lld_ ), iprepad, ipostpad,
359 CALL pcfillpad( ictxt, np, nq, mem( ipc-iprepad ),
360 $ descz( lld_ ), iprepad, ipostpad,
362 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
363 $ mem( ipw-iprepad ), worksiz-ipostpad,
364 $ iprepad, ipostpad, padval )
365 anorm =
pclanhs(
'I', n, mem( ipa ), 1, 1, desca,
367 CALL pcchekpad( ictxt,
'PCLANHS', np, nq,
368 $ mem( ipa-iprepad ), desca( lld_ ),
369 $ iprepad, ipostpad, padval )
370 CALL pcchekpad( ictxt,
'PCLANHS', worksiz-ipostpad, 1,
371 $ mem( ipw-iprepad ), worksiz-ipostpad,
372 $ iprepad, ipostpad, padval )
374 CALL pcfillpad( ictxt, n, 1, mem( ipwr-iprepad ), n,
375 $ iprepad, ipostpad, padval )
376 CALL pcfillpad( ictxt, lwork, 1, mem( ipw-iprepad ),
377 $ lwork, iprepad, ipostpad, padval )
384 CALL infog2l( jjj, jjj, descz, nprow, npcol, myrow,
385 $ mycol, irow, icol, ii, jj )
386 IF( myrow.EQ.ii .AND. mycol.EQ.jj )
THEN
387 mem( ipwr-1+jjj ) = mem( ipa-1+( icol-1 )*lda+
390 mem( ipwr-1+jjj ) = zero
393 CALL cgsum2d( ictxt,
'All',
' ', n, 1, mem( ipwr ), n,
398 CALL blacs_barrier( ictxt,
'All' )
403 CALL pctrevc(
'B',
'A',
SELECT, n, mem( ipa ), desca,
404 $ mem( ipvl ), descz, mem( ipvr ), descz, n,
405 $ m, mem( ipw ), rwork, info )
411 $
WRITE( nout, fmt = * )
'PCTREVC INFO=', info
420 CALL pcchekpad( ictxt,
'PCTREVC (A)', np, nq,
421 $ mem( ipa-iprepad ), desca( lld_ ),
422 $ iprepad, ipostpad, padval )
423 CALL pcchekpad( ictxt,
'PCTREVC (VR)', np, nq,
424 $ mem( ipvr-iprepad ), descz( lld_ ),
425 $ iprepad, ipostpad, padval )
426 CALL pcchekpad( ictxt,
'PCTREVC (VL)', np, nq,
427 $ mem( ipvl-iprepad ), descz( lld_ ),
428 $ iprepad, ipostpad, padval )
429 CALL pcchekpad( ictxt,
'PCTREVC (WR)', n, 1,
430 $ mem( ipwr-iprepad ), n, iprepad,
432 CALL pcchekpad( ictxt,
'PCTREVC (WORK)', lwork, 1,
433 $ mem( ipw-iprepad ), lwork, iprepad,
436 CALL pcfillpad( ictxt, worksiz-ipostpad, 1,
437 $ mem( ipw-iprepad ), worksiz-ipostpad,
438 $ iprepad, ipostpad, padval )
444 CALL pcget22(
'N',
'N',
'N', n, mem( ipa ), desca,
445 $ mem( ipvr ), descz, mem( ipwr ),
446 $ mem( ipc ), descz, rwork, result )
452 CALL pcget22(
'C',
'N',
'C', n, mem( ipa ), desca,
453 $ mem( ipvl ), descz, mem( ipwr ),
454 $ mem( ipc ), descz, rwork, result )
455 fresid =
max( fresid, result( 1 ) )
456 qresid =
max( qresid, result( 2 ) )
458 CALL pcchekpad( ictxt,
'PCGET22 (A)', np, nq,
459 $ mem( ipa-iprepad ), desca( lld_ ),
460 $ iprepad, ipostpad, padval )
461 CALL pcchekpad( ictxt,
'PCGET22 (VR)', np, nq,
462 $ mem( ipvr-iprepad ), descz( lld_ ),
463 $ iprepad, ipostpad, padval )
464 CALL pcchekpad( ictxt,
'PCGET22 (VL)', np, nq,
465 $ mem( ipvl-iprepad ), descz( lld_ ),
466 $ iprepad, ipostpad, padval )
467 CALL pcchekpad( ictxt,
'PCGET22 (Z)', np, nq,
468 $ mem( ipc-iprepad ), descz( lld_ ),
469 $ iprepad, ipostpad, padval )
473 IF( ( fresid.LE.thresh ) .AND.
474 $ ( ( fresid-fresid ).EQ.0.0e+0 ) .AND.
475 $ ( qresid.LE.thresh ) .AND.
476 $ ( ( qresid-qresid ).EQ.0.0e+0 ) )
THEN
483 WRITE( nout, fmt = 9986 )fresid
484 WRITE( nout, fmt = 9985 )qresid
493 fresid = fresid - fresid
494 qresid = qresid - qresid
501 CALL slcombine( ictxt,
'All',
'>',
'W', 1, 1, wtime )
502 CALL slcombine( ictxt,
'All',
'>',
'C', 1, 1, ctime )
506 IF( myrow.EQ.0 .AND. mycol.EQ.0 )
THEN
510 nops = 2.0d+0*dble( n )**2
517 IF( wtime( 1 ).GT.0.0d+0 )
THEN
518 tmflops = nops / ( wtime( 1 )*1.0d+6 )
522 IF( wtime( 1 ).GE.0.0d+0 )
523 $
WRITE( nout, fmt = 9993 )
'WALL', n, nb, nprow,
524 $ npcol, wtime( 1 ), tmflops, passed
528 IF( ctime( 1 ).GT.0.0d+0 )
THEN
529 tmflops = nops / ( ctime( 1 )*1.0d+6 )
534 IF( ctime( 1 ).GE.0.0d+0 )
535 $
WRITE( nout, fmt = 9993 )
'CPU ', n, nb, nprow,
536 $ npcol, ctime( 1 ), tmflops, passed
543 CALL blacs_gridexit( ictxt )
550 ktests = kpass + kfail + kskip
551 WRITE( nout, fmt = * )
552 WRITE( nout, fmt = 9992 )ktests
554 WRITE( nout, fmt = 9991 )kpass
555 WRITE( nout, fmt = 9989 )kfail
557 WRITE( nout, fmt = 9990 )kpass
559 WRITE( nout, fmt = 9988 )kskip
560 WRITE( nout, fmt = * )
561 WRITE( nout, fmt = * )
562 WRITE( nout, fmt = 9987 )
563 IF( nout.NE.6 .AND. nout.NE.0 )
569 9999
FORMAT(
'ILLEGAL ', a6,
': ', a5,
' = ', i3,
570 $
'; It should be at least 1' )
571 9998
FORMAT(
'ILLEGAL GRID: nprow*npcol = ', i4,
'. It can be at most',
573 9997
FORMAT(
'Bad ', a6,
' parameters: going on to next test case.' )
574 9996
FORMAT(
'Unable to perform ', a,
': need TOTMEM of at least',
576 9995
FORMAT(
'TIME N NB P Q NEP Time MFLOPS CHECK' )
577 9994
FORMAT(
'---- ----- --- ---- ---- -------- -------- ------' )
578 9993
FORMAT( a4, 1x, i5, 1x, i3, 1x, i4, 1x, i4, 1x, f8.2, 1x, f8.2,
580 9992
FORMAT(
'Finished ', i6,
' tests, with the following results:' )
581 9991
FORMAT( i5,
' tests completed and passed residual checks.' )
582 9990
FORMAT( i5,
' tests completed without checking.' )
583 9989
FORMAT( i5,
' tests completed and failed residual checks.' )
584 9988
FORMAT( i5,
' tests skipped because of illegal input values.' )
585 9987
FORMAT(
'END OF TESTS.' )
586 9986
FORMAT(
'||H*Z - Z*D|| / (||T|| * N * eps) = ', g25.7 )
587 9985
FORMAT(
'max_j(max|Z(j)| - 1) / ( N * eps ) ', g25.7 )