From 9b3701ae27d26fafd0c6ee3c7820e8ff3d2df714 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Fri, 24 May 2019 13:08:20 +0100 Subject: [PATCH] posibility to save/load schedules directly from the application parameters --- Hadrons/Application.cc | 17 ++++++++++++++++- Hadrons/Application.hpp | 2 ++ Hadrons/Utilities/HadronsXmlRun.cc | 15 ++------------- Hadrons/VirtualMachine.cc | 9 ++++----- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Hadrons/Application.cc b/Hadrons/Application.cc index d3da1b54..e4264f84 100644 --- a/Hadrons/Application.cc +++ b/Hadrons/Application.cc @@ -118,7 +118,22 @@ void Application::run(void) vm().setRunId(getPar().runId); vm().printContent(); env().printContent(); - schedule(); + if (getPar().saveSchedule or getPar().scheduleFile.empty()) + { + schedule(); + if (getPar().saveSchedule) + { + std::string filename; + + filename = (getPar().scheduleFile.empty()) ? + "hadrons.sched" : getPar().scheduleFile; + saveSchedule(filename); + } + } + else + { + loadSchedule(getPar().scheduleFile); + } printSchedule(); if (!getPar().graphFile.empty()) { diff --git a/Hadrons/Application.hpp b/Hadrons/Application.hpp index 36903e88..36179c5f 100644 --- a/Hadrons/Application.hpp +++ b/Hadrons/Application.hpp @@ -57,6 +57,8 @@ public: VirtualMachine::GeneticPar, genetic, std::string, runId, std::string, graphFile, + std::string, scheduleFile, + bool, saveSchedule, int, parallelWriteMaxRetry); GlobalPar(void): parallelWriteMaxRetry{-1} {} }; diff --git a/Hadrons/Utilities/HadronsXmlRun.cc b/Hadrons/Utilities/HadronsXmlRun.cc index a69de7d7..d13dbfe6 100644 --- a/Hadrons/Utilities/HadronsXmlRun.cc +++ b/Hadrons/Utilities/HadronsXmlRun.cc @@ -35,22 +35,15 @@ using namespace Hadrons; int main(int argc, char *argv[]) { // parse command line - std::string parameterFileName, scheduleFileName = ""; + std::string parameterFileName; if (argc < 2) { - std::cerr << "usage: " << argv[0] << " [] [Grid options]"; + std::cerr << "usage: " << argv[0] << " [Grid options]"; std::cerr << std::endl; std::exit(EXIT_FAILURE); } parameterFileName = argv[1]; - if (argc > 2) - { - if (argv[2][0] != '-') - { - scheduleFileName = argv[2]; - } - } // initialization Grid_init(&argc, &argv); @@ -61,10 +54,6 @@ int main(int argc, char *argv[]) Application application(parameterFileName); application.parseParameterFile(parameterFileName); - if (!scheduleFileName.empty()) - { - application.loadSchedule(scheduleFileName); - } application.run(); } catch (const std::exception& e) diff --git a/Hadrons/VirtualMachine.cc b/Hadrons/VirtualMachine.cc index 0d2e7de2..8a44ba69 100644 --- a/Hadrons/VirtualMachine.cc +++ b/Hadrons/VirtualMachine.cc @@ -601,11 +601,10 @@ VirtualMachine::Program VirtualMachine::schedule(const GeneticPar &par) Scheduler scheduler(graph, memPeak, gpar); gen = 0; scheduler.initPopulation(); - LOG(Iterative) << "Start: " << sizeString(scheduler.getMinValue()) - << std::endl; + LOG(Message) << "Start: " << sizeString(scheduler.getMinValue()) + << std::endl; do { - //LOG(Debug) << "Generation " << gen << ":" << std::endl; scheduler.nextGeneration(); if (gen != 0) { @@ -622,8 +621,8 @@ VirtualMachine::Program VirtualMachine::schedule(const GeneticPar &par) prevPeak = scheduler.getMinValue(); if (gen % 10 == 0) { - LOG(Iterative) << "Generation " << gen << ": " - << sizeString(scheduler.getMinValue()) << std::endl; + LOG(Message) << "Generation " << gen << ": " + << sizeString(scheduler.getMinValue()) << std::endl; } gen++;