NAMD
ComputePatchPair.C
Go to the documentation of this file.
1 
7 #include "WorkDistrib.decl.h"
8 #include "Node.h"
9 #include "ComputePatchPair.h"
10 #include "Priorities.h"
11 #include "PatchMap.inl"
12 #include "Patch.h"
13 #include "ComputeMap.h"
14 #include "LdbCoordinator.h"
15 
16 //#define DEBUGM
17 #define MIN_DEBUG_LEVEL 4
18 #include "Debug.h"
19 
21  : Compute(c) {
22 
23  gbisPhase = 3;
24  setNumPatches(2);
25 
26  for (int i=0; i<2; i++) {
27  patchID[i] = p[i];
28  trans[i] = t[i];
29  patch[i] = NULL;
30  positionBox[i] = NULL;
31  forceBox[i] = NULL;
32  }
33 }
34 
36  DebugM(4, "~ComputePatchPair("<<cid<<") numAtoms("<<patchID[0]<<") = "
37  << numAtoms[0]
38  << " numAtoms("<<patchID[1]<<") = " << numAtoms[1] << "\n" );
39  DebugM(4, "~ComputePatchPair("<<cid<<") addr("<<patchID[0]<<") = "
40  << PatchMap::Object()->patch(patchID[0]) << " addr("<<patchID[1]<<") = "
41  << PatchMap::Object()->patch(patchID[1]) << "\n");
42  for (int i=0; i<2; i++) {
43  if (positionBox[i] != NULL) {
45  &positionBox[i]);
46  }
47  if (forceBox[i] != NULL) {
49  &forceBox[i]);
50  }
51  }
52 
53 }
54 
56  // How can we tell if BoxOwner has packed up and left? Need a mechanism
57  // to handle this or do we assume the Boxes have been dumped?
58 
59  for (int i=0; i<2; i++) {
60  if (positionBox[i] == NULL) { // We have yet to get boxes
61  if (!(patch[i] = PatchMap::Object()->patch(patchID[i]))) {
62  DebugM(5,"invalid patch(" << patchID[i]
63  << ") pointer!\n");
64  }
66  forceBox[i] = patch[i]->registerForceDeposit(this);
67  }
68  numAtoms[i] = patch[i]->getNumAtoms();
69  }
70 
71  DebugM(4, "initialize("<<cid<<") numAtoms("<<patchID[0]<<") = "
72  << numAtoms[0]
73  << " numAtoms(" <<patchID[1]<<") = " << numAtoms[1] << "\n" );
74 
76 
77  // proxies are more urgent (lower priority) than patches
78  int myNode = CkMyPe();
79  int p0 = PATCH_PRIORITY(patchID[0]);
80  if ( PatchMap::Object()->node(patchID[0]) == myNode ) {
82  } else {
84  }
85  int p1 = PATCH_PRIORITY(patchID[1]);
86  if ( PatchMap::Object()->node(patchID[1]) == myNode ) {
88  } else {
90  }
91  if (p0<p1) { //base phase priorities off of p0
92  if ( PatchMap::Object()->node(patchID[0]) == myNode ) {
93  gbisPhasePriority[0] = 0;
96  } else {
97  gbisPhasePriority[0] = 0;
100  }
101  } else { //base phase priorities off of p1
102  if ( PatchMap::Object()->node(patchID[1]) == myNode ) {
103  gbisPhasePriority[0] = 0;
106  } else {
107  gbisPhasePriority[0] = 0;
110  }
111  }
112  basePriority = ((p0<p1)?p0:p1); // most urgent wins
113 
114 }
115 
117  // How can we tell if BoxOwner has packed up and left? Need a mechanism
118  // to handle this or do we assume the Boxes have been dumped?
119 
120  // DebugM(4,"atomUpdate() - positionBox[0] is " << positionBox[0] << "\n");
121  for (int i=0; i<2; i++) {
122 
123  numAtoms[i] = patch[i]->getNumAtoms();
124 
125  // DMK - Atom Separation (water vs. non-water)
126  #if NAMD_SeparateWaters != 0
127  numWaterAtoms[i] = patch[i]->getNumWaterAtoms();
128  #endif
129  }
130 
131 
132 
133  // Compute::atomUpdate();
134 }
135 
136 
138 {
139  CkPrintf("ComputePatchPair::doForce() - Dummy eval was sent\n");
140  CkPrintf(" %d patch 1 atoms and %d patch 2 atoms\n", numAtoms[0], numAtoms[1] );
141 }
142 
143 //---------------------------------------------------------------------
144 // Where the actual computation is invoked. doForce is
145 // overloaded with specific calculation
146 //---------------------------------------------------------------------
148 
149 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP)
151 #endif
153  (!patch[0]->flags.doGBIS || gbisPhase == 1) ) {
154  // Open up positionBox, forceBox, and atomBox
155  for (int i=0; i<2; i++) {
156  p[i] = positionBox[i]->open();
157  r[i] = forceBox[i]->open();
158  pExt[i] = patch[i]->getCompAtomExtInfo();
159  }
160  }
161 
162  doForce(p, pExt, r);
163  // Inform load balancer
164 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP)
165  if (patch[0]->flags.doGBIS && (gbisPhase == 1 || gbisPhase == 2)) {
167  } else {
169  }
170 #endif
171 
172  // Close up boxes
174  (!patch[0]->flags.doGBIS || gbisPhase == 3) ) {
175  for (int i=0; i<2; i++) {
176  positionBox[i]->close(&p[i]);
177  forceBox[i]->close(&r[i]);
178  }
179  }
180 
181 }
182 
void setNumPatches(int n)
Definition: Compute.h:52
#define COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:71
#define GB1_COMPUTE_HOME_PRIORITY
Definition: Priorities.h:56
#define GB2_COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:60
int ComputeID
Definition: NamdTypes.h:183
CompAtom * p[2]
Box< Patch, CompAtom > * positionBox[2]
static PatchMap * Object()
Definition: PatchMap.h:27
#define DebugM(x, y)
Definition: Debug.h:59
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:239
CompAtomExt * pExt[2]
void startWork(const LDObjHandle &handle)
virtual void initialize()
Definition: Compute.h:56
LDObjHandle ldObjHandle
Definition: Compute.h:44
Patch * patch(PatchID pid)
Definition: PatchMap.h:235
void pauseWork(const LDObjHandle &handle)
Box< Patch, Results > * forceBox[2]
virtual void doWork()
#define COMPUTE_HOME_PRIORITY
Definition: Priorities.h:76
virtual void initialize()
virtual ~ComputePatchPair()
int computeType
Definition: Compute.h:36
int gbisPhasePriority[3]
Definition: Compute.h:40
virtual void atomUpdate()
int PatchID
Definition: NamdTypes.h:182
static LdbCoordinator * Object()
int gbisPhase
Definition: Compute.h:39
void unregisterPositionPickup(Compute *cid, Box< Patch, CompAtom > **const box)
Definition: Patch.C:122
void endWork(const LDObjHandle &handle)
#define GB1_COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:52
#define GB2_COMPUTE_HOME_PRIORITY
Definition: Priorities.h:64
int getNumAtoms()
Definition: Patch.h:105
virtual void doForce(CompAtom *p[2], CompAtomExt *pExt[2], Results *r[2])
ComputePatchPair(ComputeID c, PatchID pid[], int t[])
int basePriority
Definition: Compute.h:37
Data * open(void)
Definition: Box.h:39
const ComputeID cid
Definition: Compute.h:43
void close(Data **const t)
Definition: Box.h:49
Box< Patch, CompAtom > * registerPositionPickup(Compute *cid)
Definition: Patch.C:107
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25
CompAtomExt * getCompAtomExtInfo()
Definition: Patch.h:117
Box< Patch, Results > * registerForceDeposit(Compute *cid)
Definition: Patch.C:228