Merge pull request 'planner' (#5) from planner into main
Reviewed-on: http://alex-freenas.ddns.net:3000/M/VisualSapfor/pulls/5
This commit was merged in pull request #5.
This commit is contained in:
@@ -10,12 +10,13 @@ public:
|
||||
void setTestId(String* test_id_in) {
|
||||
test_id = String(test_id_in->getCharArray());
|
||||
}
|
||||
|
||||
void setMakefileText(String* makefile_text_in) {
|
||||
makefile_text = String(makefile_text_in->getCharArray(), '|');
|
||||
}
|
||||
|
||||
virtual void print() const {
|
||||
printf("id=%ld; maxtime=%d; test_id=%s\n", id, maxtime,
|
||||
test_id.getCharArray());
|
||||
printf("id=%ld; maxtime=%d; test_id=%s\n", id, maxtime, test_id.getCharArray());
|
||||
printf("makefile_text=%s\n", makefile_text.getCharArray());
|
||||
}
|
||||
|
||||
|
||||
@@ -105,30 +105,41 @@ int main(int argc, char ** argv)
|
||||
chdir(packageWorkspace.getCharArray());
|
||||
#endif
|
||||
|
||||
#if DEB
|
||||
userWorkspace.println();
|
||||
packageWorkspace.println();
|
||||
printf("%d\n", maxKernels);
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
int pid = getpid();
|
||||
#else
|
||||
int pid = _getpid();
|
||||
#endif
|
||||
|
||||
#if DEB
|
||||
printf("PID=%d\n", pid);
|
||||
#endif
|
||||
File pidFile("PID", String(pid)+"\n");
|
||||
pidFile.Close();
|
||||
//---
|
||||
File startFile("STARTED", "+");
|
||||
startFile.Close();
|
||||
//---
|
||||
#if DEB
|
||||
printf(">>>>\n");
|
||||
#endif
|
||||
CompilationSupervisor * compilationSupervisor = new CompilationSupervisor();
|
||||
#if DEB
|
||||
printf("%ld\n", compilationSupervisor->getLength());
|
||||
#endif
|
||||
compilationSupervisor->DoWithSchedule(maxKernels);
|
||||
|
||||
RunSupervisor * runSupervisor = new RunSupervisor(compilationSupervisor);
|
||||
#if DEB
|
||||
printf("%ld\n", runSupervisor->getLength());
|
||||
runSupervisor->print();
|
||||
#endif
|
||||
runSupervisor->DoWithSchedule(maxKernels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,9 @@ public:
|
||||
CompilationTask* parent = compilationSupervisor->getTaskById(task->getTestCompilationTaskId());
|
||||
task->setState((parent->getState() == Done) ? Waiting : Canceled);
|
||||
task->setParent(parent);
|
||||
printf("id=%ld; parent_id = %ld; state=%s\n",
|
||||
task->getId(),
|
||||
task->getParent()->getId(),
|
||||
task->printState().getCharArray());
|
||||
#if DEB
|
||||
printf("id=%ld; parent_id = %ld; state=%s\n", task->getId(), task->getParent()->getId(), task->printState().getCharArray());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
return String::DQuotes(starterCall) + " " +
|
||||
String::DQuotes(launcherCall) + " " +
|
||||
String(maxtime) + " " +
|
||||
String::DQuotes("killall -SIGKILL " + binary_name) + " " +
|
||||
String::DQuotes("killall -SIGKILL " + binary_name + " 1>/dev/null 2>/dev/null") + " " +
|
||||
dvm_start;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,9 @@ public:
|
||||
String res = workspace + "/run";
|
||||
if (!environments.isEmpty())
|
||||
res = environments + " " + res;
|
||||
#if DEB
|
||||
printf("START %ld: %s\n", id, res.getCharArray());
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ public:
|
||||
String res = String(this->getCharArray());
|
||||
for (auto i = 0; i < getLength(); ++i)
|
||||
res.body[i] = toupper(body[i]);
|
||||
#if DEB
|
||||
res.println();
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -104,9 +104,8 @@ public:
|
||||
}
|
||||
|
||||
map<int, queue<T*>, std::greater<int>> sortedByKernelNeeds;
|
||||
size_t activeTasks = 0;
|
||||
|
||||
long activeTasks = 0;
|
||||
long done = 0;
|
||||
for (auto& task : this->getElements()) {
|
||||
if (task->getState() == WorkspaceReady) {
|
||||
activeTasks++;
|
||||
@@ -127,6 +126,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;
|
||||
emptyKeys.clear();
|
||||
@@ -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();
|
||||
|
||||
@@ -168,7 +168,9 @@ public:
|
||||
std::chrono::duration<double> diff_time = end_time - start_time;
|
||||
|
||||
if (maxtime * 1.1 < diff_time.count()) {
|
||||
#if DEB
|
||||
printf("SET STATUS ABORTED by timer to %ld with time %f sec / %f sec", id, diff_time.count(), maxtime * 1.1);
|
||||
#endif
|
||||
state = AbortedByTimeout;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +186,9 @@ public:
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
std::chrono::duration<double> diff_time = end_time - start_time;
|
||||
total_time = diff_time.count();
|
||||
#if DEB
|
||||
printf("%ld done with time %f\n", id, total_time);
|
||||
#endif
|
||||
state = Finished;
|
||||
}
|
||||
virtual String copyResults(const String& pathRes) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
#else
|
||||
String command = "chmod 777 " + String::DQuotes(path);
|
||||
int i=system(command.getCharArray());
|
||||
printf("chmod 777 '%s' return code = %d\n", path.getCharArray(), i);
|
||||
//printf("chmod 777 '%s' return code = %d\n", path.getCharArray(), i);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
#else
|
||||
String command = "cp " + String::DQuotes(src) + " " + String::DQuotes(dst);
|
||||
int i = system(command.getCharArray());
|
||||
printf("cp '%s' return code = %d\n",src.getCharArray(), i);
|
||||
//printf("cp '%s' return code = %d\n",src.getCharArray(), i);
|
||||
#endif
|
||||
}
|
||||
static void CopyDirectory(const String& src, const String& dst) {
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
#else
|
||||
String command = "cp -r " + String::DQuotes(src + "/.") + " " + String::DQuotes(dst);
|
||||
int i = system(command.getCharArray());
|
||||
printf("cp -r '%s' return code = %d\n",src.getCharArray(),i);
|
||||
//printf("cp -r '%s' return code = %d\n",src.getCharArray(),i);
|
||||
#endif
|
||||
}
|
||||
static time_t getAbsoluteTime() {
|
||||
|
||||
1
src/files/Planner/version.h
Normal file
1
src/files/Planner/version.h
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
Reference in New Issue
Block a user