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