SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ BI_TreeComb()

void BI_TreeComb ( BLACSCONTEXT ctxt,
BLACBUFF bp,
BLACBUFF bp2,
Int  N,
VVFUNPTR  Xvvop,
Int  dest,
Int  nbranches 
)

Definition at line 19 of file BI_TreeComb.c.

66{
74
75 Int Np, Iam, msgid, Rmsgid, i, j;
76 Int nrcvs=0; /* Number of ReCeiVeS to do */
77 Int REBS; /* should info be RE-BroadcaSt? */
78 Int rightedge; /* right-most receiving node */
79 Int mydist; /* my distance from destination node */
80 Int dist;
81 Int src; /* Used if we must force repeatability */
82
83 Np = ctxt->scp->Np;
84 if (Np < 2) return;
85 Iam = ctxt->scp->Iam;
86 msgid = Mscopeid(ctxt);
87 Rmsgid = Mscopeid(ctxt);
88 if (REBS = (dest == -1)) dest = 0;
89
90 mydist = (Np + Iam - dest) % Np;
91 if (REBS)
92 {
93 dist = mydist;
94 if (mydist != 0) BI_Arecv(ctxt, BANYNODE, Rmsgid, bp);
95 }
96
97 if (nbranches == FULLCON) nbranches = Np;
98 rightedge = Np - 1 - (Np-1)%nbranches;
99
100 for (i=1; (i < Np); i *= nbranches)
101 {
102 if (mydist%nbranches) /* nodes that send to other nodes */
103 {
104 BI_Ssend(ctxt, (dest + (mydist-mydist%nbranches)*i)%Np, msgid, bp);
105 break; /* I'm done */
106 }
107 else
108 {
109 if (mydist != rightedge) nrcvs = nbranches - 1;
110 else nrcvs = (Np + i - 1) / i - rightedge - 1;
111 mydist /= nbranches;
112 rightedge /= nbranches;
113 rightedge -= (rightedge % nbranches);
114
115 if (!ctxt->TopsRepeat)
116 {
117 for (j=nrcvs; j; j--)
118 {
119 BI_Srecv(ctxt, BANYNODE, msgid, bp2);
120 Xvvop(N, bp->Buff, bp2->Buff);
121 }
122 }
123 else
124 {
125 src = (Iam + i) % Np;
126 for (j=nrcvs; j; j--)
127 {
128 BI_Srecv(ctxt, src, msgid, bp2);
129 Xvvop(N, bp->Buff, bp2->Buff);
130 src = (src + i) % Np;
131 }
132 }
133 }
134 }
135
136/*
137 * Broadcast answer to everyone if RDEST == -1
138 */
139 if (REBS)
140 {
141 mydist = dist;
142 for (i=2; i < Np; i <<= 1);
143 if (mydist > 0) BI_BuffIsFree(bp, 1);
144
145 while (i > 1)
146 {
147 if ( !(mydist%i) )
148 {
149 i >>= 1;
150 dist = mydist + i;
151 if (dist < Np) BI_Rsend(ctxt, dist, Rmsgid, bp);
152 }
153 else i >>= 1;
154 }
155 }
156} /* end BI_TreeComb */
void BI_Arecv(BLACSCONTEXT *ctxt, Int src, Int msgid, BLACBUFF *bp)
Definition BI_Arecv.c:3
Int BI_BuffIsFree(BLACBUFF *bp, Int Wait)
BLACBUFF * BI_GetBuff(Int length)
Definition BI_GetBuff.c:37
void BI_Rsend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
Definition BI_Rsend.c:4
void BI_Srecv(BLACSCONTEXT *ctxt, Int src, Int msgid, BLACBUFF *bp)
Definition BI_Srecv.c:3
void BI_Ssend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
Definition BI_Ssend.c:3
void BI_UpdateBuffs(BLACBUFF *Newbp)
#define Int
Definition Bconfig.h:22
#define Mscopeid(ctxt)
Definition Bdef.h:179
#define FULLCON
Definition Bdef.h:100
#define BANYNODE
Definition Bdef.h:76
char * Buff
Definition Bdef.h:56
Int TopsRepeat
Definition Bdef.h:27
BLACSSCOPE * scp
Definition Bdef.h:26
Int Np
Definition Bdef.h:17
Int Iam
Definition Bdef.h:17
Here is the call graph for this function:
Here is the caller graph for this function: