ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
BI_MpathBR.c
Go to the documentation of this file.
1 #include "Bdef.h"
2 
3 void BI_MpathBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int src, int npaths)
4 {
5  void BI_Arecv(BLACSCONTEXT *, int, int, BLACBUFF *);
6  int BI_BuffIsFree(BLACBUFF *, int);
7 
8  int pathlen; /* the minimal length of each path */
9  int mydist; /* my distance from src */
10  int faredge; /* node at far end of path */
11  int lastlong; /* distance to node on end of last path with extra node */
12  int Np, Iam, msgid, Np_1, dest;
13 
14  msgid = Mscopeid(ctxt);
15  BI_Arecv(ctxt, BANYNODE, msgid, bp);
16  Np = ctxt->scp->Np;
17  Iam = ctxt->scp->Iam;
18  Np_1 = Np - 1;
19  if (npaths == FULLCON) npaths = Np_1;
20 
21  if (npaths > 0)
22  {
23  dest = (Iam+1) % Np;
24  mydist = (Np + Iam - src) % Np;
25  }
26  else
27  {
28  dest = (Np_1+Iam) % Np;
29  mydist = (Np + src - Iam) % Np;
30  npaths = -npaths;
31  }
32 /*
33  * Make sure npaths is cool
34  */
35  if (npaths > Np_1) npaths = Np_1;
36 
37  pathlen = Np_1 / npaths;
38  lastlong = (Np_1%npaths) * (pathlen+1);
39  if (lastlong)
40  {
41  if (mydist <= lastlong) faredge = ((mydist-1)/(pathlen+1)+1)*(pathlen+1);
42  else faredge = ((lastlong-1)/(pathlen+1)+1) * (pathlen+1)
43  + ((mydist-lastlong-1)/pathlen + 1) * pathlen;
44  }
45  else faredge = ((mydist-1)/pathlen + 1) * pathlen;
46 
47  BI_BuffIsFree(bp, 1); /* wait for recv to complete */
48  if (mydist < faredge) send(ctxt, dest, msgid, bp);
49 }
FULLCON
#define FULLCON
Definition: Bdef.h:100
BI_MpathBR
void BI_MpathBR(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int src, int npaths)
Definition: BI_MpathBR.c:3
bLaCbUfF
Definition: Bdef.h:54
bLaCsScOpE::Iam
int Iam
Definition: Bdef.h:17
Mscopeid
#define Mscopeid(ctxt)
Definition: Bdef.h:179
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_Arecv
void BI_Arecv(BLACSCONTEXT *ctxt, int src, int msgid, BLACBUFF *bp)
Definition: BI_Arecv.c:3
bLaCsScOpE::Np
int Np
Definition: Bdef.h:17
BANYNODE
#define BANYNODE
Definition: Bdef.h:76
BI_BuffIsFree
int BI_BuffIsFree(BLACBUFF *bp, int Wait)
Definition: BI_BuffIsFree.c:3