SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pclagen()

subroutine pclagen ( logical  inplace,
character*1  aform,
character*1  diag,
integer  offa,
integer  m,
integer  n,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
integer  iaseed,
complex, dimension( lda, * )  a,
integer  lda 
)

Definition at line 508 of file pcblastim.f.

510*
511* -- PBLAS test routine (version 2.0) --
512* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
513* and University of California, Berkeley.
514* April 1, 1998
515*
516* .. Scalar Arguments ..
517 LOGICAL INPLACE
518 CHARACTER*1 AFORM, DIAG
519 INTEGER IA, IASEED, JA, LDA, M, N, OFFA
520* ..
521* .. Array Arguments ..
522 INTEGER DESCA( * )
523 COMPLEX A( LDA, * )
524* ..
525*
526* Purpose
527* =======
528*
529* PCLAGEN generates (or regenerates) a submatrix sub( A ) denoting
530* A(IA:IA+M-1,JA:JA+N-1).
531*
532* Notes
533* =====
534*
535* A description vector is associated with each 2D block-cyclicly dis-
536* tributed matrix. This vector stores the information required to
537* establish the mapping between a matrix entry and its corresponding
538* process and memory location.
539*
540* In the following comments, the character _ should be read as
541* "of the distributed matrix". Let A be a generic term for any 2D
542* block cyclicly distributed matrix. Its description vector is DESCA:
543*
544* NOTATION STORED IN EXPLANATION
545* ---------------- --------------- ------------------------------------
546* DTYPE_A (global) DESCA( DTYPE_ ) The descriptor type.
547* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
548* the NPROW x NPCOL BLACS process grid
549* A is distributed over. The context
550* itself is global, but the handle
551* (the integer value) may vary.
552* M_A (global) DESCA( M_ ) The number of rows in the distribu-
553* ted matrix A, M_A >= 0.
554* N_A (global) DESCA( N_ ) The number of columns in the distri-
555* buted matrix A, N_A >= 0.
556* IMB_A (global) DESCA( IMB_ ) The number of rows of the upper left
557* block of the matrix A, IMB_A > 0.
558* INB_A (global) DESCA( INB_ ) The number of columns of the upper
559* left block of the matrix A,
560* INB_A > 0.
561* MB_A (global) DESCA( MB_ ) The blocking factor used to distri-
562* bute the last M_A-IMB_A rows of A,
563* MB_A > 0.
564* NB_A (global) DESCA( NB_ ) The blocking factor used to distri-
565* bute the last N_A-INB_A columns of
566* A, NB_A > 0.
567* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
568* row of the matrix A is distributed,
569* NPROW > RSRC_A >= 0.
570* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
571* first column of A is distributed.
572* NPCOL > CSRC_A >= 0.
573* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
574* array storing the local blocks of
575* the distributed matrix A,
576* IF( Lc( 1, N_A ) > 0 )
577* LLD_A >= MAX( 1, Lr( 1, M_A ) )
578* ELSE
579* LLD_A >= 1.
580*
581* Let K be the number of rows of a matrix A starting at the global in-
582* dex IA,i.e, A( IA:IA+K-1, : ). Lr( IA, K ) denotes the number of rows
583* that the process of row coordinate MYROW ( 0 <= MYROW < NPROW ) would
584* receive if these K rows were distributed over NPROW processes. If K
585* is the number of columns of a matrix A starting at the global index
586* JA, i.e, A( :, JA:JA+K-1, : ), Lc( JA, K ) denotes the number of co-
587* lumns that the process MYCOL ( 0 <= MYCOL < NPCOL ) would receive if
588* these K columns were distributed over NPCOL processes.
589*
590* The values of Lr() and Lc() may be determined via a call to the func-
591* tion PB_NUMROC:
592* Lr( IA, K ) = PB_NUMROC( K, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW )
593* Lc( JA, K ) = PB_NUMROC( K, JA, INB_A, NB_A, MYCOL, CSRC_A, NPCOL )
594*
595* Arguments
596* =========
597*
598* INPLACE (global input) LOGICAL
599* On entry, INPLACE specifies if the matrix should be generated
600* in place or not. If INPLACE is .TRUE., the local random array
601* to be generated will start in memory at the local memory lo-
602* cation A( 1, 1 ), otherwise it will start at the local posi-
603* tion induced by IA and JA.
604*
605* AFORM (global input) CHARACTER*1
606* On entry, AFORM specifies the type of submatrix to be genera-
607* ted as follows:
608* AFORM = 'S', sub( A ) is a symmetric matrix,
609* AFORM = 'H', sub( A ) is a Hermitian matrix,
610* AFORM = 'T', sub( A ) is overrwritten with the transpose
611* of what would normally be generated,
612* AFORM = 'C', sub( A ) is overwritten with the conjugate
613* transpose of what would normally be genera-
614* ted.
615* AFORM = 'N', a random submatrix is generated.
616*
617* DIAG (global input) CHARACTER*1
618* On entry, DIAG specifies if the generated submatrix is diago-
619* nally dominant or not as follows:
620* DIAG = 'D' : sub( A ) is diagonally dominant,
621* DIAG = 'N' : sub( A ) is not diagonally dominant.
622*
623* OFFA (global input) INTEGER
624* On entry, OFFA specifies the offdiagonal of the underlying
625* matrix A(1:DESCA(M_),1:DESCA(N_)) of interest when the subma-
626* trix is symmetric, Hermitian or diagonally dominant. OFFA = 0
627* specifies the main diagonal, OFFA > 0 specifies a subdiago-
628* nal, and OFFA < 0 specifies a superdiagonal (see further de-
629* tails).
630*
631* M (global input) INTEGER
632* On entry, M specifies the global number of matrix rows of the
633* submatrix sub( A ) to be generated. M must be at least zero.
634*
635* N (global input) INTEGER
636* On entry, N specifies the global number of matrix columns of
637* the submatrix sub( A ) to be generated. N must be at least
638* zero.
639*
640* IA (global input) INTEGER
641* On entry, IA specifies A's global row index, which points to
642* the beginning of the submatrix sub( A ).
643*
644* JA (global input) INTEGER
645* On entry, JA specifies A's global column index, which points
646* to the beginning of the submatrix sub( A ).
647*
648* DESCA (global and local input) INTEGER array
649* On entry, DESCA is an integer array of dimension DLEN_. This
650* is the array descriptor for the matrix A.
651*
652* IASEED (global input) INTEGER
653* On entry, IASEED specifies the seed number to generate the
654* matrix A. IASEED must be at least zero.
655*
656* A (local output) COMPLEX array
657* On entry, A is an array of dimension (LLD_A, Ka), where Ka is
658* at least Lc( 1, JA+N-1 ). On exit, this array contains the
659* local entries of the randomly generated submatrix sub( A ).
660*
661* LDA (local input) INTEGER
662* On entry, LDA specifies the local leading dimension of the
663* array A. When INPLACE is .FALSE., LDA is usually DESCA(LLD_).
664* This restriction is however not enforced, and this subroutine
665* requires only that LDA >= MAX( 1, Mp ) where
666*
667* Mp = PB_NUMROC( M, IA, IMB_A, MB_A, MYROW, RSRC_A, NPROW ).
668*
669* PB_NUMROC is a ScaLAPACK tool function; MYROW, MYCOL, NPROW
670* and NPCOL can be determined by calling the BLACS subroutine
671* BLACS_GRIDINFO.
672*
673* Further Details
674* ===============
675*
676* OFFD is tied to the matrix described by DESCA, as opposed to the
677* piece that is currently (re)generated. This is a global information
678* independent from the distribution parameters. Below are examples of
679* the meaning of OFFD for a global 7 by 5 matrix:
680*
681* ---------------------------------------------------------------------
682* OFFD | 0 -1 -2 -3 -4 0 -1 -2 -3 -4 0 -1 -2 -3 -4
683* -------|-------------------------------------------------------------
684* | | OFFD=-1 | OFFD=0 OFFD=2
685* | V V
686* 0 | . d . . . -> d . . . . . . . . .
687* 1 | . . d . . . d . . . . . . . .
688* 2 | . . . d . . . d . . -> d . . . .
689* 3 | . . . . d . . . d . . d . . .
690* 4 | . . . . . . . . . d . . d . .
691* 5 | . . . . . . . . . . . . . d .
692* 6 | . . . . . . . . . . . . . . d
693* ---------------------------------------------------------------------
694*
695* -- Written on April 1, 1998 by
696* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
697*
698* =====================================================================
699*
700* .. Parameters ..
701 INTEGER BLOCK_CYCLIC_2D_INB, CSRC_, CTXT_, DLEN_,
702 $ DTYPE_, IMB_, INB_, LLD_, MB_, M_, NB_, N_,
703 $ RSRC_
704 parameter( block_cyclic_2d_inb = 2, dlen_ = 11,
705 $ dtype_ = 1, ctxt_ = 2, m_ = 3, n_ = 4,
706 $ imb_ = 5, inb_ = 6, mb_ = 7, nb_ = 8,
707 $ rsrc_ = 9, csrc_ = 10, lld_ = 11 )
708 INTEGER JMP_1, JMP_COL, JMP_IMBV, JMP_INBV, JMP_LEN,
709 $ JMP_MB, JMP_NB, JMP_NPIMBLOC, JMP_NPMB,
710 $ JMP_NQINBLOC, JMP_NQNB, JMP_ROW
711 parameter( jmp_1 = 1, jmp_row = 2, jmp_col = 3,
712 $ jmp_mb = 4, jmp_imbv = 5, jmp_npmb = 6,
713 $ jmp_npimbloc = 7, jmp_nb = 8, jmp_inbv = 9,
714 $ jmp_nqnb = 10, jmp_nqinbloc = 11,
715 $ jmp_len = 11 )
716 REAL ZERO
717 parameter( zero = 0.0e+0 )
718* ..
719* .. Local Scalars ..
720 LOGICAL DIAGDO, SYMM, HERM, NOTRAN
721 INTEGER CSRC, I, IACOL, IAROW, ICTXT, IIA, ILOCBLK,
722 $ ILOCOFF, ILOW, IMB, IMB1, IMBLOC, IMBVIR, INB,
723 $ INB1, INBLOC, INBVIR, INFO, IOFFDA, ITMP, IUPP,
724 $ IVIR, JJA, JLOCBLK, JLOCOFF, JVIR, LCMT00,
725 $ LMBLOC, LNBLOC, LOW, MAXMN, MB, MBLKS, MP,
726 $ MRCOL, MRROW, MYCDIST, MYCOL, MYRDIST, MYROW,
727 $ NB, NBLKS, NPCOL, NPROW, NQ, NVIR, RSRC, UPP
728 COMPLEX ALPHA
729* ..
730* .. Local Arrays ..
731 INTEGER DESCA2( DLEN_ ), IMULADD( 4, JMP_LEN ),
732 $ IRAN( 2 ), JMP( JMP_LEN ), MULADD0( 4 )
733* ..
734* .. External Subroutines ..
735 EXTERNAL blacs_gridinfo, pb_ainfog2l, pb_binfo,
739* ..
740* .. External Functions ..
741 LOGICAL LSAME
742 EXTERNAL lsame
743* ..
744* .. Intrinsic Functions ..
745 INTRINSIC cmplx, max, min, real
746* ..
747* .. Data Statements ..
748 DATA ( muladd0( i ), i = 1, 4 ) / 20077, 16838,
749 $ 12345, 0 /
750* ..
751* .. Executable Statements ..
752*
753* Convert descriptor
754*
755 CALL pb_desctrans( desca, desca2 )
756*
757* Test the input arguments
758*
759 ictxt = desca2( ctxt_ )
760 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
761*
762* Test the input parameters
763*
764 info = 0
765 IF( nprow.EQ.-1 ) THEN
766 info = -( 1000 + ctxt_ )
767 ELSE
768 symm = lsame( aform, 'S' )
769 herm = lsame( aform, 'H' )
770 notran = lsame( aform, 'N' )
771 diagdo = lsame( diag, 'D' )
772 IF( .NOT.( symm.OR.herm.OR.notran ) .AND.
773 $ .NOT.( lsame( aform, 'T' ) ) .AND.
774 $ .NOT.( lsame( aform, 'C' ) ) ) THEN
775 info = -2
776 ELSE IF( ( .NOT.diagdo ) .AND.
777 $ ( .NOT.lsame( diag, 'N' ) ) ) THEN
778 info = -3
779 END IF
780 CALL pb_chkmat( ictxt, m, 5, n, 6, ia, ja, desca2, 10, info )
781 END IF
782*
783 IF( info.NE.0 ) THEN
784 CALL pxerbla( ictxt, 'PCLAGEN', -info )
785 RETURN
786 END IF
787*
788* Quick return if possible
789*
790 IF( ( m.LE.0 ).OR.( n.LE.0 ) )
791 $ RETURN
792*
793* Start the operations
794*
795 mb = desca2( mb_ )
796 nb = desca2( nb_ )
797 imb = desca2( imb_ )
798 inb = desca2( inb_ )
799 rsrc = desca2( rsrc_ )
800 csrc = desca2( csrc_ )
801*
802* Figure out local information about the distributed matrix operand
803*
804 CALL pb_ainfog2l( m, n, ia, ja, desca2, nprow, npcol, myrow,
805 $ mycol, imb1, inb1, mp, nq, iia, jja, iarow,
806 $ iacol, mrrow, mrcol )
807*
808* Decide where the entries shall be stored in memory
809*
810 IF( inplace ) THEN
811 iia = 1
812 jja = 1
813 END IF
814*
815* Initialize LCMT00, MBLKS, NBLKS, IMBLOC, INBLOC, LMBLOC, LNBLOC,
816* ILOW, LOW, IUPP, and UPP.
817*
818 ioffda = ja + offa - ia
819 CALL pb_binfo( ioffda, mp, nq, imb1, inb1, mb, nb, mrrow,
820 $ mrcol, lcmt00, mblks, nblks, imbloc, inbloc,
821 $ lmbloc, lnbloc, ilow, low, iupp, upp )
822*
823* Initialize ILOCBLK, ILOCOFF, MYRDIST, JLOCBLK, JLOCOFF, MYCDIST
824* This values correspond to the square virtual underlying matrix
825* of size MAX( M_ + MAX( 0, -OFFA ), N_ + MAX( 0, OFFA ) ) used
826* to set up the random sequence. For practical purposes, the size
827* of this virtual matrix is upper bounded by M_ + N_ - 1.
828*
829 itmp = max( 0, -offa )
830 ivir = ia + itmp
831 imbvir = imb + itmp
832 nvir = desca2( m_ ) + itmp
833*
834 CALL pb_locinfo( ivir, imbvir, mb, myrow, rsrc, nprow, ilocblk,
835 $ ilocoff, myrdist )
836*
837 itmp = max( 0, offa )
838 jvir = ja + itmp
839 inbvir = inb + itmp
840 nvir = max( max( nvir, desca2( n_ ) + itmp ),
841 $ desca2( m_ ) + desca2( n_ ) - 1 )
842*
843 CALL pb_locinfo( jvir, inbvir, nb, mycol, csrc, npcol, jlocblk,
844 $ jlocoff, mycdist )
845*
846 IF( symm .OR. herm .OR. notran ) THEN
847*
848 CALL pb_initjmp( .true., nvir, imbvir, inbvir, imbloc, inbloc,
849 $ mb, nb, rsrc, csrc, nprow, npcol, 2, jmp )
850*
851* Compute constants to jump JMP( * ) numbers in the sequence
852*
853 CALL pb_initmuladd( muladd0, jmp, imuladd )
854*
855* Compute and set the random value corresponding to A( IA, JA )
856*
857 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
858 $ myrdist, mycdist, nprow, npcol, jmp,
859 $ imuladd, iran )
860*
861 CALL pb_clagen( 'Lower', aform, a( iia, jja ), lda, lcmt00,
862 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
863 $ nb, lnbloc, jmp, imuladd )
864*
865 END IF
866*
867 IF( symm .OR. herm .OR. ( .NOT. notran ) ) THEN
868*
869 CALL pb_initjmp( .false., nvir, imbvir, inbvir, imbloc, inbloc,
870 $ mb, nb, rsrc, csrc, nprow, npcol, 2, jmp )
871*
872* Compute constants to jump JMP( * ) numbers in the sequence
873*
874 CALL pb_initmuladd( muladd0, jmp, imuladd )
875*
876* Compute and set the random value corresponding to A( IA, JA )
877*
878 CALL pb_setlocran( iaseed, ilocblk, jlocblk, ilocoff, jlocoff,
879 $ myrdist, mycdist, nprow, npcol, jmp,
880 $ imuladd, iran )
881*
882 CALL pb_clagen( 'Upper', aform, a( iia, jja ), lda, lcmt00,
883 $ iran, mblks, imbloc, mb, lmbloc, nblks, inbloc,
884 $ nb, lnbloc, jmp, imuladd )
885*
886 END IF
887*
888 IF( diagdo ) THEN
889*
890 maxmn = max( desca2( m_ ), desca2( n_ ) )
891 IF( herm ) THEN
892 alpha = cmplx( real( 2 * maxmn ), zero )
893 ELSE
894 alpha = cmplx( real( maxmn ), real( maxmn ) )
895 END IF
896*
897 IF( ioffda.GE.0 ) THEN
898 CALL pcladom( inplace, min( max( 0, m-ioffda ), n ), alpha,
899 $ a, min( ia+ioffda, ia+m-1 ), ja, desca )
900 ELSE
901 CALL pcladom( inplace, min( m, max( 0, n+ioffda ) ), alpha,
902 $ a, ia, min( ja-ioffda, ja+n-1 ), desca )
903 END IF
904*
905 END IF
906*
907 RETURN
908*
909* End of PCLAGEN
910*
float cmplx[2]
Definition pblas.h:136
subroutine pb_ainfog2l(m, n, i, j, desc, nprow, npcol, myrow, mycol, imb1, inb1, mp, nq, ii, jj, prow, pcol, rprow, rpcol)
Definition pblastst.f:2023
subroutine pb_binfo(offd, m, n, imb1, inb1, mb, nb, mrrow, mrcol, lcmt00, mblks, nblks, imbloc, inbloc, lmbloc, lnbloc, ilow, low, iupp, upp)
Definition pblastst.f:3577
subroutine pb_setran(iran, iac)
Definition pblastst.f:4759
subroutine pb_locinfo(i, inb, nb, myroc, srcproc, nprocs, ilocblk, ilocoff, mydist)
Definition pblastst.f:3910
subroutine pb_chkmat(ictxt, m, mpos0, n, npos0, ia, ja, desca, dpos0, info)
Definition pblastst.f:2742
subroutine pb_jump(k, muladd, irann, iranm, ima)
Definition pblastst.f:4648
subroutine pb_setlocran(seed, ilocblk, jlocblk, ilocoff, jlocoff, myrdist, mycdist, nprow, npcol, jmp, imuladd, iran)
Definition pblastst.f:4302
subroutine pb_initmuladd(muladd0, jmp, imuladd)
Definition pblastst.f:4196
subroutine pb_desctrans(descin, descout)
Definition pblastst.f:2964
subroutine pb_initjmp(colmaj, nvir, imbvir, inbvir, imbloc, inbloc, mb, nb, rsrc, csrc, nprow, npcol, stride, jmp)
Definition pblastst.f:4045
subroutine pb_jumpit(muladd, irann, iranm)
Definition pblastst.f:4822
subroutine pcladom(inplace, n, alpha, a, ia, ja, desca)
Definition pcblastst.f:8894
subroutine pb_clagen(uplo, aform, a, lda, lcmt00, iran, mblks, imbloc, mb, lmbloc, nblks, inbloc, nb, lnbloc, jmp, imuladd)
#define max(A, B)
Definition pcgemr.c:180
#define min(A, B)
Definition pcgemr.c:181
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
logical function lsame(ca, cb)
Definition tools.f:1724
Here is the call graph for this function: