1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Hadrons: exposing scheduler settings

This commit is contained in:
Antonin Portelli 2016-12-06 12:12:05 +09:00
parent a683a0f55a
commit 646b11f5c2
2 changed files with 18 additions and 4 deletions

View File

@ -76,6 +76,7 @@ Application::Application(const std::string parameterFileName)
void Application::setPar(const Application::GlobalPar &par) void Application::setPar(const Application::GlobalPar &par)
{ {
par_ = par; par_ = par;
LOG(Message) << par_.seed << std::endl;
env_.setSeed(strToVec<int>(par_.seed)); env_.setSeed(strToVec<int>(par_.seed));
} }
@ -144,15 +145,14 @@ void Application::schedule(void)
// constrained topological sort using a genetic algorithm // constrained topological sort using a genetic algorithm
LOG(Message) << "Scheduling computation..." << std::endl; LOG(Message) << "Scheduling computation..." << std::endl;
constexpr unsigned int maxGen = 200, maxCstGen = 50;
unsigned int k = 0, gen, prevPeak, nCstPeak = 0; unsigned int k = 0, gen, prevPeak, nCstPeak = 0;
auto graph = env_.makeModuleGraph(); auto graph = env_.makeModuleGraph();
auto con = graph.getConnectedComponents(); auto con = graph.getConnectedComponents();
std::random_device rd; std::random_device rd;
GeneticScheduler<unsigned int>::Parameters par; GeneticScheduler<unsigned int>::Parameters par;
par.popSize = 10; par.popSize = par_.genetic.popSize;
par.mutationRate = .1; par.mutationRate = par_.genetic.mutationRate;
par.seed = rd(); par.seed = rd();
CartesianCommunicator::BroadcastWorld(0, &(par.seed), sizeof(par.seed)); CartesianCommunicator::BroadcastWorld(0, &(par.seed), sizeof(par.seed));
for (unsigned int i = 0; i < con.size(); ++i) for (unsigned int i = 0; i < con.size(); ++i)
@ -182,7 +182,8 @@ void Application::schedule(void)
<< MEM_MSG(scheduler.getMinValue()) << std::endl; << MEM_MSG(scheduler.getMinValue()) << std::endl;
} }
gen++; gen++;
} while ((gen < maxGen) and (nCstPeak < maxCstGen)); } while ((gen < par_.genetic.maxGen)
and (nCstPeak < par_.genetic.maxCstGen));
auto &t = scheduler.getMinSchedule(); auto &t = scheduler.getMinSchedule();
LOG(Message) << "Program " << i + 1 << " (memory peak: " LOG(Message) << "Program " << i + 1 << " (memory peak: "
<< MEM_MSG(scheduler.getMinValue()) << "):" << std::endl; << MEM_MSG(scheduler.getMinValue()) << "):" << std::endl;

View File

@ -49,11 +49,24 @@ public:
unsigned int, end, unsigned int, end,
unsigned int, step); unsigned int, step);
}; };
class GeneticPar: Serializable
{
public:
GeneticPar(void):
popSize{20}, maxGen{1000}, maxCstGen{100}, mutationRate{.1} {};
public:
GRID_SERIALIZABLE_CLASS_MEMBERS(GeneticPar,
unsigned int, popSize,
unsigned int, maxGen,
unsigned int, maxCstGen,
double , mutationRate);
};
class GlobalPar: Serializable class GlobalPar: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(GlobalPar, GRID_SERIALIZABLE_CLASS_MEMBERS(GlobalPar,
TrajRange, trajCounter, TrajRange, trajCounter,
GeneticPar, genetic,
std::string, seed); std::string, seed);
}; };
public: public: