29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 template <
typename GUM_SCALAR >
44 template <
typename GUM_SCALAR >
46 const SchedulerBasic< GUM_SCALAR >& from) :
53 template <
typename GUM_SCALAR >
60 template <
typename GUM_SCALAR >
62 return new SchedulerBasic< GUM_SCALAR >(*this);
66 template <
typename GUM_SCALAR >
68 const NodeSet& available = schedule.availableOperations();
70 while (!available.empty()) {
72 iter != available.endSafe();
74 schedule.execute(*iter);
78 return (schedule.scheduling_dag().size() == 0);
82 template <
typename GUM_SCALAR >
85 const NodeSet& available = schedule.availableOperations();
87 while (!available.empty() && k) {
89 iter != available.endSafe() && k;
91 schedule.execute(*iter);
95 return !k || (schedule.scheduling_dag().size() == 0);
100 template <
typename GUM_SCALAR >
102 const Schedule< GUM_SCALAR >& schedule)
const {
103 NodeSet available = schedule.availableOperations();
104 DAG dag = schedule.scheduling_dag();
105 float nb_operations = 0;
107 while (!available.empty()) {
109 iter != available.endSafe();
112 nb_operations += schedule.nbOperations(
id);
113 const NodeSet& children = dag.children(
id);
116 children.beginSafe();
117 iter_children != children.endSafe();
119 if (dag.parents(*iter_children).size() == 1) {
120 available.
insert(*iter_children);
125 available.erase(iter);
129 return nb_operations;
134 template <
typename GUM_SCALAR >
136 const Schedule< GUM_SCALAR >& schedule,
Size k)
const {
137 NodeSet available = schedule.availableOperations();
138 DAG dag = schedule.scheduling_dag();
139 float nb_operations = 0;
141 while (!available.empty() && k) {
143 iter != available.endSafe() && k;
146 nb_operations += schedule.nbOperations(
id);
147 const NodeSet& children = dag.children(
id);
150 children.beginSafe();
151 iter_children != children.endSafe();
153 if (dag.parents(*iter_children).size() == 1) {
154 available.
insert(*iter_children);
159 available.erase(iter);
163 return nb_operations;
167 template <
typename GUM_SCALAR >
169 const Schedule< GUM_SCALAR >& schedule)
const {
170 NodeSet available = schedule.availableOperations();
171 DAG dag = schedule.scheduling_dag();
173 long current_memory = 0;
175 while (!available.empty()) {
177 iter != available.endSafe();
181 std::pair< long, long > mem_op = schedule.memoryUsage(
id);
183 if ((std::numeric_limits< long >::max() - current_memory < mem_op.first)
184 || (std::numeric_limits< long >::max() - current_memory
186 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
189 if (current_memory + mem_op.first > max_memory)
190 max_memory = current_memory + mem_op.first;
192 current_memory += mem_op.second;
194 const NodeSet& children = dag.children(
id);
197 children.beginSafe();
198 iter_children != children.endSafe();
200 if (dag.parents(*iter_children).size() == 1) {
201 available.
insert(*iter_children);
206 available.erase(iter);
210 return std::pair< long, long >(max_memory, current_memory);
215 template <
typename GUM_SCALAR >
217 const Schedule< GUM_SCALAR >& schedule,
Size k)
const {
218 NodeSet available = schedule.availableOperations();
219 DAG dag = schedule.scheduling_dag();
221 long current_memory = 0;
223 while (!available.empty() && k) {
225 iter != available.endSafe() && k;
229 std::pair< long, long > mem_op = schedule.memoryUsage(
id);
231 if ((std::numeric_limits< long >::max() - current_memory < mem_op.first)
232 || (std::numeric_limits< long >::max() - current_memory
234 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
237 if (current_memory + mem_op.first > max_memory)
238 max_memory = current_memory + mem_op.first;
240 current_memory += mem_op.second;
242 const NodeSet& children = dag.children(
id);
245 children.beginSafe();
246 iter_children != children.endSafe();
248 if (dag.parents(*iter_children).size() == 1) {
249 available.
insert(*iter_children);
254 available.erase(iter);
258 return std::pair< long, long >(max_memory, current_memory);
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
std::pair< long, long > memoryUsage(const Schedule< GUM_SCALAR > &) const
returns the memory consumption used during the execution of a schedule
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
SchedulerBasic< GUM_SCALAR > * newFactory() const
virtual constructor
bool execute(Schedule< GUM_SCALAR > &)
execute all the operations of a given schedule
SetIteratorSafe< NodeId > const_iterator_safe
SchedulerBasic()
default constructor
virtual ~SchedulerBasic()
destructor
Scheduler()
default constructor
float nbOperations(const Schedule< GUM_SCALAR > &) const
returns an estimation of the number of elementary operations needed to perform a given schedule ...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.
#define GUM_ERROR(type, msg)