SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
itrbr2d_.c
Go to the documentation of this file.
1#include "Bdef.h"
2
3#if (INTFACE == C_CALL)
4void Citrbr2d(Int ConTxt, char *scope, char *top, char *uplo, char *diag,
5 Int m, Int n, Int *A, Int lda, Int rsrc, Int csrc)
6#else
7F_VOID_FUNC itrbr2d_(Int *ConTxt, F_CHAR scope, F_CHAR top, F_CHAR uplo,
8 F_CHAR diag, Int *m, Int *n, Int *A, Int *lda,
9 Int *rsrc, Int *csrc)
10#endif
11/*
12 * -- V1.1 BLACS routine --
13 * University of Tennessee, May 1, 1996
14 * Written by Clint Whaley.
15 *
16 * Purpose
17 * =======
18 * Broadcast/receive for trapezoidal integer arrays.
19 *
20 * Arguments
21 * =========
22 *
23 * ConTxt (input) Ptr to Int
24 * Index into MyConTxts00 (my contexts array).
25 *
26 * SCOPE (input) Ptr to char
27 * Limit the scope of the operation.
28 * = 'R' : Operation is performed by a process row.
29 * = 'C' : Operation is performed by a process column.
30 * = 'A' : Operation is performed by all processes in grid.
31 *
32 * TOP (input) Ptr to char
33 * Controls fashion in which messages flow within the operation.
34 *
35 * UPLO (input) Ptr to char
36 * Specifies the part of the matrix to be sent.
37 * = 'U': Upper trapezoidal part
38 * ELSE : Lower trapezoidal part
39 *
40 * DIAG (input) Ptr to char
41 * Specifies whether the matrix is unit diagonal or not.
42 * = 'U': Matrix is unit diagonal, diagonal not communicated.
43 * ELSE : Matrix is not unit diagonal, diagonal is communicated.
44 *
45 * M (input) Ptr to Int
46 * The number of rows of the matrix A. M >= 0.
47 *
48 * N (input) Ptr to Int
49 * The number of columns of the matrix A. N >= 0.
50 *
51 * A (output) Ptr to integer two dimensional array
52 * The m by n matrix A. Fortran77 (column-major) storage
53 * assumed.
54 * If UPLO = 'U', only the upper trapezoid is accessed;
55 * if UPLO = 'L', only the lower trapezoid is accessed.
56 *
57 * LDA (input) Ptr to Int
58 * The leading dimension of the array A. LDA >= M.
59 *
60 *
61 * RSRC (input) Ptr to Int
62 * The process row of the source of the matrix.
63 *
64 * CSRC (input) Ptr to Int
65 * The process column of the source of the matrix.
66 *
67 *
68 * ------------------------------------------------------------------------
69 */
70{
71 void BI_ArgCheck(Int, Int, char *, char, char, char, Int, Int, Int, Int,
72 Int *, Int *);
81 MPI_Datatype BI_GetMpiTrType(BLACSCONTEXT *, char, char, Int, Int, Int,
82 MPI_Datatype, Int *);
83 void BI_Unpack(BLACSCONTEXT *, BVOID *, BLACBUFF *, MPI_Datatype);
86
87 BLACSCONTEXT *ctxt;
88 BLACBUFF *bp=NULL;
89 SDRVPTR send;
90 MPI_Datatype IntTyp, MatTyp;
91 Int length, src, tlda, error, one=1;
92 char ttop, tscope, tuplo, tdiag;
94
95 MGetConTxt(Mpval(ConTxt), ctxt);
96 ttop = F2C_CharTrans(top);
97 ttop = Mlowcase(ttop);
98 tscope = F2C_CharTrans(scope);
99 tscope = Mlowcase(tscope);
100 tdiag = F2C_CharTrans(diag);
101 tdiag = Mlowcase(tdiag);
102 tuplo = F2C_CharTrans(uplo);
103 tuplo = Mlowcase(tuplo);
104#if (BlacsDebugLvl > 0)
105 BI_ArgCheck(Mpval(ConTxt), RT_BR, __FILE__, tscope, tuplo, tdiag, Mpval(m),
106 Mpval(n), Mpval(lda), 1, Mpaddress(rsrc), Mpaddress(csrc));
107#endif
108/*
109 * If the user has set the default broadcast topology, use it instead of
110 * BLACS default
111 */
112#ifdef DefBSTop
113 if (ttop == ' ') ttop = DefBSTop;
114#endif
115 if (Mpval(m) <= Mpval(lda)) tlda = Mpval(lda);
116 else tlda = Mpval(m);
117
118 switch(tscope)
119 {
120 case 'r':
121 ctxt->scp = &ctxt->rscp;
122 src = Mpval(csrc);
123 break;
124 case 'c':
125 ctxt->scp = &ctxt->cscp;
126 src = Mpval(rsrc);
127 break;
128 case 'a':
129 ctxt->scp = &ctxt->ascp;
130 src = Mvkpnum(ctxt, Mpval(rsrc), Mpval(csrc));
131 break;
132 default:
133 BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown scope '%c'",
134 tscope);
135 }
136
137 MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(Int), &IntTyp);
138 MatTyp = BI_GetMpiTrType(ctxt, tuplo, tdiag, Mpval(m), Mpval(n), tlda,
139 IntTyp, &BI_AuxBuff.N);
140/*
141 * If using default topology, use MPI native broadcast
142 */
143 if (ttop == ' ')
144 {
145 error=MPI_Bcast(A, BI_AuxBuff.N, MatTyp, src, ctxt->scp->comm);
146 error=BI_MPI_TYPE_FREE(&MatTyp);
147 if (BI_ActiveQ) BI_UpdateBuffs(NULL);
148 return;
149 }
150/*
151 * If MPI handles non-contiguous buffering well, always use MPI data types
152 * instead of packing
153 */
154#ifdef MpiBuffGood
155 send = BI_Ssend;
156 BI_AuxBuff.Buff = (char *) A;
157 BI_AuxBuff.dtype = MatTyp;
158 bp = &BI_AuxBuff;
159#else
160
161 send = BI_Asend;
162 MPI_Pack_size(one, MatTyp, ctxt->scp->comm, &length);
163 bp = BI_GetBuff(length);
164 bp->N = length;
165 bp->dtype = MPI_PACKED;
166#if ZeroByteTypeBug
167 if (MatTyp == MPI_BYTE)
168 {
169 send = BI_Ssend;
170 bp->N = 0;
171 bp->dtype = MPI_BYTE;
172 }
173#endif
174
175#endif
176
177 switch(ttop)
178 {
179 case 'h':
180 error = BI_HypBR(ctxt, bp, send, src);
181 if (error == NPOW2) BI_TreeBR(ctxt, bp, send, src, 2);
182 break;
183 case '1':
184 case '2':
185 case '3':
186 case '4':
187 case '5':
188 case '6':
189 case '7':
190 case '8':
191 case '9':
192 BI_TreeBR(ctxt, bp, send, src, ttop-47);
193 break;
194 case 't':
195 BI_TreeBR(ctxt, bp, send, src, ctxt->Nb_bs);
196 break;
197 case 'i':
198 BI_IdringBR(ctxt, bp, send, src, 1);
199 break;
200 case 'd':
201 BI_IdringBR(ctxt, bp, send, src, -1);
202 break;
203 case 's':
204 BI_SringBR(ctxt, bp, send, src);
205 break;
206 case 'm':
207 BI_MpathBR(ctxt, bp, send, src, ctxt->Nr_bs);
208 break;
209 case 'f':
210 BI_MpathBR(ctxt, bp, send, src, FULLCON);
211 break;
212 default :
213 BI_BlacsErr(Mpval(ConTxt), __LINE__, __FILE__, "Unknown topology '%c'",
214 ttop);
215 }
216
217#ifdef MpiBuffGood
218 error=BI_MPI_TYPE_FREE(&MatTyp);
219 if (BI_ActiveQ) BI_UpdateBuffs(NULL);
220#endif
221#ifndef MpiBuffGood
222 BI_Unpack(ctxt, (BVOID *) A, bp, MatTyp);
223 BI_UpdateBuffs(bp);
224#endif
225}
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_GetMpiTrType(BLACSCONTEXT *ctxt, char uplo, char diag, 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 Citrbr2d()
char * F_CHAR
Definition pblas.h:113
F_VOID_FUNC itrbr2d_(Int *ConTxt, F_CHAR scope, F_CHAR top, F_CHAR uplo, F_CHAR diag, Int *m, Int *n, Int *A, Int *lda, Int *rsrc, Int *csrc)
Definition itrbr2d_.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