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