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 #include "PatchData.h"
23 
24 #include "Node.h"
25 #include "Compute.h"
26 #include "Priorities.h"
27 
28 #include "LdbCoordinator.h"
29 #include "NamdEventsProfiling.h"
30 #include "SimParameters.h"
31 
32 
33 #define MIN_DEBUG_LEVEL 4
34 // #define DEBUGM
35 #include "Debug.h"
36 
37 Compute::Compute(ComputeID c) : gbisPhase(1),basePriority(0), cid(c),
38  localWorkMsg(new (PRIORITY_SIZE) LocalWorkMsg) {
39  gbisPhasePriority[0] = 0;
40  gbisPhasePriority[1] = 0;
41  gbisPhasePriority[2] = 0;
42  doAtomUpdate = false;
44  LdbIdField(ldObjHandle.id, 0) = 0;
45 }
46 
48  delete localWorkMsg;
49 }
50 
52  if (!this) { DebugM(4,"This Compute is NULL!!!\n"); }
53  if ( ! noWork() ) {
54  //gbisPhase = 1; //first phase - this should already be 1
55  WorkDistrib::messageEnqueueWork(this); // should be in ComputeMgr?
56  } else {
57  //don't enqueue work
58  }
59 }
60 
61 
62 //---------------------------------------------------------------------
63 // Signal from patch or proxy that data is ready.
64 // When all Patches and Proxies needed by this Compute object
65 // have checked-in, we are ready to enqueueWork()
66 //---------------------------------------------------------------------
67 void Compute::patchReady(PatchID patchID, int doneMigration, int seq){
68  if (doneMigration) { // If any patch has done migration - we must remap
69  doAtomUpdate = true;
70  }
71 
72  if (numPatches <= 0) {
73  DebugM(5,"Compute::patchReady("<<patchID<<")-call not valid!\n");
74  } else {
75  if (! --patchReadyCounter) {
76  patchReadyCounter = numPatches;
77  //gbisPhase = 1;
78  sequenceNumber = seq; // breaks CUDA priority if done earlier
79  //fprintf(stderr, "Sequence number %d\n", sequenceNumber);
80  if (doAtomUpdate) {
81  atomUpdate();
82  doAtomUpdate = false;
83  }
84 #ifdef NODEGROUP_FORCE_REGISTER
86  if(!simParams->CUDASOAintegrate){
87  enqueueWork();
88  }
89 #else
90  enqueueWork();
91 #endif
92  }
93  }
94 }
95 
96 void Compute::gbisP2PatchReady(PatchID pid, int seq) {
97 
98  if (! --patchReadyCounter) {
99  patchReadyCounter = numPatches;
100  //gbisPhase = 2;
101  sequenceNumber = seq;
102  enqueueWork();
103  }
104 }
105 
106 void Compute::gbisP3PatchReady(PatchID pid, int seq) {
107  if (! --patchReadyCounter) {
108  patchReadyCounter = numPatches;
109  //gbisPhase = 3;
110  sequenceNumber = seq;
111  enqueueWork();
112  }
113 }
114 
115 
117  return 0;
118 }
119 
121  DebugM(5,"Default Compute::doWork() called.\n");
122 }
123 
125  DebugM(5,"Default Compute::finishPatch() called.\n");
126 }
127 
static Node * Object()
Definition: Node.h:86
virtual void gbisP3PatchReady(PatchID, int seq)
Definition: Compute.C:106
int32 ComputeID
Definition: NamdTypes.h:278
SimParameters * simParameters
Definition: Node.h:181
#define DebugM(x, y)
Definition: Debug.h:75
static void messageEnqueueWork(Compute *)
Definition: WorkDistrib.C:2852
LDObjHandle ldObjHandle
Definition: Compute.h:44
LocalWorkMsg *const localWorkMsg
Definition: Compute.h:46
virtual void gbisP2PatchReady(PatchID, int seq)
Definition: Compute.C:96
virtual void doWork()
Definition: Compute.C:120
#define PRIORITY_SIZE
Definition: Priorities.h:13
ComputeType type(ComputeID cid)
Definition: ComputeMap.C:118
virtual ~Compute()
Definition: Compute.C:47
int computeType
Definition: Compute.h:36
int gbisPhasePriority[3]
Definition: Compute.h:40
const int & LdbIdField(const LdbId &id, const int index)
virtual void finishPatch(int)
Definition: Compute.C:124
#define simParams
Definition: Output.C:129
static ComputeMap * Object()
Definition: ComputeMap.h:89
void enqueueWork()
Definition: Compute.C:51
virtual void atomUpdate()
Definition: Compute.h:59
virtual void patchReady(PatchID, int doneMigration, int seq)
Definition: Compute.C:67
virtual int noWork()
Definition: Compute.C:116
Compute(ComputeID)
Definition: Compute.C:37
int32 PatchID
Definition: NamdTypes.h:277