66{
74
75 Int Np, Iam, msgid, Rmsgid, i, j;
82
84 if (Np < 2) return;
88 if (REBS = (dest == -1)) dest = 0;
89
90 mydist = (Np + Iam - dest) % Np;
91 if (REBS)
92 {
93 dist = mydist;
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)
103 {
104 BI_Ssend(ctxt, (dest + (mydist-mydist%nbranches)*i)%Np, msgid, bp);
105 break;
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
116 {
117 for (j=nrcvs; j; j--)
118 {
121 }
122 }
123 else
124 {
125 src = (Iam + i) % Np;
126 for (j=nrcvs; j; j--)
127 {
130 src = (src + i) % Np;
131 }
132 }
133 }
134 }
135
136
137
138
139 if (REBS)
140 {
141 mydist = dist;
142 for (i=2; i < Np; i <<= 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}
void BI_Arecv(BLACSCONTEXT *ctxt, Int src, Int msgid, BLACBUFF *bp)
Int BI_BuffIsFree(BLACBUFF *bp, Int Wait)
BLACBUFF * BI_GetBuff(Int length)
void BI_Rsend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
void BI_Srecv(BLACSCONTEXT *ctxt, Int src, Int msgid, BLACBUFF *bp)
void BI_Ssend(BLACSCONTEXT *ctxt, Int dest, Int msgid, BLACBUFF *bp)
void BI_UpdateBuffs(BLACBUFF *Newbp)