26 #ifndef DOXYGEN_SHOULD_SKIP_THIS 34 template <
typename GUM_SCALAR >
41 template <
typename GUM_SCALAR >
43 const SchedulerBasic< GUM_SCALAR >& from) :
50 template <
typename GUM_SCALAR >
57 template <
typename GUM_SCALAR >
59 return new SchedulerBasic< GUM_SCALAR >(*this);
63 template <
typename GUM_SCALAR >
65 const NodeSet& available = schedule.availableOperations();
67 while (!available.empty()) {
69 iter != available.endSafe();
71 schedule.execute(*iter);
75 return (schedule.scheduling_dag().size() == 0);
79 template <
typename GUM_SCALAR >
82 const NodeSet& available = schedule.availableOperations();
84 while (!available.empty() && k) {
86 iter != available.endSafe() && k;
88 schedule.execute(*iter);
92 return !k || (schedule.scheduling_dag().size() == 0);
97 template <
typename GUM_SCALAR >
99 const Schedule< GUM_SCALAR >& schedule)
const {
100 NodeSet available = schedule.availableOperations();
101 DAG dag = schedule.scheduling_dag();
102 float nb_operations = 0;
104 while (!available.empty()) {
106 iter != available.endSafe();
109 nb_operations += schedule.nbOperations(
id);
110 const NodeSet& children = dag.children(
id);
113 children.beginSafe();
114 iter_children != children.endSafe();
116 if (dag.parents(*iter_children).size() == 1) {
117 available.
insert(*iter_children);
122 available.erase(iter);
126 return nb_operations;
131 template <
typename GUM_SCALAR >
133 const Schedule< GUM_SCALAR >& schedule,
Size k)
const {
134 NodeSet available = schedule.availableOperations();
135 DAG dag = schedule.scheduling_dag();
136 float nb_operations = 0;
138 while (!available.empty() && k) {
140 iter != available.endSafe() && k;
143 nb_operations += schedule.nbOperations(
id);
144 const NodeSet& children = dag.children(
id);
147 children.beginSafe();
148 iter_children != children.endSafe();
150 if (dag.parents(*iter_children).size() == 1) {
151 available.
insert(*iter_children);
156 available.erase(iter);
160 return nb_operations;
164 template <
typename GUM_SCALAR >
166 const Schedule< GUM_SCALAR >& schedule)
const {
167 NodeSet available = schedule.availableOperations();
168 DAG dag = schedule.scheduling_dag();
170 long current_memory = 0;
172 while (!available.empty()) {
174 iter != available.endSafe();
178 std::pair< long, long > mem_op = schedule.memoryUsage(
id);
180 if ((std::numeric_limits< long >::max() - current_memory < mem_op.first)
181 || (std::numeric_limits< long >::max() - current_memory
183 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
186 if (current_memory + mem_op.first > max_memory)
187 max_memory = current_memory + mem_op.first;
189 current_memory += mem_op.second;
191 const NodeSet& children = dag.children(
id);
194 children.beginSafe();
195 iter_children != children.endSafe();
197 if (dag.parents(*iter_children).size() == 1) {
198 available.
insert(*iter_children);
203 available.erase(iter);
207 return std::pair< long, long >(max_memory, current_memory);
212 template <
typename GUM_SCALAR >
214 const Schedule< GUM_SCALAR >& schedule,
Size k)
const {
215 NodeSet available = schedule.availableOperations();
216 DAG dag = schedule.scheduling_dag();
218 long current_memory = 0;
220 while (!available.empty() && k) {
222 iter != available.endSafe() && k;
226 std::pair< long, long > mem_op = schedule.memoryUsage(
id);
228 if ((std::numeric_limits< long >::max() - current_memory < mem_op.first)
229 || (std::numeric_limits< long >::max() - current_memory
231 GUM_ERROR(OutOfBounds,
"memory usage out of long int range");
234 if (current_memory + mem_op.first > max_memory)
235 max_memory = current_memory + mem_op.first;
237 current_memory += mem_op.second;
239 const NodeSet& children = dag.children(
id);
242 children.beginSafe();
243 iter_children != children.endSafe();
245 if (dag.parents(*iter_children).size() == 1) {
246 available.
insert(*iter_children);
251 available.erase(iter);
255 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
gum is the global namespace for all aGrUM entities
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)