improved planner
This commit is contained in:
@@ -104,9 +104,8 @@ public:
|
||||
}
|
||||
|
||||
map<int, queue<T*>, std::greater<int>> sortedByKernelNeeds;
|
||||
|
||||
long activeTasks = 0;
|
||||
long done = 0;
|
||||
size_t activeTasks = 0;
|
||||
|
||||
for (auto& task : this->getElements()) {
|
||||
if (task->getState() == WorkspaceReady) {
|
||||
activeTasks++;
|
||||
@@ -126,6 +125,10 @@ public:
|
||||
|
||||
vector<int> emptyKeys;
|
||||
vector<T*> toDel;
|
||||
|
||||
size_t done = 0;
|
||||
size_t step = activeTasks * 0.01; // step == 1%
|
||||
const double total = activeTasks;
|
||||
|
||||
while (activeTasks) {
|
||||
long oldActiveTasks = activeTasks;
|
||||
@@ -143,8 +146,9 @@ public:
|
||||
|
||||
activeTaskSet.insert(task);
|
||||
task->Start(ignoreCheck);
|
||||
#if DEB
|
||||
printf("start task with %d kernels and id %ld\n", task->getKernels(), task->getId());
|
||||
|
||||
#endif
|
||||
busyKernels += task->getKernels();
|
||||
freeKernels = maxKernels - busyKernels;
|
||||
}
|
||||
@@ -169,8 +173,9 @@ public:
|
||||
activeTasks--;
|
||||
done++;
|
||||
busyKernels -= task->getKernels();
|
||||
#if DEB
|
||||
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
|
||||
|
||||
#endif
|
||||
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
|
||||
task->copyResults(pathRes);
|
||||
}
|
||||
@@ -180,8 +185,19 @@ public:
|
||||
for (auto& del : toDel)
|
||||
activeTaskSet.erase(del);
|
||||
|
||||
if (oldActiveTasks != activeTasks)
|
||||
printf("done %ld / %ld\n", done, this->getLength());
|
||||
if (oldActiveTasks != activeTasks) {
|
||||
#if DEB
|
||||
printf("done %ld / %d\n", done, this->getLength());
|
||||
#endif
|
||||
if ((done % step) == 0) {
|
||||
size_t persentDone = (done / total) * 100.0;
|
||||
FILE *f = fopen("progress", "w");
|
||||
if (f) {
|
||||
fprintf(f, "%lld\n", persentDone);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeState();
|
||||
|
||||
Reference in New Issue
Block a user