File: Cnumroc2.c

package info (click to toggle)
scalapack 1.6-13
  • links: PTS
  • area: main
  • in suites: potato
  • size: 30,476 kB
  • ctags: 25,789
  • sloc: fortran: 296,718; ansic: 51,265; makefile: 1,541; sh: 4
file content (45 lines) | stat: -rw-r--r-- 914 bytes parent folder | download
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
#include "tools.h"
int Cnumroc2(N, I, nb, proc, srcproc, nproc)
int N;
int I;
int nb;
int proc;
int srcproc;
int  nproc;
{
   int nrocs=0, nblocks, extrablocks, dist;
/*
 * If I is non-zero, handle possibly partial first block
 */
   if (I)
   {
      srcproc = MCindxg2p(I, nb, srcproc, nproc);
      nrocs = nb - (I % nb);
      if (nrocs > N) nrocs = N;

      if (nrocs)
      {
         N -= nrocs;
         if (proc != srcproc) nrocs = 0;
         srcproc = (srcproc + 1) % nproc;
      }
   }

/*
 * Figure proc's distance from srcproc
 */
   dist = (nproc + proc - srcproc) % nproc;
/*
 * Figure number of blocks given to all processes
 */
   nblocks = N / nb;
   nrocs += (nblocks/nproc) * nb;
/*
 * If we've got blocks that are not given to all processes
 */
   extrablocks = nblocks % nproc;
   if (dist < extrablocks) nrocs += nb;
   else if (dist == extrablocks) nrocs += N % nb;

   return(nrocs);
}