NAMD
ComputePatch.C
Go to the documentation of this file.
1 
7 /*
8  Compute object which deals with a single patch.
9 */
10 
11 #include "WorkDistrib.decl.h"
12 #include "Node.h"
13 #include "ComputePatch.h"
14 #include "Priorities.h"
15 #include "PatchMap.inl"
16 #include "Patch.h"
17 #include "ComputeMap.h" //needed for checking GBIS type
18 #include "LdbCoordinator.h"
19 
20 #define MIN_DEBUG_LEVEL 4
21 //#define DEBUGM
22 #include "Debug.h"
23 
25  setNumPatches(1);
26  patchID = p;
27  patch = NULL;
28  positionBox = NULL;
29  forceBox = NULL;
30  gbisPhase = 3;
31 }
32 
34  DebugM(4, "~ComputePatch("<<cid<<") numAtoms("<<patchID<<") = "
35  << numAtoms << "\n");
36  if (positionBox != NULL) {
38  &positionBox);
39  }
40  if (forceBox != NULL) {
42  &forceBox);
43  }
44 }
45 
47  // How can we tell if BoxOwner has packed up and left? Need a mechanism
48  // to handle this or do we assume the Boxes have been dumped?
49 
50  if (positionBox == NULL) { // We have yet to get boxes
51  if (!(patch = PatchMap::Object()->patch(patchID))) {
52  NAMD_bug("ComputePatch used with unknown patch.");
53  }
54  DebugM(3, "initialize(" << cid <<") patchid = "<<patch->getPatchID()<<"\n");
57  }
59 
60  DebugM(3, "initialize("<<cid<<") numAtoms("<<patchID<<") = "
61  << numAtoms << " patchAddr=" << patch << "\n");
63 
64  int myNode = CkMyPe();
65  if ( PatchMap::Object()->node(patchID) != myNode ) {
67  gbisPhasePriority[0] = 0;
70  } else {
72  gbisPhasePriority[0] = 0;
75  }
76 }
77 
79  // How can we tell if BoxOwner has packed up and left? Need a mechanism
80  // to handle this or do we assume the Boxes have been dumped?
82 
83  // DMK - Atom Separation (water vs. non-water)
84  #if NAMD_SeparateWaters != 0
85  numWaterAtoms = patch->getNumWaterAtoms();
86  #endif
87 }
88 
90  DebugM(3,patchID << ": doWork() called.\n");
91 
92 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP)
93  // Inform load balancer.
94  // I assume no threads will suspend until endWork is called
96 #endif
98  (!patch->flags.doGBIS || gbisPhase == 1) ) {
99  // Open up positionBox, forceBox
100  p = positionBox->open();
101  r = forceBox->open();
103  }
104 
105  // Pass pointers to doForce
106  doForce(p, pExt, r);
107 // Inform load balancer
108 #if !defined(NAMD_CUDA) && !defined(NAMD_HIP)
109  if (patch->flags.doGBIS && (gbisPhase == 1 || gbisPhase == 2)) {
111  } else {
113  }
114 #endif
115  // Close up boxes
117  (!patch->flags.doGBIS || gbisPhase == 3) ) {
118  positionBox->close(&p);
119  forceBox->close(&r);
120  }
121  DebugM(2,patchID << ": doWork() completed.\n");
122 }
123 
void setNumPatches(int n)
Definition: Compute.h:52
#define COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:71
CompAtom * p
Definition: ComputePatch.h:37
CompAtomExt * pExt
Definition: ComputePatch.h:36
#define GB1_COMPUTE_HOME_PRIORITY
Definition: Priorities.h:56
#define GB2_COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:60
int ComputeID
Definition: NamdTypes.h:183
static PatchMap * Object()
Definition: PatchMap.h:27
Patch * patch
Definition: ComputePatch.h:46
Box< Patch, Results > * forceBox
Definition: ComputePatch.h:51
#define DebugM(x, y)
Definition: Debug.h:59
void unregisterForceDeposit(Compute *cid, Box< Patch, Results > **const box)
Definition: Patch.C:239
void startWork(const LDObjHandle &handle)
virtual void initialize()
Definition: Compute.h:56
virtual void doForce(CompAtom *p, CompAtomExt *pExt, Results *r)=0
LDObjHandle ldObjHandle
Definition: Compute.h:44
Patch * patch(PatchID pid)
Definition: PatchMap.h:235
void pauseWork(const LDObjHandle &handle)
virtual void atomUpdate()
Definition: ComputePatch.C:78
Flags flags
Definition: Patch.h:127
PatchID patchID
Definition: ComputePatch.h:49
#define COMPUTE_HOME_PRIORITY
Definition: Priorities.h:76
virtual ~ComputePatch()
Definition: ComputePatch.C:33
void NAMD_bug(const char *err_msg)
Definition: common.C:129
virtual void doWork()
Definition: ComputePatch.C:89
Results * r
Definition: ComputePatch.h:38
int computeType
Definition: Compute.h:36
int gbisPhasePriority[3]
Definition: Compute.h:40
ComputePatch(ComputeID c, PatchID pid)
Definition: ComputePatch.C:24
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)
PatchID getPatchID()
Definition: Patch.h:114
#define GB1_COMPUTE_PROXY_PRIORITY
Definition: Priorities.h:52
virtual void initialize()
Definition: ComputePatch.C:46
Box< Patch, CompAtom > * positionBox
Definition: ComputePatch.h:50
#define GB2_COMPUTE_HOME_PRIORITY
Definition: Priorities.h:64
int getNumAtoms()
Definition: Patch.h:105
int doGBIS
Definition: PatchTypes.h:28
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