NAMD
Compute.C
Go to the documentation of this file.
1 
7 /*
8  Top of Compute hierarchy.
9  enqueueWork() - delivers Compute object itself to queue up for doWork()
10  doWork() - called by work queue
11 */
12 
13 #include "main.h"
14 #include "charm++.h"
15 
16 #include "WorkDistrib.decl.h"
17 #include "WorkDistrib.h"
18 
19 #include "NamdTypes.h"
20 #include "Box.h"
21 #include "OwnerBox.h"
22 
23 #include "Node.h"
24 #include "Compute.h"
25 #include "Priorities.h"
26 
27 #include "LdbCoordinator.h"
28 
29 #define MIN_DEBUG_LEVEL 4
30 // #define DEBUGM
31 #include "Debug.h"
32 
33 Compute::Compute(ComputeID c) : gbisPhase(1),basePriority(0), cid(c),
34  localWorkMsg(new (PRIORITY_SIZE) LocalWorkMsg) {
35  gbisPhasePriority[0] = 0;
36  gbisPhasePriority[1] = 0;
37  gbisPhasePriority[2] = 0;
38  doAtomUpdate = false;
40  LdbIdField(ldObjHandle.id, 0) = 0;
41 }
42 
44  delete localWorkMsg;
45 }
46 
48  if (!this) { DebugM(4,"This Compute is NULL!!!\n"); }
49  if ( ! noWork() ) {
50  //gbisPhase = 1; //first phase - this should already be 1
51  WorkDistrib::messageEnqueueWork(this); // should be in ComputeMgr?
52  } else {
53  //don't enqueue work
54  }
55 }
56 
57 
58 //---------------------------------------------------------------------
59 // Signal from patch or proxy that data is ready.
60 // When all Patches and Proxies needed by this Compute object
61 // have checked-in, we are ready to enqueueWork()
62 //---------------------------------------------------------------------
63 void Compute::patchReady(PatchID patchID, int doneMigration, int seq) {
64  if (doneMigration) { // If any patch has done migration - we must remap
65  doAtomUpdate = true;
66  }
67 
68  if (numPatches <= 0) {
69  DebugM(5,"Compute::patchReady("<<patchID<<")-call not valid!\n");
70  } else {
71  if (! --patchReadyCounter) {
72  patchReadyCounter = numPatches;
73  //gbisPhase = 1;
74  sequenceNumber = seq; // breaks CUDA priority if done earlier
75  if (doAtomUpdate) {
76  atomUpdate();
77  doAtomUpdate = false;
78  }
79  enqueueWork();
80  }
81  }
82 }
83 
84 void Compute::gbisP2PatchReady(PatchID pid, int seq) {
85 
86  if (! --patchReadyCounter) {
87  patchReadyCounter = numPatches;
88  //gbisPhase = 2;
89  sequenceNumber = seq;
90  enqueueWork();
91  }
92 }
93 
94 void Compute::gbisP3PatchReady(PatchID pid, int seq) {
95  if (! --patchReadyCounter) {
96  patchReadyCounter = numPatches;
97  //gbisPhase = 3;
98  sequenceNumber = seq;
99  enqueueWork();
100  }
101 }
102 
103 
105  return 0;
106 }
107 
109  DebugM(5,"Default Compute::doWork() called.\n");
110 }
111 
113  DebugM(5,"Default Compute::finishPatch() called.\n");
114 }
115 
virtual void gbisP3PatchReady(PatchID, int seq)
Definition: Compute.C:94
int ComputeID
Definition: NamdTypes.h:183
#define DebugM(x, y)
Definition: Debug.h:59
static void messageEnqueueWork(Compute *)
Definition: WorkDistrib.C:2727
LDObjHandle ldObjHandle
Definition: Compute.h:44
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
virtual void gbisP2PatchReady(PatchID, int seq)
Definition: Compute.C:84
virtual void doWork()
Definition: Compute.C:108
#define PRIORITY_SIZE
Definition: Priorities.h:13
ComputeType type(ComputeID cid)
Definition: ComputeMap.C:120
virtual ~Compute()
Definition: Compute.C:43
int computeType
Definition: Compute.h:36
int gbisPhasePriority[3]
Definition: Compute.h:40
int PatchID
Definition: NamdTypes.h:182
const int & LdbIdField(const LdbId &id, const int index)
virtual void finishPatch(int)
Definition: Compute.C:112
static ComputeMap * Object()
Definition: ComputeMap.h:89
void enqueueWork()
Definition: Compute.C:47
virtual void atomUpdate()
Definition: Compute.h:59
virtual void patchReady(PatchID, int doneMigration, int seq)
Definition: Compute.C:63
virtual int noWork()
Definition: Compute.C:104
Compute(ComputeID)
Definition: Compute.C:33