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