Доделал Planner. Для компиляции тоже заменил старый Do на DoWithSchedule
Добавил сохранение в архив задач на компиляцию. Закомментирова info txt который почему то в архив клался пустым, вместо него кладу в архив файлы TaskState и total_time. Адаптировал анализ под распаковку архива. При сохранении в бд, удаляю задачи на компиляцию.
This commit is contained in:
@@ -124,7 +124,7 @@ int main(int argc, char ** argv)
|
||||
printf(">>>>\n");
|
||||
CompilationSupervisor * compilationSupervisor = new CompilationSupervisor();
|
||||
printf("%ld\n", compilationSupervisor->getLength());
|
||||
compilationSupervisor->Do();
|
||||
compilationSupervisor->DoWithSchedule(maxKernels);
|
||||
|
||||
RunSupervisor * runSupervisor = new RunSupervisor(compilationSupervisor);
|
||||
printf("%ld\n", runSupervisor->getLength());
|
||||
|
||||
@@ -93,18 +93,12 @@ public:
|
||||
printf("START %ld: %s\n", id, res.getCharArray());
|
||||
return res;
|
||||
}
|
||||
|
||||
virtual void copyResults(const String& pathRes) {
|
||||
String resultPath(packageWorkspace + "/" + pathRes + "/" + getId());
|
||||
|
||||
Utils::Mkdir(resultPath);
|
||||
|
||||
Utils::Copy(workspace + "/out.txt", resultPath + "/out.txt");
|
||||
Utils::Copy(workspace + "/err.txt", resultPath + "/err.txt");
|
||||
|
||||
virtual String copyResults(const String& pathRes) {
|
||||
String resultPath = Task::copyResults(pathRes);
|
||||
if (Utils::Exists(workspace + "/sts.gz+")) {
|
||||
String dvm_start = String::DQuotes(dvm_drv) + " pa " + String::DQuotes(String(getId()) + "/sts.gz+") + " " + String::DQuotes(resultPath + "/statistic.txt");
|
||||
system(dvm_start.getCharArray());
|
||||
}
|
||||
return resultPath;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
delete packedTasks;
|
||||
delete lines;
|
||||
}
|
||||
|
||||
void changeState() {
|
||||
switch (this->state) {
|
||||
case WorkspacesCreation:
|
||||
@@ -81,60 +80,8 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Do() {
|
||||
saveState();
|
||||
long activeCount = 0;
|
||||
//todo обязательно убрать отладочную печать.
|
||||
printf("tasks count = %ld\n", this->getLength());
|
||||
while (this->state != End) {
|
||||
// printf("state=%d\n", this->state);
|
||||
// printf("max=%d; busy=%d; free=%d\n", maxKernels, busyKernels, freeKernels);
|
||||
activeCount = 0;
|
||||
for (long i = 0; i < this->getLength(); ++i) {
|
||||
T* task = this->get(i);
|
||||
switch (this->state) {
|
||||
case WorkspacesCreation:
|
||||
if (task->getState() == Waiting) {
|
||||
activeCount++;
|
||||
task->createWorkspace();
|
||||
task->setState(WorkspaceCreated);
|
||||
}
|
||||
break;
|
||||
case Preparation:
|
||||
if (task->getState() == WorkspaceCreated) {
|
||||
activeCount++;
|
||||
task->prepareWorkspace();
|
||||
task->createLaunchScript();
|
||||
task->setState(WorkspaceReady);
|
||||
}
|
||||
break;
|
||||
case Execution:
|
||||
if (task->getState() == WorkspaceReady) {
|
||||
activeCount++;
|
||||
task->Start();
|
||||
}
|
||||
else if (task->getState() == Running) {
|
||||
activeCount++;
|
||||
task->Check();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// printf("id = %ld; state = %d\n", task->getId(), task->getState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// printf("active count = %d\n", activeCount);
|
||||
if (activeCount == 0)
|
||||
changeState();
|
||||
Utils::Sleep(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DoWithSchedule(int maxKernels) {
|
||||
saveState();
|
||||
|
||||
// подготовка тестов
|
||||
while (this->state != Execution) {
|
||||
for (auto& task : this->getElements()) {
|
||||
@@ -179,7 +126,7 @@ public:
|
||||
|
||||
String pathRes("results");
|
||||
Utils::Mkdir(pathRes);
|
||||
string buf;
|
||||
//string buf;
|
||||
|
||||
while (activeTasks) {
|
||||
long oldActiveTasks = activeTasks;
|
||||
@@ -227,7 +174,7 @@ public:
|
||||
busyKernels -= task->getKernels();
|
||||
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
|
||||
|
||||
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
|
||||
//buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
|
||||
task->copyResults(pathRes);
|
||||
continue;
|
||||
}
|
||||
@@ -240,8 +187,8 @@ public:
|
||||
|
||||
changeState();
|
||||
|
||||
String outFile(pathRes + "/info.txt");
|
||||
File tmp(outFile, String(buf.c_str()));
|
||||
//String outFile(pathRes + "/info.txt");
|
||||
//File tmp(outFile, String(buf.c_str()));
|
||||
|
||||
Utils::ZipFolder(pathRes, pathRes + ".zip");
|
||||
}
|
||||
|
||||
@@ -198,5 +198,13 @@ public:
|
||||
File tmp(stateFile, printState());
|
||||
}
|
||||
|
||||
virtual void copyResults(const String& path) { }
|
||||
virtual String copyResults(const String& pathRes) {
|
||||
String resultPath(packageWorkspace + "/" + pathRes + "/" + getId());
|
||||
Utils::Mkdir(resultPath);
|
||||
Utils::Copy(workspace + "/TaskState", resultPath + "/TaskState");
|
||||
Utils::Copy(workspace + "/out.txt", resultPath + "/out.txt");
|
||||
Utils::Copy(workspace + "/err.txt", resultPath + "/err.txt");
|
||||
Utils::Copy(workspace + "/total_time", resultPath + "/total_time");
|
||||
return resultPath;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user