File: BI_MpathBS.c

package info (click to toggle)
blacs-mpi 1.1-28.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,320 kB
  • ctags: 2,031
  • sloc: fortran: 14,968; ansic: 12,353; makefile: 531; sh: 1
file content (50 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download | duplicates (11)
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
#include "Bdef.h"

void BI_MpathBS(BLACSCONTEXT *ctxt, BLACBUFF *bp, SDRVPTR send, int npaths)
{
   int pathlen;		/* the length of each path */
   int dist;	        /* the distance to the node closest to src on each path */
   int pdest;           /* part of dest calculation -- saves unneeded ops */
   int lastlong;	/* number of paths with extra node */
   int Np, Iam, msgid, Np_1, dir;

   Np = ctxt->scp->Np;
   if (Np < 2) return;
   Iam = ctxt->scp->Iam;
   msgid = Mscopeid(ctxt);
   Np_1 = Np - 1;
   if (npaths == FULLCON) npaths = Np_1;

   if (npaths > 0)  /* paths are increasing rings */
   {
      pdest = Iam;
      dir = 1;
   }
   else             /* paths are decreasing rings */
   {
      pdest = Np + Iam;
      dir = -1;
      npaths = -npaths;
   }
/*
 * Ensure npaths is correct
 */
   if (npaths > Np_1) npaths = Np_1;
   pathlen = Np_1 / npaths;

/*
 * Loop over all long paths (paths with an extra node), if there are any
 */
   lastlong = (Np_1 % npaths) * (pathlen+1);  /* last node in long ring */
   for (dist=1; dist < lastlong; dist += pathlen+1)
      send(ctxt, (pdest+dir*dist)%Np, msgid, bp);

/*
 * Loop over all normal length paths
 */
   while (dist < Np)
   {
      send(ctxt, (pdest+dir*dist)%Np, msgid, bp);
      dist += pathlen;
   }
}