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

Hadrons: scheduler offline, minimal code working again

This commit is contained in:
Antonin Portelli 2017-12-03 19:45:15 +01:00
parent ff7afe6e17
commit 2a9ebddad5
3 changed files with 51 additions and 50 deletions

View File

@ -182,7 +182,7 @@ GeneticScheduler<unsigned int>::ObjFunc memPeak = \
memPeak = env().executeProgram(program);\ memPeak = env().executeProgram(program);\
env().dryRun(false);\ env().dryRun(false);\
env().freeAll();\ env().freeAll();\
HadronsLogMessage.Active(true);\ HadronsLogMessage.Active(msg);\
\ \
return memPeak;\ return memPeak;\
} }
@ -199,58 +199,59 @@ void Application::schedule(void)
auto con = graph.getConnectedComponents(); auto con = graph.getConnectedComponents();
// 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;
LOG(Message) << " #module= " << graph.size() << std::endl; // LOG(Message) << " #module= " << graph.size() << std::endl;
LOG(Message) << " population size= " << par_.genetic.popSize << std::endl; // LOG(Message) << " population size= " << par_.genetic.popSize << std::endl;
LOG(Message) << " max. generation= " << par_.genetic.maxGen << std::endl; // LOG(Message) << " max. generation= " << par_.genetic.maxGen << std::endl;
LOG(Message) << " max. cst. generation= " << par_.genetic.maxCstGen << std::endl; // LOG(Message) << " max. cst. generation= " << par_.genetic.maxCstGen << std::endl;
LOG(Message) << " mutation rate= " << par_.genetic.mutationRate << std::endl; // LOG(Message) << " mutation rate= " << par_.genetic.mutationRate << std::endl;
unsigned int k = 0, gen, prevPeak, nCstPeak = 0; // unsigned int k = 0, gen, prevPeak, nCstPeak = 0;
std::random_device rd; // std::random_device rd;
GeneticScheduler<unsigned int>::Parameters par; // GeneticScheduler<unsigned int>::Parameters par;
par.popSize = par_.genetic.popSize; // par.popSize = par_.genetic.popSize;
par.mutationRate = par_.genetic.mutationRate; // par.mutationRate = par_.genetic.mutationRate;
par.seed = rd(); // par.seed = rd();
memPeak_ = 0; // memPeak_ = 0;
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)
{ {
GeneticScheduler<unsigned int> scheduler(con[i], memPeak, par); // GeneticScheduler<unsigned int> scheduler(con[i], memPeak, par);
gen = 0; // gen = 0;
do // do
{ // {
LOG(Debug) << "Generation " << gen << ":" << std::endl; // LOG(Debug) << "Generation " << gen << ":" << std::endl;
scheduler.nextGeneration(); // scheduler.nextGeneration();
if (gen != 0) // if (gen != 0)
{ // {
if (prevPeak == scheduler.getMinValue()) // if (prevPeak == scheduler.getMinValue())
{ // {
nCstPeak++; // nCstPeak++;
} // }
else // else
{ // {
nCstPeak = 0; // nCstPeak = 0;
} // }
} // }
prevPeak = scheduler.getMinValue(); // prevPeak = scheduler.getMinValue();
if (gen % 10 == 0) // if (gen % 10 == 0)
{ // {
LOG(Iterative) << "Generation " << gen << ": " // LOG(Iterative) << "Generation " << gen << ": "
<< MEM_MSG(scheduler.getMinValue()) << std::endl; // << MEM_MSG(scheduler.getMinValue()) << std::endl;
} // }
gen++; // gen++;
} while ((gen < par_.genetic.maxGen) // } while ((gen < par_.genetic.maxGen)
and (nCstPeak < par_.genetic.maxCstGen)); // and (nCstPeak < par_.genetic.maxCstGen));
auto &t = scheduler.getMinSchedule(); // auto &t = scheduler.getMinSchedule();
if (scheduler.getMinValue() > memPeak_) // if (scheduler.getMinValue() > memPeak_)
{ // {
memPeak_ = scheduler.getMinValue(); // memPeak_ = scheduler.getMinValue();
} // }
auto t = con[i].topoSort();
for (unsigned int j = 0; j < t.size(); ++j) for (unsigned int j = 0; j < t.size(); ++j)
{ {
program_.push_back(t[j]); program_.push_back(t[j]);

View File

@ -95,8 +95,8 @@ static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance;
#define envGetTmp(type, name)\ #define envGetTmp(type, name)\
*env().template getObject<type>(getName() + "_tmp_" + name) *env().template getObject<type>(getName() + "_tmp_" + name)
#define envIsType(type, name)\ #define envHasType(type, name)\
env().template getObject<type>(name) env().template isObjectOfType<type>(name)
#define envCreate(type, name, Ls, pt)\ #define envCreate(type, name, Ls, pt)\
env().template createObject<type>(name, Environment::Storage::object, Ls, pt) env().template createObject<type>(name, Environment::Storage::object, Ls, pt)

View File

@ -179,8 +179,8 @@ void TMeson<FImpl1, FImpl2>::execute(void)
result[i].gamma_src = gammaList[i].second; result[i].gamma_src = gammaList[i].second;
result[i].corr.resize(nt); result[i].corr.resize(nt);
} }
if (envIsType(SlicedPropagator1, par().q1) and if (envHasType(SlicedPropagator1, par().q1) and
envIsType(SlicedPropagator2, par().q2)) envHasType(SlicedPropagator2, par().q2))
{ {
SlicedPropagator1 &q1 = envGet(SlicedPropagator1, par().q1); SlicedPropagator1 &q1 = envGet(SlicedPropagator1, par().q1);
SlicedPropagator2 &q2 = envGet(SlicedPropagator2, par().q2); SlicedPropagator2 &q2 = envGet(SlicedPropagator2, par().q2);