ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
ztrbs2d_.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 
3 #if (INTFACE == C_CALL)
4 void Cztrbs2d(int ConTxt, char *scope, char *top, char *uplo, char *diag,
5  int m, int n, double *A, int lda)
6 #else
7 F_VOID_FUNC ztrbs2d_(int *ConTxt, F_CHAR scope, F_CHAR top, F_CHAR uplo,
8  F_CHAR diag, int *m, int *n, double *A, int *lda)
9 #endif
10 /*
11  * -- V1.1 BLACS routine --
12  * University of Tennessee, May 1, 1996
13  * Written by Clint Whaley.
14  *
15  * Purpose
16  * =======
17  * Broadcast/send for trapezoidal double complex arrays.
18  *
19  * Arguments
20  * =========
21  *
22  * ConTxt (input) Ptr to int
23  * Index into MyConTxts00 (my contexts array).
24  *
25  * SCOPE (input) Ptr to char
26  * Limit the scope of the operation.
27  * = 'R' : Operation is performed by a process row.
28  * = 'C' : Operation is performed by a process column.
29  * = 'A' : Operation is performed by all processes in grid.
30  *
31  * TOP (input) Ptr to char
32  * Controls fashion in which messages flow within the operation.
33  *
34  * UPLO (input) Ptr to char
35  * Specifies the part of the matrix to be sent.
36  * = 'U': Upper trapezoidal part
37  * ELSE : Lower trapezoidal part
38  *
39  * DIAG (input) Ptr to char
40  * Specifies whether the matrix is unit diagonal or not.
41  * = 'U': Matrix is unit diagonal, diagonal not communicated.
42  * ELSE : Matrix is not unit diagonal, diagonal is communicated.
43  *
44  * M (input) Ptr to int
45  * The number of rows of the matrix A. M >= 0.
46  *
47  * N (input) Ptr to int
48  * The number of columns of the matrix A. N >= 0.
49  *
50  * A (input) Ptr to double complex two dimensional array
51  * The m by n matrix A. Fortran77 (column-major) storage
52  * assumed.
53  * If UPLO = 'U', only the upper trapezoid is accessed;
54  * if UPLO = 'L', only the lower trapezoid is accessed.
55  *
56  * LDA (input) Ptr to int
57  * The leading dimension of the array A. LDA >= M.
58  *
59  * ------------------------------------------------------------------------
60  */
61 {
62  void BI_ArgCheck(int, int, char *, char, char, char, int, int, int, int,
63  int *, int *);
65  void BI_IdringBS(BLACSCONTEXT *, BLACBUFF *, SDRVPTR, int);
67  void BI_MpathBS(BLACSCONTEXT *, BLACBUFF *, SDRVPTR, int);
68  void BI_TreeBS(BLACSCONTEXT *, BLACBUFF *, SDRVPTR, int);
69  void BI_UpdateBuffs(BLACBUFF *);
70  BLACBUFF *BI_GetBuff(int);
71  int BI_BuffIsFree(BLACBUFF *, int);
72  MPI_Datatype BI_GetMpiTrType(BLACSCONTEXT *, char, char, int, int, int,
73  MPI_Datatype, int *);
74  BLACBUFF *BI_Pack(BLACSCONTEXT *, BVOID *, BLACBUFF *, MPI_Datatype);
75  void BI_Ssend(BLACSCONTEXT *, int, int, BLACBUFF *);
76  void BI_Asend(BLACSCONTEXT *, int, int, BLACBUFF *);
77 
78  char ttop, tscope, tuplo, tdiag;
79  int error, tlda;
80  MPI_Datatype MatTyp;
81  SDRVPTR send;
82  BLACBUFF *bp;
83  BLACSCONTEXT *ctxt;
85 /*
86  * get context, lowcase char variables, and perform parameter checking
87  */
88  MGetConTxt(Mpval(ConTxt), ctxt);
89  ttop = F2C_CharTrans(top);
90  ttop = Mlowcase(ttop);
91  tscope = F2C_CharTrans(scope);
92  tscope = Mlowcase(tscope);
93  tuplo = F2C_CharTrans(uplo);
94  tuplo = Mlowcase(tuplo);
95  tdiag = F2C_CharTrans(diag);
96  tdiag = Mlowcase(tdiag);
97 #if (BlacsDebugLvl > 0)
98  BI_ArgCheck(Mpval(ConTxt), RT_BS, __FILE__, 'a', tuplo, tdiag, Mpval(m),
99  Mpval(n), Mpval(lda), 0, NULL, NULL);
100 #endif
101 /*
102  * If the user has set the default broadcast topology, use it instead of
103  * BLACS default
104  */
105 #ifdef DefBSTop
106  if (ttop == ' ') ttop = DefBSTop;
107 #endif
108  if (Mpval(lda) < Mpval(m)) tlda = Mpval(m);
109  else tlda = Mpval(lda);
110 
111  switch(tscope)
112  {
113  case 'r':
114  ctxt->scp = &ctxt->rscp;
115  break;
116  case 'c':
117  ctxt->scp = &ctxt->cscp;
118  break;
119  case 'a':
120  ctxt->scp = &ctxt->ascp;
121  break;
122  default:
123  BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown scope '%c'",
124  tscope);
125  }
126  MatTyp = BI_GetMpiTrType(ctxt, tuplo, tdiag, Mpval(m), Mpval(n), tlda,
127  MPI_DOUBLE_COMPLEX, &BI_AuxBuff.N);
128 /*
129  * If using default topology, use MPI native broadcast
130  */
131  if (ttop == ' ')
132  {
133  error=MPI_Bcast(A, BI_AuxBuff.N, MatTyp, ctxt->scp->Iam, ctxt->scp->comm);
134  error=BI_MPI_TYPE_FREE(&MatTyp);
135  if (BI_ActiveQ) BI_UpdateBuffs(NULL);
136  return;
137  }
138 /*
139  * If MPI handles non-contiguous buffering well, always use MPI data types
140  * instead of packing
141  */
142 #ifdef MpiBuffGood
143  send = BI_Ssend;
144  BI_AuxBuff.Buff = (char *) A;
145  BI_AuxBuff.dtype = MatTyp;
146  bp = &BI_AuxBuff;
147 #endif
148 /*
149  * Pack and use non-blocking sends for broadcast if MPI's data types aren't
150  * more efficient
151  */
152 #ifndef MpiBuffGood
153  send = BI_Asend;
154  bp = BI_Pack(ctxt, (BVOID *) A, NULL, MatTyp);
155 #endif
156 
157 /*
158  * Call correct topology for BS/BR
159  */
160  switch(ttop)
161  {
162  case 'h':
163  error = BI_HypBS(ctxt, bp, send);
164  if (error == NPOW2) BI_TreeBS(ctxt, bp, send, 2);
165  break;
166  case '1':
167  case '2':
168  case '3':
169  case '4':
170  case '5':
171  case '6':
172  case '7':
173  case '8':
174  case '9':
175  BI_TreeBS(ctxt, bp, send, ttop-47);
176  break;
177  case 't':
178  BI_TreeBS(ctxt, bp, send, ctxt->Nb_bs);
179  break;
180  case 'i':
181  BI_IdringBS(ctxt, bp, send, 1);
182  break;
183  case 'd':
184  BI_IdringBS(ctxt, bp, send, -1);
185  break;
186  case 's':
187  BI_SringBS(ctxt, bp, send);
188  break;
189  case 'f':
190  BI_MpathBS(ctxt, bp, send, FULLCON);
191  break;
192  case 'm':
193  BI_MpathBS(ctxt, bp, send, ctxt->Nr_bs);
194  break;
195  default :
196  BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown topology '%c'",
197  ttop);
198  }
199 
200  error=BI_MPI_TYPE_FREE(&MatTyp);
201  if (bp == &BI_AuxBuff)
202  {
203  if (BI_ActiveQ) BI_UpdateBuffs(NULL);
204  }
205  else BI_UpdateBuffs(bp);
206 } /* end ztrbs2d_ */
BI_MpathBS
void BI_MpathBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int npaths)
Definition: BI_MpathBS.c:3
BI_Pack
BLACBUFF * BI_Pack(BLACSCONTEXT *ctxt, BVOID *A, BLACBUFF *bp, MPI_Datatype Dtype)
Definition: BI_Pack.c:2
BI_GetBuff
BLACBUFF * BI_GetBuff(int length)
Definition: BI_GetBuff.c:36
bLaCbUfF::Buff
char * Buff
Definition: Bdef.h:56
bLaCsCoNtExT::rscp
BLACSSCOPE rscp
Definition: Bdef.h:25
BI_GetMpiTrType
MPI_Datatype BI_GetMpiTrType(BLACSCONTEXT *ctxt, char uplo, char diag, int m, int n, int lda, MPI_Datatype Dtype, int *N)
Definition: BI_GetMpiTrType.c:4
BI_Asend
void BI_Asend(BLACSCONTEXT *ctxt, int dest, int msgid, BLACBUFF *bp)
Definition: BI_Asend.c:3
FULLCON
#define FULLCON
Definition: Bdef.h:100
BI_Ssend
void BI_Ssend(BLACSCONTEXT *ctxt, int dest, int msgid, BLACBUFF *bp)
Definition: BI_Ssend.c:3
RT_BS
#define RT_BS
Definition: Bdef.h:107
F_CHAR
char * F_CHAR
Definition: pblas.h:109
bLaCsCoNtExT::ascp
BLACSSCOPE ascp
Definition: Bdef.h:25
MGetConTxt
#define MGetConTxt(Context, ctxtptr)
Definition: Bdef.h:200
BVOID
#define BVOID
Definition: Bdef.h:136
bLaCbUfF
Definition: Bdef.h:54
BI_ActiveQ
BLACBUFF * BI_ActiveQ
Definition: BI_GlobalVars.c:9
bLaCsScOpE::Iam
int Iam
Definition: Bdef.h:17
BI_HypBS
int BI_HypBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send)
Definition: BI_HypBS.c:2
bLaCbUfF::N
int N
Definition: Bdef.h:61
bLaCsCoNtExT::Nb_bs
int Nb_bs
Definition: Bdef.h:29
F2C_CharTrans
#define F2C_CharTrans(c)
Definition: Bdef.h:246
Mpval
#define Mpval(para)
Definition: Bdef.h:261
Mlowcase
#define Mlowcase(C)
Definition: Bdef.h:145
bLaCsCoNtExT
Definition: Bdef.h:23
Cztrbs2d
void Cztrbs2d()
bLaCsCoNtExT::Nr_bs
int Nr_bs
Definition: Bdef.h:29
SDRVPTR
void(* SDRVPTR)(BLACSCONTEXT *, int, int, BLACBUFF *)
Definition: Bdef.h:69
F_VOID_FUNC
#define F_VOID_FUNC
Definition: Bdef.h:232
bLaCsCoNtExT::cscp
BLACSSCOPE cscp
Definition: Bdef.h:25
bLaCsCoNtExT::scp
BLACSSCOPE * scp
Definition: Bdef.h:26
Bdef.h
bLaCsScOpE::comm
MPI_Comm comm
Definition: Bdef.h:15
BI_TreeBS
void BI_TreeBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int nbranches)
Definition: BI_TreeBS.c:37
BI_AuxBuff
BLACBUFF BI_AuxBuff
Definition: BI_GlobalVars.c:10
bLaCbUfF::dtype
MPI_Datatype dtype
Definition: Bdef.h:60
BI_BlacsErr
void BI_BlacsErr(int ConTxt, int line, char *file, char *form,...)
Definition: BI_BlacsErr.c:3
ztrbs2d_
F_VOID_FUNC ztrbs2d_(int *ConTxt, F_CHAR scope, F_CHAR top, F_CHAR uplo, F_CHAR diag, int *m, int *n, double *A, int *lda)
Definition: ztrbs2d_.c:7
BI_ArgCheck
void BI_ArgCheck(int ConTxt, int RoutType, char *routine, char scope, char uplo, char diag, int m, int n, int lda, int nprocs, int *prows, int *pcols)
Definition: BI_ArgCheck.c:4
BI_MPI_TYPE_FREE
#define BI_MPI_TYPE_FREE(t)
Definition: Bdef.h:305
BI_IdringBS
void BI_IdringBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int step)
Definition: BI_IdringBS.c:3
BI_UpdateBuffs
void BI_UpdateBuffs(BLACBUFF *Newbp)
Definition: BI_UpdateBuffs.c:3
BI_SringBS
void BI_SringBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send)
Definition: BI_SringBS.c:3
NPOW2
#define NPOW2
Definition: Bdef.h:88
BI_BuffIsFree
int BI_BuffIsFree(BLACBUFF *bp, int Wait)
Definition: BI_BuffIsFree.c:3