diff --git a/src/files/Planner/CompilationTask.h b/src/files/Planner/CompilationTask.h index 588eb909..18bb6688 100644 --- a/src/files/Planner/CompilationTask.h +++ b/src/files/Planner/CompilationTask.h @@ -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()); } diff --git a/src/files/Planner/Planner.cpp b/src/files/Planner/Planner.cpp index a00e9ae0..1f59b362 100644 --- a/src/files/Planner/Planner.cpp +++ b/src/files/Planner/Planner.cpp @@ -17,7 +17,7 @@ void hdl(int sig) { String file_name = "GOT_SIGNAL_AT_"+ String(Utils::getAbsoluteTime()); FILE * res = fopen(file_name.getCharArray(),"w"); - fprintf(res,"%d\n", sig); + fprintf(res, "%d\n", sig); fclose(res); } void set_handlers() { @@ -105,30 +105,41 @@ int main(int argc, char ** argv) chdir(packageWorkspace.getCharArray()); #endif - userWorkspace.println(); - packageWorkspace.println(); +#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"); - CompilationSupervisor * compilationSupervisor = new CompilationSupervisor(); +#endif + CompilationSupervisor * compilationSupervisor = new CompilationSupervisor(); +#if DEB printf("%ld\n", compilationSupervisor->getLength()); +#endif compilationSupervisor->DoWithSchedule(maxKernels); RunSupervisor * runSupervisor = new RunSupervisor(compilationSupervisor); - printf("%ld\n", runSupervisor->getLength()); - runSupervisor->print(); +#if DEB + printf("%ld\n", runSupervisor->getLength()); + runSupervisor->print(); +#endif runSupervisor->DoWithSchedule(maxKernels); return 0; } diff --git a/src/files/Planner/RunSupervisor.h b/src/files/Planner/RunSupervisor.h index c3fdfd7c..de165d63 100644 --- a/src/files/Planner/RunSupervisor.h +++ b/src/files/Planner/RunSupervisor.h @@ -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 } } diff --git a/src/files/Planner/RunTask.h b/src/files/Planner/RunTask.h index 8f8da661..52538819 100644 --- a/src/files/Planner/RunTask.h +++ b/src/files/Planner/RunTask.h @@ -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; } diff --git a/src/files/Planner/String.h b/src/files/Planner/String.h index f4844d99..2df6ee26 100644 --- a/src/files/Planner/String.h +++ b/src/files/Planner/String.h @@ -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; } }; diff --git a/src/files/Planner/Supervisor.h b/src/files/Planner/Supervisor.h index c7f3aea1..09766cf3 100644 --- a/src/files/Planner/Supervisor.h +++ b/src/files/Planner/Supervisor.h @@ -104,9 +104,8 @@ public: } map, std::greater> 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 emptyKeys; vector 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(); diff --git a/src/files/Planner/Task.h b/src/files/Planner/Task.h index d5d124c0..3ec919ef 100644 --- a/src/files/Planner/Task.h +++ b/src/files/Planner/Task.h @@ -168,7 +168,9 @@ public: std::chrono::duration 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 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) { diff --git a/src/files/Planner/Utils.h b/src/files/Planner/Utils.h index 6d6f864e..b5633dcb 100644 --- a/src/files/Planner/Utils.h +++ b/src/files/Planner/Utils.h @@ -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() { diff --git a/src/files/Planner/version.h b/src/files/Planner/version.h new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/src/files/Planner/version.h @@ -0,0 +1 @@ +1 \ No newline at end of file