-
Notifications
You must be signed in to change notification settings - Fork 28
/
IntraNodeLBManager.cpp
71 lines (59 loc) · 1.64 KB
/
IntraNodeLBManager.cpp
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
#include "ParallelGravity.h"
#include "IntraNodeLBManager.h"
CpvDeclare(int, tpGravDone);
IntraNodeLBManager::IntraNodeLBManager(CkMigrateMessage *m) :
CBase_IntraNodeLBManager(m) {
total_tps_ = 0;
tps_done_ = 0;
CpvInitialize(int, tpGravDone );
CpvAccess(tpGravDone) = 1;
}
IntraNodeLBManager::IntraNodeLBManager(int dummy, CkGroupID gid) :
total_tps_(0), tps_done_(0), num_loc_mgr_(1) {
loc_mgr_ = new CkGroupID[1];
loc_mgr_[0] = gid;
CpvInitialize(int, tpGravDone );
CpvAccess(tpGravDone) = 1;
}
void IntraNodeLBManager::registerTP() {
if (total_tps_ > 0) {
return;
}
tps_done_ = 0;
CkCacheArrayCounter local_chares;
for (int i = 0; i < num_loc_mgr_; ++i) {
CkLocMgr *mgr = (CkLocMgr *)CkLocalBranch(loc_mgr_[i]);
mgr->iterate(local_chares);
}
total_tps_ = local_chares.count;
CpvAccess(tpGravDone) = 0;
}
void IntraNodeLBManager::finishedTPWork() {
tps_done_++;
// All the work for the TPs in this PE is done so reset the counters for the
// next iteration
if (tps_done_ == total_tps_) {
total_tps_ = 0;
tps_done_ = 0;
CpvAccess(tpGravDone) = 1;
}
}
vector<int> IntraNodeLBManager::getOtherIdlePes() {
vector<int> idlepes;
int nsize = CkNodeSize(CkMyNode());
for (int i = 0; i < nsize; i++) {
if (CpvAccessOther(tpGravDone, i) == 1 &&
(CkNodeFirst(CkMyNode()) + i)!=CkMyPe()) {
idlepes.push_back(CkNodeFirst(CkMyNode()) + i);
}
}
return idlepes;
}
void IntraNodeLBManager::pup(PUP::er &p) {
CBase_IntraNodeLBManager::pup(p);
p | num_loc_mgr_;
if (p.isUnpacking()) {
loc_mgr_ = new CkGroupID[num_loc_mgr_];
}
PUParray(p, loc_mgr_, num_loc_mgr_);
}