From 2a9ebddad59116151e6db2a0bc8cdbf53dd5741c Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Sun, 3 Dec 2017 19:45:15 +0100 Subject: [PATCH] Hadrons: scheduler offline, minimal code working again --- extras/Hadrons/Application.cc | 93 ++++++++++--------- extras/Hadrons/Module.hpp | 4 +- extras/Hadrons/Modules/MContraction/Meson.hpp | 4 +- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/extras/Hadrons/Application.cc b/extras/Hadrons/Application.cc index 0a7d0290..0860437b 100644 --- a/extras/Hadrons/Application.cc +++ b/extras/Hadrons/Application.cc @@ -182,7 +182,7 @@ GeneticScheduler::ObjFunc memPeak = \ memPeak = env().executeProgram(program);\ env().dryRun(false);\ env().freeAll();\ - HadronsLogMessage.Active(true);\ + HadronsLogMessage.Active(msg);\ \ return memPeak;\ } @@ -199,58 +199,59 @@ void Application::schedule(void) auto con = graph.getConnectedComponents(); // constrained topological sort using a genetic algorithm - LOG(Message) << "Scheduling computation..." << std::endl; - LOG(Message) << " #module= " << graph.size() << std::endl; - LOG(Message) << " population size= " << par_.genetic.popSize << std::endl; - LOG(Message) << " max. generation= " << par_.genetic.maxGen << std::endl; - LOG(Message) << " max. cst. generation= " << par_.genetic.maxCstGen << std::endl; - LOG(Message) << " mutation rate= " << par_.genetic.mutationRate << std::endl; + // LOG(Message) << "Scheduling computation..." << std::endl; + // LOG(Message) << " #module= " << graph.size() << std::endl; + // LOG(Message) << " population size= " << par_.genetic.popSize << std::endl; + // LOG(Message) << " max. generation= " << par_.genetic.maxGen << std::endl; + // LOG(Message) << " max. cst. generation= " << par_.genetic.maxCstGen << std::endl; + // LOG(Message) << " mutation rate= " << par_.genetic.mutationRate << std::endl; - unsigned int k = 0, gen, prevPeak, nCstPeak = 0; - std::random_device rd; - GeneticScheduler::Parameters par; + // unsigned int k = 0, gen, prevPeak, nCstPeak = 0; + // std::random_device rd; + // GeneticScheduler::Parameters par; - par.popSize = par_.genetic.popSize; - par.mutationRate = par_.genetic.mutationRate; - par.seed = rd(); - memPeak_ = 0; - CartesianCommunicator::BroadcastWorld(0, &(par.seed), sizeof(par.seed)); + // par.popSize = par_.genetic.popSize; + // par.mutationRate = par_.genetic.mutationRate; + // par.seed = rd(); + // memPeak_ = 0; + // CartesianCommunicator::BroadcastWorld(0, &(par.seed), sizeof(par.seed)); for (unsigned int i = 0; i < con.size(); ++i) { - GeneticScheduler scheduler(con[i], memPeak, par); + // GeneticScheduler scheduler(con[i], memPeak, par); - gen = 0; - do - { - LOG(Debug) << "Generation " << gen << ":" << std::endl; - scheduler.nextGeneration(); - if (gen != 0) - { - if (prevPeak == scheduler.getMinValue()) - { - nCstPeak++; - } - else - { - nCstPeak = 0; - } - } + // gen = 0; + // do + // { + // LOG(Debug) << "Generation " << gen << ":" << std::endl; + // scheduler.nextGeneration(); + // if (gen != 0) + // { + // if (prevPeak == scheduler.getMinValue()) + // { + // nCstPeak++; + // } + // else + // { + // nCstPeak = 0; + // } + // } - prevPeak = scheduler.getMinValue(); - if (gen % 10 == 0) - { - LOG(Iterative) << "Generation " << gen << ": " - << MEM_MSG(scheduler.getMinValue()) << std::endl; - } + // prevPeak = scheduler.getMinValue(); + // if (gen % 10 == 0) + // { + // LOG(Iterative) << "Generation " << gen << ": " + // << MEM_MSG(scheduler.getMinValue()) << std::endl; + // } - gen++; - } while ((gen < par_.genetic.maxGen) - and (nCstPeak < par_.genetic.maxCstGen)); - auto &t = scheduler.getMinSchedule(); - if (scheduler.getMinValue() > memPeak_) - { - memPeak_ = scheduler.getMinValue(); - } + // gen++; + // } while ((gen < par_.genetic.maxGen) + // and (nCstPeak < par_.genetic.maxCstGen)); + // auto &t = scheduler.getMinSchedule(); + // if (scheduler.getMinValue() > memPeak_) + // { + // memPeak_ = scheduler.getMinValue(); + // } + auto t = con[i].topoSort(); for (unsigned int j = 0; j < t.size(); ++j) { program_.push_back(t[j]); diff --git a/extras/Hadrons/Module.hpp b/extras/Hadrons/Module.hpp index a0b062df..a9525029 100644 --- a/extras/Hadrons/Module.hpp +++ b/extras/Hadrons/Module.hpp @@ -95,8 +95,8 @@ static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance; #define envGetTmp(type, name)\ *env().template getObject(getName() + "_tmp_" + name) -#define envIsType(type, name)\ -env().template getObject(name) +#define envHasType(type, name)\ +env().template isObjectOfType(name) #define envCreate(type, name, Ls, pt)\ env().template createObject(name, Environment::Storage::object, Ls, pt) diff --git a/extras/Hadrons/Modules/MContraction/Meson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp index ccc6dc55..34127da3 100644 --- a/extras/Hadrons/Modules/MContraction/Meson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -179,8 +179,8 @@ void TMeson::execute(void) result[i].gamma_src = gammaList[i].second; result[i].corr.resize(nt); } - if (envIsType(SlicedPropagator1, par().q1) and - envIsType(SlicedPropagator2, par().q2)) + if (envHasType(SlicedPropagator1, par().q1) and + envHasType(SlicedPropagator2, par().q2)) { SlicedPropagator1 &q1 = envGet(SlicedPropagator1, par().q1); SlicedPropagator2 &q2 = envGet(SlicedPropagator2, par().q2);