27 #ifndef SCHNEK_DEPENDENCIES_HPP_ 28 #define SCHNEK_DEPENDENCIES_HPP_ 30 #include "variables.hpp" 31 #include "blockparameters.hpp" 33 #pragma GCC diagnostic push 34 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 36 #include <boost/variant.hpp> 38 #pragma GCC diagnostic pop 47 class DependencyUpdater;
56 typedef std::set<long> DependencySet;
60 DependencySet dependsOn;
61 DependencySet modifies;
64 VarInfo(pVariable v_, DependencySet dependsOn_, DependencySet modifies_)
65 : v(v_), dependsOn(dependsOn_), modifies(modifies_), counter(0) {
70 typedef std::map<long, VarInfo> DepMap;
73 typedef std::map<long, VarInfo*> RefDepMap;
74 typedef std::shared_ptr<RefDepMap> pRefDepMap;
76 typedef std::set<pVariable> VariableSet;
77 typedef std::list<pVariable> VariableList;
80 pBlockVariables blockVars;
86 void constructMapRecursive(
const pBlockVariables vars);
87 void constructMap(
const pBlockVariables vars);
90 void makeUpdateList(
const VariableSet &independentVars,
const VariableSet &dependentVars, VariableList &updateList);
91 pRefDepMap makeUpdatePredecessors(
const VariableSet &independentVars,
const VariableSet &dependentVars);
92 pRefDepMap makeUpdateFollowers(
const VariableSet &independentVars, pRefDepMap reverseDeps);
93 void makeUpdateOrder(pRefDepMap deps, VariableList &updateList);
97 void recreate() { constructMap(blockVars); }
98 pBlockVariables getBlockVariables();
104 typedef std::shared_ptr<DependencyMap> pDependencyMap;
109 typedef std::set<pParameter> ParameterSet;
110 typedef std::set<pVariable> VariableSet;
111 typedef std::list<pVariable> VariableList;
113 VariableList updateList;
114 VariableSet independentVars;
115 VariableSet dependentVars;
116 ParameterSet dependentParameters;
118 pDependencyMap dependencies;
122 void addIndependent(pParameter v);
123 void addDependent(pParameter v);
124 void clearDependent();
126 template<
size_t rank,
template<
size_t>
class CheckingPolicy>
128 {
for (
size_t i=0; i<rank; ++i) addIndependent(v[i]); }
130 template<
size_t rank,
template<
size_t>
class CheckingPolicy>
132 {
for (
size_t i=0; i<rank; ++i) addDependent(v[i]); }
141 dependencies->makeUpdateList(independentVars, dependentVars, updateList);
144 for(pVariable v: updateList) v->evaluateExpression();
145 for(pParameter p: dependentParameters) p->update();
149 typedef std::shared_ptr<DependencyUpdater> pDependencyUpdater;
154 #endif // SCHNEK_DEPENDENCIES_HPP_ Definition: dependencies.hpp:53
void update()
Definition: dependencies.hpp:138
Definition: dependencies.hpp:106