mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-13 01:05:36 +00:00
posibility to save/load schedules directly from the application parameters
This commit is contained in:
parent
4ac27340b9
commit
9b3701ae27
@ -118,7 +118,22 @@ void Application::run(void)
|
|||||||
vm().setRunId(getPar().runId);
|
vm().setRunId(getPar().runId);
|
||||||
vm().printContent();
|
vm().printContent();
|
||||||
env().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();
|
printSchedule();
|
||||||
if (!getPar().graphFile.empty())
|
if (!getPar().graphFile.empty())
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,8 @@ public:
|
|||||||
VirtualMachine::GeneticPar, genetic,
|
VirtualMachine::GeneticPar, genetic,
|
||||||
std::string, runId,
|
std::string, runId,
|
||||||
std::string, graphFile,
|
std::string, graphFile,
|
||||||
|
std::string, scheduleFile,
|
||||||
|
bool, saveSchedule,
|
||||||
int, parallelWriteMaxRetry);
|
int, parallelWriteMaxRetry);
|
||||||
GlobalPar(void): parallelWriteMaxRetry{-1} {}
|
GlobalPar(void): parallelWriteMaxRetry{-1} {}
|
||||||
};
|
};
|
||||||
|
@ -35,22 +35,15 @@ using namespace Hadrons;
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// parse command line
|
// parse command line
|
||||||
std::string parameterFileName, scheduleFileName = "";
|
std::string parameterFileName;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
std::cerr << "usage: " << argv[0] << " <parameter file> [<precomputed schedule>] [Grid options]";
|
std::cerr << "usage: " << argv[0] << " <parameter file> [Grid options]";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
parameterFileName = argv[1];
|
parameterFileName = argv[1];
|
||||||
if (argc > 2)
|
|
||||||
{
|
|
||||||
if (argv[2][0] != '-')
|
|
||||||
{
|
|
||||||
scheduleFileName = argv[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialization
|
// initialization
|
||||||
Grid_init(&argc, &argv);
|
Grid_init(&argc, &argv);
|
||||||
@ -61,10 +54,6 @@ int main(int argc, char *argv[])
|
|||||||
Application application(parameterFileName);
|
Application application(parameterFileName);
|
||||||
|
|
||||||
application.parseParameterFile(parameterFileName);
|
application.parseParameterFile(parameterFileName);
|
||||||
if (!scheduleFileName.empty())
|
|
||||||
{
|
|
||||||
application.loadSchedule(scheduleFileName);
|
|
||||||
}
|
|
||||||
application.run();
|
application.run();
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -601,11 +601,10 @@ VirtualMachine::Program VirtualMachine::schedule(const GeneticPar &par)
|
|||||||
Scheduler scheduler(graph, memPeak, gpar);
|
Scheduler scheduler(graph, memPeak, gpar);
|
||||||
gen = 0;
|
gen = 0;
|
||||||
scheduler.initPopulation();
|
scheduler.initPopulation();
|
||||||
LOG(Iterative) << "Start: " << sizeString(scheduler.getMinValue())
|
LOG(Message) << "Start: " << sizeString(scheduler.getMinValue())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
//LOG(Debug) << "Generation " << gen << ":" << std::endl;
|
|
||||||
scheduler.nextGeneration();
|
scheduler.nextGeneration();
|
||||||
if (gen != 0)
|
if (gen != 0)
|
||||||
{
|
{
|
||||||
@ -622,8 +621,8 @@ VirtualMachine::Program VirtualMachine::schedule(const GeneticPar &par)
|
|||||||
prevPeak = scheduler.getMinValue();
|
prevPeak = scheduler.getMinValue();
|
||||||
if (gen % 10 == 0)
|
if (gen % 10 == 0)
|
||||||
{
|
{
|
||||||
LOG(Iterative) << "Generation " << gen << ": "
|
LOG(Message) << "Generation " << gen << ": "
|
||||||
<< sizeString(scheduler.getMinValue()) << std::endl;
|
<< sizeString(scheduler.getMinValue()) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
gen++;
|
gen++;
|
||||||
|
Loading…
Reference in New Issue
Block a user