1 SUBROUTINE pslarzb( SIDE, TRANS, DIRECT, STOREV, M, N, K, L, V,
2 $ IV, JV, DESCV, T, C, IC, JC, DESCC, WORK )
10 CHARACTER DIRECT, SIDE, STOREV, TRANS
11 INTEGER IC, IV, JC, JV, K, L, M, N
14 INTEGER DESCC( * ), DESCV( * )
15 REAL C( * ), T( * ), V( * ), WORK( * )
222 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
223 $ lld_, mb_, m_, nb_, n_, rsrc_
224 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
225 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
226 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
228 parameter( one = 1.0e+0, zero = 0.0e+0 )
232 CHARACTER COLBTOP, TRANST
233 INTEGER ICCOL1, ICCOL2, ICOFFC1, ICOFFC2, ICOFFV,
234 $ icrow1, icrow2, ictxt, iibeg, iic1, iic2,
235 $ iiend, iinxt, iiv, ileft, info, ioffc2, ioffv,
236 $ ipt, ipv, ipw, iroffc1, iroffc2, itop, ivcol,
237 $ ivrow, jjbeg, jjend, jjnxt, jjc1, jjc2, jjv,
238 $ ldc, ldv, lv, lw, mbc, mbv, mpc1, mpc2, mpc20,
239 $ mqv, mqv0, mycol, mydist, myrow, nbc, nbv,
240 $ npcol, nprow, nqc1, nqc2, nqcall, nqv
243 EXTERNAL blacs_abort, blacs_gridinfo,
infog2l,
245 $ sgebr2d, sgebs2d, sgemm,
246 $ sgsum2d, slamov, slaset, strbr2d,
254 INTEGER ICEIL, NUMROC
255 EXTERNAL iceil, lsame, numroc
261 IF( m.LE.0 .OR. n.LE.0 .OR. k.LE.0 )
266 ictxt = descc( ctxt_ )
267 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
272 IF( .NOT.lsame( direct,
'B' ) )
THEN
274 ELSE IF( .NOT.lsame( storev,
'R' ) )
THEN
278 CALL pxerbla( ictxt,
'PSLARZB', -info )
279 CALL blacs_abort( ictxt, 1 )
283 left = lsame( side,
'L' )
284 IF( lsame( trans,
'N' ) )
THEN
290 CALL infog2l( iv, jv, descv, nprow, npcol, myrow, mycol, iiv, jjv,
294 icoffv = mod( jv-1, nbv )
295 nqv = numroc( l+icoffv, nbv, mycol, ivcol, npcol )
299 iiv =
min( iiv, ldv )
300 jjv =
min( jjv,
max( 1, numroc( descv( n_ ), nbv, mycol,
301 $ descv( csrc_ ), npcol ) ) )
302 ioffv = iiv + ( jjv-1 ) * ldv
305 nqcall = numroc( descc( n_ ), nbc, mycol, descc( csrc_ ), npcol )
306 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol, iic1,
307 $ jjc1, icrow1, iccol1 )
309 iic1 =
min( iic1, ldc )
310 jjc1 =
min( jjc1,
max( 1, nqcall ) )
313 iroffc1 = mod( ic-1, mbc )
314 mpc1 = numroc( k+iroffc1, mbc, myrow, icrow1, nprow )
315 IF( myrow.EQ.icrow1 )
316 $ mpc1 = mpc1 - iroffc1
317 icoffc1 = mod( jc-1, nbc )
318 nqc1 = numroc( n+icoffc1, nbc, mycol, iccol1, npcol )
319 IF( mycol.EQ.iccol1 )
320 $ nqc1 = nqc1 - icoffc1
321 CALL infog2l( ic+m-l, jc, descc, nprow, npcol, myrow, mycol,
322 $ iic2, jjc2, icrow2, iccol2 )
323 iroffc2 = mod( ic+m-l-1, mbc )
324 mpc2 = numroc( l+iroffc2, mbc, myrow, icrow2, nprow )
325 IF( myrow.EQ.icrow2 )
326 $ mpc2 = mpc2 - iroffc2
330 iroffc1 = mod( ic-1, mbc )
331 mpc1 = numroc( m+iroffc1, mbc, myrow, icrow1, nprow )
332 IF( myrow.EQ.icrow1 )
333 $ mpc1 = mpc1 - iroffc1
334 icoffc1 = mod( jc-1, nbc )
335 nqc1 = numroc( k+icoffc1, nbc, mycol, iccol1, npcol )
336 IF( mycol.EQ.iccol1 )
337 $ nqc1 = nqc1 - icoffc1
338 CALL infog2l( ic, jc+n-l, descc, nprow, npcol, myrow, mycol,
339 $ iic2, jjc2, icrow2, iccol2 )
342 icoffc2 = mod( jc+n-l-1, nbc )
343 nqc2 = numroc( l+icoffc2, nbc, mycol, iccol2, npcol )
344 IF( mycol.EQ.iccol2 )
345 $ nqc2 = nqc2 - icoffc2
347 iic2 =
min( iic2, ldc )
348 jjc2 =
min( jjc2, nqcall )
349 ioffc2 = iic2 + ( jjc2-1 ) * ldc
351 IF( lsame( side,
'L' ) )
THEN
358 mqv0 = numroc( m+icoffv, nbv, mycol, ivcol, npcol )
359 IF( mycol.EQ.ivcol )
THEN
364 IF( myrow.EQ.icrow2 )
THEN
365 mpc20 = mpc2 + iroffc2
376 ipw = ipv + mpc20 * k
381 IF( myrow.EQ.ivrow )
THEN
382 IF( mycol.EQ.ivcol )
THEN
383 CALL slamov(
'All', k, mqv, v( ioffv ), ldv,
384 $ work( ipw+icoffv*lw ), lw )
386 CALL slamov(
'All', k, mqv, v( ioffv ), ldv,
393 CALL pbstran( ictxt,
'Rowwise',
'Transpose', k, m+icoffv,
394 $ descv( nb_ ), work( ipw ), lw, zero,
395 $ work( ipv ), lv, ivrow, ivcol, icrow2, -1,
400 IF( myrow.EQ.icrow2 )
401 $ ipv = ipv + iroffc2
409 CALL sgemm(
'Transpose',
'No transpose', nqc2, k, mpc2,
410 $ one, c( ioffc2 ), ldc, work( ipv ), lv, zero,
413 CALL slaset(
'All', nqc2, k, zero, zero, work( ipw ), lw )
419 mydist = mod( myrow-icrow1+nprow, nprow )
420 itop =
max( 0, mydist * mbc - iroffc1 )
422 iiend = iic1 + mpc1 - 1
423 iinxt =
min( iceil( iibeg, mbc ) * mbc, iiend )
426 IF( iibeg.LE.iinxt )
THEN
427 CALL pbsmatadd( ictxt,
'Transpose', nqc2, iinxt-iibeg+1,
428 $ one, c( iibeg+(jjc1-1)*ldc ), ldc, one,
429 $ work( ipw+itop ), lw )
430 mydist = mydist + nprow
431 itop = mydist * mbc - iroffc1
433 iinxt =
min( iinxt+mbc, iiend )
438 CALL sgsum2d( ictxt,
'Columnwise',
' ', nqc2, k, work( ipw ),
443 IF( myrow.EQ.ivrow )
THEN
444 IF( mycol.EQ.ivcol )
THEN
448 CALL strbs2d( ictxt,
'Rowwise',
' ',
'Lower',
'Non unit',
451 CALL strbr2d( ictxt,
'Rowwise',
' ',
'Lower',
'Non unit',
452 $ k, k, t, mbv, myrow, ivcol )
454 CALL strmm(
'Right',
'Lower', transt,
'Non unit', nqc2, k,
455 $ one, t, mbv, work( ipw ), lw )
457 CALL sgebs2d( ictxt,
'Columnwise',
' ', nqc2, k,
460 CALL sgebr2d( ictxt,
'Columnwise',
' ', nqc2, k,
461 $ work( ipw ), lw, ivrow, mycol )
467 mydist = mod( myrow-icrow1+nprow, nprow )
468 itop =
max( 0, mydist * mbc - iroffc1 )
470 iiend = iic1 + mpc1 - 1
471 iinxt =
min( iceil( iibeg, mbc ) * mbc, iiend )
474 IF( iibeg.LE.iinxt )
THEN
475 CALL pbsmatadd( ictxt,
'Transpose', iinxt-iibeg+1, nqc2,
476 $ -one, work( ipw+itop ), lw, one,
477 $ c( iibeg+(jjc1-1)*ldc ), ldc )
478 mydist = mydist + nprow
479 itop = mydist * mbc - iroffc1
481 iinxt =
min( iinxt+mbc, iiend )
490 CALL sgemm(
'No transpose',
'Transpose', mpc2, nqc2, k, -one,
491 $ work( ipv ), lv, work( ipw ), lw, one,
509 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
510 IF( myrow.EQ.ivrow )
THEN
511 CALL sgebs2d( ictxt,
'Columnwise', colbtop, k, nqc2,
514 $
CALL strbs2d( ictxt,
'Columnwise', colbtop,
'Lower',
515 $
'Non unit', k, k, t, mbv )
516 CALL slamov(
'All', k, nqc2, v( ioffv ), ldv, work( ipv ),
519 CALL sgebr2d( ictxt,
'Columnwise', colbtop, k, nqc2,
520 $ work( ipv ), lv, ivrow, mycol )
522 $
CALL strbr2d( ictxt,
'Columnwise', colbtop,
'Lower',
523 $
'Non unit', k, k, t, mbv, ivrow, mycol )
530 CALL sgemm(
'No Transpose',
'Transpose', mpc2, k, nqc2,
531 $ one, c( ioffc2 ), ldc, work( ipv ), lv, zero,
534 CALL slaset(
'All', mpc2, k, zero, zero, work( ipw ), lw )
540 mydist = mod( mycol-iccol1+npcol, npcol )
541 ileft =
max( 0, mydist * nbc - icoffc1 )
543 jjend = jjc1 + nqc1 - 1
544 jjnxt =
min( iceil( jjbeg, nbc ) * nbc, jjend )
547 IF( jjbeg.LE.jjnxt )
THEN
548 CALL pbsmatadd( ictxt,
'No transpose', mpc2,
549 $ jjnxt-jjbeg+1, one,
550 $ c( iic1+(jjbeg-1)*ldc ), ldc, one,
551 $ work( ipw+ileft*lw ), lw )
552 mydist = mydist + npcol
553 ileft = mydist * nbc - icoffc1
555 jjnxt =
min( jjnxt+nbc, jjend )
560 CALL sgsum2d( ictxt,
'Rowwise',
' ', mpc2, k, work( ipw ),
565 IF( mycol.EQ.ivcol )
THEN
566 CALL strmm(
'Right',
'Lower', trans,
'Non unit', mpc2, k,
567 $ one, t, mbv, work( ipw ), lw )
568 CALL sgebs2d( ictxt,
'Rowwise',
' ', mpc2, k, work( ipw ),
571 CALL sgebr2d( ictxt,
'Rowwise',
' ', mpc2, k, work( ipw ),
578 mydist = mod( mycol-iccol1+npcol, npcol )
579 ileft =
max( 0, mydist * nbc - icoffc1 )
581 jjend = jjc1 + nqc1 - 1
582 jjnxt =
min( iceil( jjbeg, nbc ) * nbc, jjend )
585 IF( jjbeg.LE.jjnxt )
THEN
586 CALL pbsmatadd( ictxt,
'No transpose', mpc2,
587 $ jjnxt-jjbeg+1, -one,
588 $ work( ipw+ileft*lw ), lw, one,
589 $ c( iic1+(jjbeg-1)*ldc ), ldc )
590 mydist = mydist + npcol
591 ileft = mydist * nbc - icoffc1
593 jjnxt =
min( jjnxt+nbc, jjend )
603 $
CALL sgemm(
'No transpose',
'No transpose', mpc2, nqc2, k,
604 $ -one, work( ipw ), lw, work( ipv ), lv, one,