The FARGO_THORIN code developer's guide
 All Data Structures Files Functions Variables Typedefs Macros
split.c
Go to the documentation of this file.
1 /** \file split.c
2 
3 Split (radially) the mesh among the different processors. A simple
4 Round Robin algorithm is used to achieve a proper load balancing,
5 assuming the cluster to be homogeneous. A ring described by a given
6 process has its 5 (CPUOVERLAP) innermost zones that are ghost zones
7 which are filled by communications with the previous inner process
8 (unless it is the innermost process itself), and its 5 (CPUOVERLAP)
9 outermost zones that are ghost zones which are filled by
10 communications with the next outer process (unless it is the outermost
11 process itself). The "active" part of the submesh described by a given
12 process is the part of this mesh that excludes the ghost zones. For
13 each process, the (local) radial index of the first active ring is
14 Zero_or_active, and the (local) radial index of the last active ring
15 is Max_or_active. MaxMO_or_active is Max_or_active for all processes,
16 except the very last one (the outermost) for which it is
17 Max_or_active-1 (MO stands for 'Minus One').
18 
19 */
20 
21 
22 #include "fargo.h"
23 
24 void SplitDomain () {
25  int remainder;
26  int size_low, size_high;
27  GLOBALNRAD = NRAD;
28  size_low = NRAD/CPU_Number;
29  size_high = size_low+1;
30  remainder = NRAD % CPU_Number;
31  if (size_low < 2*CPUOVERLAP) {
32  mastererr("The number of processes is too large\n");
33  mastererr("or the mesh is radially too narrow.\n");
34  prs_exit(1);
35  }
36  if (CPU_Rank < remainder) {
37  IMIN = size_high*CPU_Rank;
38  IMAX = IMIN+size_high-1;
39  } else {
40  IMIN = size_high*remainder+(CPU_Rank-remainder)*size_low;
41  IMAX = IMIN+size_low-1;
42  }
43  if (CPU_Rank > 0) IMIN -= CPUOVERLAP;
45  NRAD = IMAX-IMIN+1;
46  Zero_or_active = CPUOVERLAP * (CPU_Rank > 0 ? 1 : 0);
47  One_or_active = 1+(CPUOVERLAP-1) * (CPU_Rank > 0 ? 1 : 0);
49  MaxMO_or_active = NRAD-1-(CPUOVERLAP-1)*(CPU_Rank < CPU_Number-1 ? 1 : 0);
50  if (debug == YES) {
51  masterprint ("%d = %d * %d + %d\n", GLOBALNRAD, CPU_Number, size_low, remainder);
52  printf ("IMIN process %d : %d\n", CPU_Rank, IMIN);
53  printf ("IMAX process %d : %d\n", CPU_Rank, IMAX);
54  printf ("NRAD process %d : %d\n", CPU_Rank, NRAD);
55  printf ("Zero_or_active process %d : %d\n", CPU_Rank, Zero_or_active);
56  printf ("One_or_active process %d : %d\n", CPU_Rank, One_or_active);
57  printf ("Max_or_active process %d : %d\n", CPU_Rank, Max_or_active);
58  printf ("MaxMO_or_active process %d : %d\n", CPU_Rank, MaxMO_or_active);
59  printf ("GLOB process %d : %d\n", CPU_Rank, GLOBALNRAD);
60  }
61 }
62 
int CPU_Number
Definition: global.h:2
#define YES
Definition: types.h:46
int Zero_or_active
Definition: global.h:6
int One_or_active
Definition: global.h:8
int MaxMO_or_active
Definition: global.h:9
int IMIN
Definition: global.h:4
int GLOBALNRAD
Definition: global.h:10
#define CPUOVERLAP
Definition: fondam.h:13
int Max_or_active
Definition: global.h:7
int IMAX
Definition: global.h:5
void mastererr(const char *template,...)
Definition: LowTasks.c:49
int NRAD
Definition: param_noex.h:18
Contains all the include directives requested by the code.
int CPU_Rank
Definition: global.h:1
boolean debug
Definition: global.h:29
void SplitDomain()
Definition: split.c:24
void prs_exit(int numb)
Definition: LowTasks.c:33
void masterprint(const char *template,...)
Definition: LowTasks.c:40