MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
domain.h
Go to the documentation of this file.
1 #ifndef DOMAIN_H
2 #define DOMAIN_H
3 
4 #include <mpi.h>
5 #include "utils/peano.h"
6 #include "utils/paramset.h"
7 #include "drift.h"
8 
9 /*These variables are used externally in forcetree.c.
10  * DomainTask is also used in treewalk and NTopLeaves is used in gravpm.c*/
11 
13 {
15  int Daughter;
16  int Shift;
17  int Leaf ;
18 };
19 
20 struct topleaf_data {
21  int Task;
22  union {
23  int topnode; /* used during domain_decompose for balancing the decomposition */
24  int treenode; /* used during life span of the tree for looking up in the tree Nodes */
25  };
26 };
27 
28 struct task_data {
29  int StartLeaf;
30  int EndLeaf;
31 };
32 
33 typedef struct DomainDecomp {
35  /* TopNode and TopLeaf data arrays*/
38  /*Size of the above arrays*/
39  int NTopNodes;
41  struct task_data * Tasks;
42  /* MPI Communicator over which to build the Domain.
43  * Currently this is always MPI_COMM_WORLD.*/
44  MPI_Comm DomainComm;
46 
47 /*Parameters of the domain decomposition, set by the input parameter file*/
48 typedef struct DomainParams
49 {
50  /* Number of TopLeaves (Peano-Hilbert segments) per processor. TopNodes are refined so that no TopLeaf contains
51  * no more than 1/(DODF * NTask) fraction of the work.
52  * The load balancer will assign these TopLeaves so that each MPI rank has a similar amount of work.*/
61 
62 /*Set the parameters of the domain module*/
64 /* Test helper*/
66 
67 /* Do a full domain decomposition, which splits the particles into even clumps*/
68 void domain_decompose_full(DomainDecomp * ddecomp);
69 /* Exchange particles which have moved into the new domains, not re-doing the split unless we have to*/
70 void domain_maintain(DomainDecomp * ddecomp, struct DriftData * drift);
71 
73 static inline int
74 domain_get_topleaf(const peano_t key, const DomainDecomp * ddecomp) {
75  int no=0;
76  while(ddecomp->TopNodes[no].Daughter >= 0)
77  no = ddecomp->TopNodes[no].Daughter + ((key - ddecomp->TopNodes[no].StartKey) >> (ddecomp->TopNodes[no].Shift - 3));
78  no = ddecomp->TopNodes[no].Leaf;
79  return no;
80 };
81 
82 void domain_free(DomainDecomp * ddecomp);
83 
84 #endif
void domain_free(DomainDecomp *ddecomp)
Definition: domain.c:320
void domain_decompose_full(DomainDecomp *ddecomp)
Definition: domain.c:155
struct DomainParams DomainParams
struct DomainDecomp DomainDecomp
void set_domain_params(ParameterSet *ps)
Definition: domain.c:84
static int domain_get_topleaf(const peano_t key, const DomainDecomp *ddecomp)
Definition: domain.h:74
void domain_maintain(DomainDecomp *ddecomp, struct DriftData *drift)
Definition: domain.c:234
void set_domain_par(DomainParams dp)
Definition: domain.c:78
uint64_t peano_t
Definition: peano.h:7
struct topnode_data * TopNodes
Definition: domain.h:36
struct task_data * Tasks
Definition: domain.h:41
MPI_Comm DomainComm
Definition: domain.h:44
int NTopNodes
Definition: domain.h:39
struct topleaf_data * TopLeaves
Definition: domain.h:37
int NTopLeaves
Definition: domain.h:40
int domain_allocated_flag
Definition: domain.h:34
int DomainOverDecompositionFactor
Definition: domain.h:53
int DomainUseGlobalSorting
Definition: domain.h:55
double TopNodeAllocFactor
Definition: domain.h:57
double SetAsideFactor
Definition: domain.h:59
int EndLeaf
Definition: domain.h:30
int StartLeaf
Definition: domain.h:29
int topnode
Definition: domain.h:23
int Task
Definition: domain.h:21
int treenode
Definition: domain.h:24
peano_t StartKey
Definition: domain.h:14
int Leaf
Definition: domain.h:17
int Daughter
Definition: domain.h:15
int Shift
Definition: domain.h:16