SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
igebr2d_.c
Go to the documentation of this file.
1#include "Bdef.h"
2
3#if (INTFACE == C_CALL)
4void Cigebr2d(Int ConTxt, char *scope, char *top, Int m, Int n, Int *A,
5 Int lda, Int rsrc, Int csrc)
6#else
7F_VOID_FUNC igebr2d_(Int *ConTxt, F_CHAR scope, F_CHAR top, Int *m, Int *n,
8 Int *A, Int *lda, Int *rsrc, Int *csrc)
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/receive for general integer 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 * M (input) Ptr to Int
35 * The number of rows of the matrix A. M >= 0.
36 *
37 * N (input) Ptr to Int
38 * The number of columns of the matrix A. N >= 0.
39 *
40 * A (output) Ptr to integer two dimensional array
41 * The m by n matrix A. Fortran77 (column-major) storage
42 * assumed.
43 *
44 * LDA (input) Ptr to Int
45 * The leading dimension of the array A. LDA >= M.
46 *
47 *
48 * RSRC (input) Ptr to Int
49 * The process row of the source of the matrix.
50 *
51 * CSRC (input) Ptr to Int
52 * The process column of the source of the matrix.
53 *
54 *
55 * ------------------------------------------------------------------------
56 */
57{
58 void BI_ArgCheck(Int, Int, char *, char, char, char, Int, Int, Int, Int,
59 Int *, Int *);
68 MPI_Datatype BI_GetMpiGeType(BLACSCONTEXT *, Int, Int, Int,
69 MPI_Datatype, Int *);
70 void BI_Unpack(BLACSCONTEXT *, BVOID *, BLACBUFF *, MPI_Datatype);
73
74 BLACSCONTEXT *ctxt;
75 BLACBUFF *bp=NULL;
76 SDRVPTR send;
77 MPI_Datatype IntTyp, MatTyp;
78 Int length, src, tlda, error, one=1;
79 char ttop, tscope;
81
82 MGetConTxt(Mpval(ConTxt), ctxt);
83 ttop = F2C_CharTrans(top);
84 ttop = Mlowcase(ttop);
85 tscope = F2C_CharTrans(scope);
86 tscope = Mlowcase(tscope);
87#if (BlacsDebugLvl > 0)
88 BI_ArgCheck(Mpval(ConTxt), RT_BR, __FILE__, tscope, 'u', 'u', Mpval(m),
89 Mpval(n), Mpval(lda), 1, Mpaddress(rsrc), Mpaddress(csrc));
90#endif
91/*
92 * If the user has set the default broadcast topology, use it instead of
93 * BLACS default
94 */
95#ifdef DefBSTop
96 if (ttop == ' ') ttop = DefBSTop;
97#endif
98 if (Mpval(m) <= Mpval(lda)) tlda = Mpval(lda);
99 else tlda = Mpval(m);
100
101 switch(tscope)
102 {
103 case 'r':
104 ctxt->scp = &ctxt->rscp;
105 src = Mpval(csrc);
106 break;
107 case 'c':
108 ctxt->scp = &ctxt->cscp;
109 src = Mpval(rsrc);
110 break;
111 case 'a':
112 ctxt->scp = &ctxt->ascp;
113 src = Mvkpnum(ctxt, Mpval(rsrc), Mpval(csrc));
114 break;
115 default:
116 BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown scope '%c'",
117 tscope);
118 }
119
120 MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(Int), &IntTyp);
121 MatTyp = BI_GetMpiGeType(ctxt, Mpval(m), Mpval(n), tlda,
122 IntTyp, &BI_AuxBuff.N);
123/*
124 * If using default topology, use MPI native broadcast
125 */
126 if (ttop == ' ')
127 {
128 error=MPI_Bcast(A, BI_AuxBuff.N, MatTyp, src, ctxt->scp->comm);
129 error=BI_MPI_TYPE_FREE(&MatTyp);
130 if (BI_ActiveQ) BI_UpdateBuffs(NULL);
131 return;
132 }
133/*
134 * If MPI handles non-contiguous buffering well, always use MPI data types
135 * instead of packing
136 */
137#ifndef MpiBuffGood
138/*
139 * If A is contiguous, receive and send directly to/from it
140 */
141 else if ( (tlda == Mpval(m)) || (Mpval(n) == 1) )
142 {
143#endif
144 send = BI_Ssend;
145 BI_AuxBuff.Buff = (char *) A;
146 BI_AuxBuff.dtype = MatTyp;
147 bp = &BI_AuxBuff;
148#ifndef MpiBuffGood
149 }
150/*
151 * If A is not contiguous, we receive message as packed so it can be
152 * forwarded without further system intervention
153 */
154 else
155 {
156 send = BI_Asend;
157 MPI_Pack_size(one, MatTyp, ctxt->scp->comm, &length);
158 bp = BI_GetBuff(length);
159 bp->N = length;
160 bp->dtype = MPI_PACKED;
161#if ZeroByteTypeBug
162 if (MatTyp == MPI_BYTE)
163 {
164 send = BI_Ssend;
165 bp->N = 0;
166 bp->dtype = MPI_BYTE;
167 }
168#endif
169 }
170#endif
171
172 switch(ttop)
173 {
174 case 'h':
175 error = BI_HypBR(ctxt, bp, send, src);
176 if (error == NPOW2) BI_TreeBR(ctxt, bp, send, src, 2);
177 break;
178 case '1':
179 case '2':
180 case '3':
181 case '4':
182 case '5':
183 case '6':
184 case '7':
185 case '8':
186 case '9':
187 BI_TreeBR(ctxt, bp, send, src, ttop-47);
188 break;
189 case 't':
190 BI_TreeBR(ctxt, bp, send, src, ctxt->Nb_bs);
191 break;
192 case 'i':
193 BI_IdringBR(ctxt, bp, send, src, 1);
194 break;
195 case 'd':
196 BI_IdringBR(ctxt, bp, send, src, -1);
197 break;
198 case 's':
199 BI_SringBR(ctxt, bp, send, src);
200 break;
201 case 'm':
202 BI_MpathBR(ctxt, bp, send, src, ctxt->Nr_bs);
203 break;
204 case 'f':
205 BI_MpathBR(ctxt, bp, send, src, FULLCON);
206 break;
207 default :
208 BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown topology '%c'",
209 ttop);
210 }
211
212/*
213 * If we buffered, unpack.
214 */
215#ifndef MpiBuffGood
216 if (bp != &BI_AuxBuff)
217 {
218 BI_Unpack(ctxt, (BVOID *) A, bp, MatTyp);
219 BI_UpdateBuffs(bp);
220 }
221 else
222#endif
223 {
224 error=BI_MPI_TYPE_FREE(&MatTyp);
225 if (BI_ActiveQ) BI_UpdateBuffs(NULL);
226 }
227}
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
void BI_Asend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
Definition BI_Asend.c:3
Int BI_BuffIsFree(BLACBUFF *bp, Int Wait)
BLACBUFF * BI_GetBuff(Int length)
Definition BI_GetBuff.c:37
MPI_Datatype BI_GetMpiGeType(BLACSCONTEXT *ctxt, Int m, Int n, Int lda, MPI_Datatype Dtype, Int *N)
BLACBUFF * BI_ActiveQ
BLACBUFF BI_AuxBuff
Int BI_HypBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, Int src)
Definition BI_HypBR.c:3
void BI_IdringBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, Int src, Int step)
Definition BI_IdringBR.c:3
void BI_MpathBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, Int src, Int npaths)
Definition BI_MpathBR.c:3
void BI_SringBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, Int src)
Definition BI_SringBR.c:3
void BI_Ssend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
Definition BI_Ssend.c:3
void BI_TreeBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, Int src, Int nbranches)
Definition BI_TreeBR.c:3
void BI_Unpack(BLACSCONTEXT *ctxt, BVOID *A, BLACBUFF *bp, MPI_Datatype Dtype)
Definition BI_Unpack.c:3
void BI_UpdateBuffs(BLACBUFF *Newbp)
#define Int
Definition Bconfig.h:22
void BI_BlacsErr(Int ConTxt, Int line, char *file, char *form,...)
Definition BI_BlacsErr.c:3
#define BI_MPI_TYPE_FREE(t)
Definition Bdef.h:305
#define F2C_CharTrans(c)
Definition Bdef.h:246
#define Mvkpnum(ctxt, prow, pcol)
Definition Bdef.h:174
#define MGetConTxt(Context, ctxtptr)
Definition Bdef.h:200
#define F_VOID_FUNC
Definition Bdef.h:232
#define RT_BR
Definition Bdef.h:108
#define Mpaddress(para)
Definition Bdef.h:262
#define Mpval(para)
Definition Bdef.h:261
#define NPOW2
Definition Bdef.h:88
#define FULLCON
Definition Bdef.h:100
void(* SDRVPTR)(BLACSCONTEXT *, Int, Int, BLACBUFF *)
Definition Bdef.h:69
#define Mlowcase(C)
Definition Bdef.h:145
#define BVOID
Definition Bdef.h:136
void Cigebr2d()
char * F_CHAR
Definition pblas.h:113
F_VOID_FUNC igebr2d_(Int *ConTxt, F_CHAR scope, F_CHAR top, Int *m, Int *n, Int *A, Int *lda, Int *rsrc, Int *csrc)
Definition igebr2d_.c:7
Int N
Definition Bdef.h:61
MPI_Datatype dtype
Definition Bdef.h:60
char * Buff
Definition Bdef.h:56
Int Nb_bs
Definition Bdef.h:29
Int Nr_bs
Definition Bdef.h:29
BLACSSCOPE * scp
Definition Bdef.h:26
BLACSSCOPE ascp
Definition Bdef.h:25
BLACSSCOPE rscp
Definition Bdef.h:25
BLACSSCOPE cscp
Definition Bdef.h:25
MPI_Comm comm
Definition Bdef.h:15