ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
BI_TreeBR.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 
3 void BI_TreeBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int src, int nbranches)
4 {
5  void BI_Srecv(BLACSCONTEXT *, int, int, BLACBUFF *);
6  int Np, Iam, msgid, i, j;
7  int mydist; /* my distance from src */
8  int destdist; /* the distance of the destination node */
9 
10  Np = ctxt->scp->Np;
11  if (Np < 2) return;
12  Iam = ctxt->scp->Iam;
13  msgid = Mscopeid(ctxt);
14  mydist = (Np + Iam - src) % Np;
15 
16 /*
17  * Go up to first step of tree where I send data to other nodes
18  */
19  for (i=nbranches; i < Np; i *= nbranches);
20  for (i /= nbranches; (mydist%i); i /= nbranches);
21  BI_Srecv(ctxt, BANYNODE, msgid, bp);
22 
23 /*
24  * While I need to send data to others
25  */
26  while ( (i > 1) && !(mydist%i) )
27  {
28  i /= nbranches;
29  j = 1;
30  do
31  {
32  destdist = mydist + j*i;
33  if (destdist < Np)
34  send(ctxt, (src+destdist)%Np, msgid, bp);
35  }
36  while(++j < nbranches);
37  }
38 
39 } /* end BI_TreeBR */
bLaCbUfF
Definition: Bdef.h:54
bLaCsScOpE::Iam
int Iam
Definition: Bdef.h:17
Mscopeid
#define Mscopeid(ctxt)
Definition: Bdef.h:179
BI_TreeBR
void BI_TreeBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int src, int nbranches)
Definition: BI_TreeBR.c:3
bLaCsCoNtExT
Definition: Bdef.h:23
SDRVPTR
void(* SDRVPTR)(BLACSCONTEXT *, int, int, BLACBUFF *)
Definition: Bdef.h:69
bLaCsCoNtExT::scp
BLACSSCOPE * scp
Definition: Bdef.h:26
Bdef.h
BI_Srecv
void BI_Srecv(BLACSCONTEXT *ctxt, int src, int msgid, BLACBUFF *bp)
Definition: BI_Srecv.c:3
bLaCsScOpE::Np
int Np
Definition: Bdef.h:17
BANYNODE
#define BANYNODE
Definition: Bdef.h:76