aGrUM  0.16.0
schedule.h
Go to the documentation of this file.
1 
28 #ifndef GUM_SCHEDULE_H
29 #define GUM_SCHEDULE_H
30 
31 #include <utility>
32 
33 #include <agrum/agrum.h>
34 
35 #include <agrum/core/hashTable.h>
36 #include <agrum/core/set.h>
37 #include <agrum/graphs/DAG.h>
39 
46 
47 namespace gum {
48 
67  template < typename GUM_SCALAR >
68  class Schedule {
69  public:
71  using OperationId = Idx;
72 
74  using MultiDimId = Idx;
75 
76  // ############################################################################
78  // ############################################################################
80 
82  Schedule();
83 
86 
88  ~Schedule();
89 
91 
92  // ############################################################################
94  // ############################################################################
95 
97 
100 
102 
103  // ############################################################################
105  // ############################################################################
107 
109 
113 
117  void forceAfter(const ScheduleOperation< GUM_SCALAR >& op_to_force,
118  const ScheduleOperation< GUM_SCALAR >& op_before);
119  void forceAfter(NodeId op_to_force, NodeId op_before);
120 
124  void
125  forceAfter(const ScheduleOperation< GUM_SCALAR >& op_to_force,
126  const Set< const ScheduleOperation< GUM_SCALAR >* >& ops_before);
127  void forceAfter(NodeId op_to_force, const NodeSet& ops_before);
128 
131  void forceBefore(const ScheduleOperation< GUM_SCALAR >& op_to_force,
132  const ScheduleOperation< GUM_SCALAR >& op_after);
133  void forceBefore(NodeId op_to_force, NodeId op_after);
134 
137  void
138  forceBefore(const ScheduleOperation< GUM_SCALAR >& op_to_force,
139  const Set< const ScheduleOperation< GUM_SCALAR >* >& ops_after);
140  void forceBefore(NodeId op_to_force, const NodeSet& ops_after);
141 
143 
145  const DAG& scheduling_dag() const;
146 
148 
151 
153 
156 
159  operations() const;
160 
162  const NodeSet&
164  const NodeSet& operationsInvolving(MultiDimId table_id) const;
165 
167 
169  const NodeSet& availableOperations() const;
170 
172 
179  void execute(NodeId);
181 
185  float nbOperations(NodeId) const;
187 
189 
198  std::pair< long, long > memoryUsage(NodeId) const;
199  std::pair< long, long > memoryUsage(ScheduleOperation< GUM_SCALAR >&) const;
200 
202 
203  private:
205 
208  mutable DAG __dag;
209 
212 
215 
219 
221 
229 
232 
235 
238  void __updateWrongParents() const;
239  };
240 
241 } /* namespace gum */
242 
243 // always include the template implementation
245 
246 #endif /* GUM_SCHEDULE_H */
NodeSet __operations_available
the set of operations that can be executed at once
Definition: schedule.h:231
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
a MultiDimImplementation Wrapper used for scheduling inferences
void execute(NodeId)
executes a given operation (if this one is available)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeProperty< ScheduleOperation< GUM_SCALAR > *> __node2operation
a hashtable assigning to each node of the DAG an operation
Definition: schedule.h:211
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DAG __dag
the DAG of the operations to perform
Definition: schedule.h:208
Idx MultiDimId
to identify correctly the ids that correspond to ScheduleMultiDim ids
Definition: schedule.h:74
NodeId nodeId(const ScheduleOperation< GUM_SCALAR > &) const
returns the id of the node corresponding to a given ScheduleOperation
NodeSet __operations_with_wrong_parents
a list of operations whose parents are not properly set
Definition: schedule.h:228
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void forceAfter(const ScheduleOperation< GUM_SCALAR > &op_to_force, const ScheduleOperation< GUM_SCALAR > &op_before)
adds a constraint indicating that an operation cannot be performed before another one ...
The class for generic Hash Tables.
Definition: hashTable.h:679
NodeId insert(const ScheduleOperation< GUM_SCALAR > &)
inserts an operation to be scheduled
const NodeSet & operationsInvolving(const ScheduleMultiDim< GUM_SCALAR > &table) const
returns the set of operations involving a given multidim table
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
const DAG & scheduling_dag() const
returns a DAG indicating in which order the operations can be performed
const NodeSet & availableOperations() const
returns the set of ScheduleOperations that can be executed at once
~Schedule()
destructor
Schedule< GUM_SCALAR > & operator=(const Schedule< GUM_SCALAR > &)
copy operator
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::pair< long, long > memoryUsage(NodeId) const
returns the memory consumption used during the execution of an operation
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void forceBefore(const ScheduleOperation< GUM_SCALAR > &op_to_force, const ScheduleOperation< GUM_SCALAR > &op_after)
adds a constraint indicating that an operation must be performed before another one ...
Idx OperationId
to identify correctly the ids that correspond to ScheduleOperation ids
Definition: schedule.h:71
const ScheduleOperation< GUM_SCALAR > & operation(NodeId) const
returns the scheduleOperation corresponding to an id in the DAG
Schedule()
default constructor (construct an empty sequence)
Class containing a schedule of operations to perform on multidims.
Definition: schedule.h:68
Size Idx
Type for indexes.
Definition: types.h:53
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< OperationId, NodeId > __operation2node
a hashtable assigning to each operation id a node id in the DAG
Definition: schedule.h:214
void __updateWrongParents() const
updates the set of parents for the nodes whoses parents are not correct yet and update accordingly th...
HashTable< MultiDimId, NodeId > __created_multidims
a hashtable assigning to each ScheduleMultiDim resulting from a computation the MultiDimOperation nod...
Definition: schedule.h:218
Base class for dag.
Definition: DAG.h:102
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
float nbOperations(NodeId) const
returns an estimation of the number of elementary operations needed to perform a given ScheduleOperat...
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const NodeProperty< const ScheduleOperation< GUM_SCALAR > *> & operations() const
resturns the association between operations anf nodeIds
HashTable< MultiDimId, NodeSet *> __multidim2operations
for each multidim, store the set of operations involving it
Definition: schedule.h:234
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.