![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Class containing a schedule of operations to perform on multidims. More...
#include <agrum/base/graphicalModels/inference/scheduler/schedule.h>
Public Member Functions | |
Constructors / Destructors | |
| Schedule (const Size nb_ops=256) | |
| default constructor (construct an empty sequence) | |
| Schedule (const Schedule &from) | |
| copy constructor | |
| Schedule (Schedule &&from) | |
| move constructor | |
| virtual Schedule * | clone () const |
| virtual copy constructor | |
| virtual | ~Schedule () |
| destructor | |
Operators | |
| Schedule & | operator= (const Schedule &) |
| copy operator | |
| Schedule & | operator= (Schedule &&) |
| move operator | |
| bool | operator== (const Schedule &) const |
| operator == | |
| bool | operator!= (const Schedule &) const |
| operator != | |
Accessors/Modifiers | |
| template<typename TABLE> | |
| const IScheduleMultiDim * | insertTable (const TABLE &table, const bool copy, const Idx id=0) |
| inserts a new table as a source operation's input, i.e., this table is not computed by any ScheduleOperator | |
| const IScheduleMultiDim * | insertScheduleMultiDim (const IScheduleMultiDim &multidim) |
| inserts a copy of a table as a source operation's input, i.e., this table is not computed by any ScheduleOperator | |
| void | emplaceScheduleMultiDim (const IScheduleMultiDim &multidim) |
| inserts without copying it a table as a source operation's input, i.e., this table is not computed by any ScheduleOperator | |
| const ScheduleOperator & | insertOperation (const ScheduleOperator &op, const bool are_results_persistent=false) |
| inserts an operation into the schedule | |
| template<typename TABLE1, typename TABLE2, typename TABLE_RES> | |
| const ScheduleOperator & | emplaceBinaryCombination (const ScheduleMultiDim< TABLE1 > &table1, const ScheduleMultiDim< TABLE2 > &table2, TABLE_RES(*combine)(const TABLE1 &, const TABLE2 &), const bool is_result_persistent=false) |
| emplace a new schedule binary combination operation | |
| template<typename TABLE> | |
| const ScheduleOperator & | emplaceProjection (const ScheduleMultiDim< TABLE > &table, const gum::VariableSet &del_vars, TABLE(*project)(const TABLE &, const gum::VariableSet &), const bool is_result_persistent=false) |
| emplace a new schedule projection operation | |
| template<typename TABLE> | |
| const ScheduleOperator & | emplaceDeletion (const ScheduleMultiDim< TABLE > &table) |
| emplace a new schedule deletion operation | |
| template<typename TABLE, template< typename... > class CONTAINER> | |
| const ScheduleOperator & | emplaceStorage (const IScheduleMultiDim &table, CONTAINER< TABLE > &container) |
| emplace a new schedule storage operation | |
| const DAG & | dag () const |
| returns a DAG indicating in which order the operations can be performed | |
| const ScheduleOperator & | operation (const NodeId id) const |
| returns the scheduleOperation corresponding to an id in the DAG | |
| NodeId | nodeId (const ScheduleOperator &) const |
| returns the id of the node corresponding to a given ScheduleOperator | |
| NodeSet | availableOperations () const |
| returns the set of ScheduleOperations that are ready to be executed | |
| void | updateAfterExecution (const NodeId exec_node, std::vector< NodeId > &new_available_nodes, const bool check=false) |
| updates the schedule after a given operation has been executed | |
| void | updateAfterExecution (const ScheduleOperator &exec_op, std::vector< NodeId > &new_available_nodes, const bool check=false) |
| updates the schedule after executing a given operation | |
| const IScheduleMultiDim * | scheduleMultiDim (const NodeId id) const |
| returns the ScheduleMultiDim corresponding to a given id | |
| bool | existsScheduleMultiDim (const NodeId id) const |
| indicates whether the schedule contains a given ScheduleMultiDim | |
| NodeId | scheduleMultiDimId (const IScheduleMultiDim *multidim) const |
| returns the id of a given IScheduleMultiDim | |
| const ScheduleOperator * | scheduleMultiDimCreator (const NodeId id) const |
| returns the operation, if any, that created a given scheduleMultiDim | |
| const ScheduleOperator * | scheduleMultiDimCreator (const IScheduleMultiDim *multidim) const |
| returns the operation, if any, that created a given scheduleMultiDim | |
| Idx | versionNumber () const |
| returns the version number of the schedule | |
| void | clear () |
| empty the schedule, i.e., remove its content | |
Private Member Functions | |
| void | _copy_ (const Schedule &from) |
| a function to copy the content of a schedule into another one | |
| void | _destroy_ () |
| a function to delete from memory the content of a schedule | |
| DAG | _fullDAG_ () const |
| returns the graph that would obtain when no operation is performed | |
Static Private Member Functions | |
| static std::string | _paramString_ (Idx i) |
| returns the adjective corresponding to a parameter index (1st, 2nd, etc.) | |
| static Idx | _newVersionNumber_ () |
| returns a new distinct version for each schedule | |
Private Attributes | |
| DAG | _dag_ |
| the DAG of the operations to perform | |
| NodeId | _newId_ {NodeId(0)} |
| the highest node id in the graph | |
| Bijection< NodeId, ScheduleOperator * > | _node2op_ |
| a mapping between the ids of the operations and their pointer | |
| HashTable< const IScheduleMultiDim *, std::pair< ScheduleOperator *, Idx > > | _multidim_location_ |
| a structure to indicate precisely where a ScheduleMultiDim comes from | |
| Bijection< const IScheduleMultiDim *, Idx > | _multidim2id_ |
| a bijection between pointers to IScheduleMultiDim and their Ids | |
| Set< const IScheduleMultiDim * > | _emplaced_multidims_ |
| indicates which ScheduleMultiDims were emplaced | |
| HashTable< const IScheduleMultiDim *, NodeSet > | _multidim2nodes_ |
| maps the multidims to the set of operations that use them | |
| Bijection< const IScheduleMultiDim *, NodeId > | _deleted_multidim2node_ |
| A bijection mapping ScheduleMultiDims to be deleted with the operations that will delete them. | |
| Idx | _version_number_ |
| a number that identifies the current version of the schedule | |
Static Private Attributes | |
| static std::atomic< Idx > | _overall_version_number_ |
Class containing a schedule of operations to perform on multidims.
A Schedule class contains a set of operations to be scheduled. It is able to indicate which operations can currently be performed (because all their arguments have already been computed). In addition, it is possible to insert new operations into the schedule (at a specific location) and to remove some operations.
Definition at line 80 of file schedule.h.
|
explicit |
default constructor (construct an empty sequence)
Referenced by Schedule(), Schedule(), _copy_(), clone(), operator!=(), operator=(), operator=(), and operator==().
| gum::Schedule::Schedule | ( | const Schedule & | from | ) |
| gum::Schedule::Schedule | ( | Schedule && | from | ) |
|
virtual |
destructor
|
private |
a function to copy the content of a schedule into another one
References Schedule().
|
private |
a function to delete from memory the content of a schedule
|
private |
returns the graph that would obtain when no operation is performed
|
staticprivate |
returns a new distinct version for each schedule
|
staticprivate |
returns the adjective corresponding to a parameter index (1st, 2nd, etc.)
| NodeSet gum::Schedule::availableOperations | ( | ) | const |
returns the set of ScheduleOperations that are ready to be executed
The operations that can be executed at once are those that have no parent or whose parents have already been executed.
| void gum::Schedule::clear | ( | ) |
empty the schedule, i.e., remove its content
|
virtual |
| const DAG & gum::Schedule::dag | ( | ) | const |
| const ScheduleOperator & gum::Schedule::emplaceBinaryCombination | ( | const ScheduleMultiDim< TABLE1 > & | table1, |
| const ScheduleMultiDim< TABLE2 > & | table2, | ||
| TABLE_RES(* | combine )(const TABLE1 &, const TABLE2 &), | ||
| const bool | is_result_persistent = false ) |
emplace a new schedule binary combination operation
| table1 | the first ScheduleMultiDim to combine with the other table |
| table2 | the second table involved in the combination |
| combine | a function taking two (real) tables in argument and returning the result of their combination |
| is_result_persistent | this boolean indicates whether the result of the binary combination is persistent, i.e., whether it should be kept in memory when the operation itself is deleted from memory. |
| UnknownScheduleMultiDim | if some of the arguments of op do not already belong to the schedule. Such arguments would indeed prevent the schedule to be performed. |
| OperationNotAllowed | if the operation deletes its arguments and either another operation also deletes some of them or the operation has already been performed but other operations use some of these arguments and they have not been executed yet. |
| const ScheduleOperator & gum::Schedule::emplaceDeletion | ( | const ScheduleMultiDim< TABLE > & | table | ) |
emplace a new schedule deletion operation
| UnknownScheduleMultiDim | if some of the arguments of op do not already belong to the schedule. Such arguments would indeed prevent the schedule to be performed. |
| OperationNotAllowed | if the operation deletes its arguments and either another operation also deletes some of them or the operation has already been performed but other operations use some of these arguments and they have not been executed yet. |
| const ScheduleOperator & gum::Schedule::emplaceProjection | ( | const ScheduleMultiDim< TABLE > & | table, |
| const gum::VariableSet & | del_vars, | ||
| TABLE(* | project )(const TABLE &, const gum::VariableSet &), | ||
| const bool | is_result_persistent = false ) |
emplace a new schedule projection operation
| table | the ScheduleMultiDim containing the table that will be projected |
| del_vars | the set of variables that will be removed from table. Note that variables in del_vars that do not belong to table are simply not taken into account. They do not raise any exception. |
| project | the function that will actually perform the projection |
| is_result_persistent | this boolean indicates whether the result of the projection is persistent, i.e., whether it should be kept in memory when the operation itself is deleted from memory. |
| UnknownScheduleMultiDim | if some of the arguments of op do not already belong to the schedule. Such arguments would indeed prevent the schedule to be performed. |
| OperationNotAllowed | if the operation deletes its arguments and either another operation also deletes some of them or the operation has already been performed but other operations use some of these arguments and they have not been executed yet. |
| void gum::Schedule::emplaceScheduleMultiDim | ( | const IScheduleMultiDim & | multidim | ) |
inserts without copying it a table as a source operation's input, i.e., this table is not computed by any ScheduleOperator
ScheduleOperations produce new tables that can be passed as arguments to other ScheduleOperations. However source operations, i.e., those that are the sources of the DAG (they are the first to be computed), need arguments/tables that have been created before the Schedule. These tables can be inserted as is (without copy) into the schedule using this emplace method
| multidim | the ScheduleMultiDim inserted into the schedule without copying it. |
| AbstractScheduleMultiDim | is thrown if the ScheduleMultiDim is abstract, i.e., it does not contain a true table. The tables we insert with method insertTable are not computed by any schedule operations, hence they should never be abstract, else the schedule may not be executable. |
| DuplicateScheduleMultiDim | is thrown if the schedule already contains a table with the same id |
| const ScheduleOperator & gum::Schedule::emplaceStorage | ( | const IScheduleMultiDim & | table, |
| CONTAINER< TABLE > & | container ) |
emplace a new schedule storage operation
| UnknownScheduleMultiDim | if some of the arguments of op do not already belong to the schedule. Such arguments would indeed prevent the schedule to be performed. |
| OperationNotAllowed | if the operation deletes its arguments and either another operation also deletes some of them or the operation has already been performed but other operations use some of these arguments and they have not been executed yet. |
indicates whether the schedule contains a given ScheduleMultiDim
| const ScheduleOperator & gum::Schedule::insertOperation | ( | const ScheduleOperator & | op, |
| const bool | are_results_persistent = false ) |
inserts an operation into the schedule
The Schedule class is able to determine by itself when the operation can be performed.
| op | the operation that will be copied into the schedule |
| are_results_persistent | this boolean indicates whether the results of the operation are persistent, i.e., whether they should be kept in memory when the operation itself is deleted from memory. |
| UnknownScheduleMultiDim | if some of the arguments of op do not already belong to the schedule. Such arguments would indeed prevent the schedule to be performed. |
| OperationNotAllowed | if the operation deletes its arguments and either another operation also deletes some of them or the operation has already been performed but other operations use some of these arguments and they have not been executed yet. |
| const IScheduleMultiDim * gum::Schedule::insertScheduleMultiDim | ( | const IScheduleMultiDim & | multidim | ) |
inserts a copy of a table as a source operation's input, i.e., this table is not computed by any ScheduleOperator
ScheduleOperations produce new tables that can be passed as arguments to other ScheduleOperations. However source operations, i.e., those that are the sources of the DAG (they are the first to be computed), need arguments/tables that have been created before the Schedule. These tables can be inserted into the schedule using this insert method
| multidim | the ScheduleMultiDim inserted into the schedule. Note that this clones the ScheduleMultiDim passed in argument if it does not already belong to the schedule, or it returns it otherwise. |
| AbstractScheduleMultiDim | is thrown if the ScheduleMultiDim is abstract, i.e., it does not contain a true table. The tables we insert with method insertTable are not computed by any schedule operations, hence they should never be abstract, else the schedule may not be executable. |
| DuplicateScheduleMultiDim | is thrown if the schedule already contains a table with the same id |
| const IScheduleMultiDim * gum::Schedule::insertTable | ( | const TABLE & | table, |
| const bool | copy, | ||
| const Idx | id = 0 ) |
inserts a new table as a source operation's input, i.e., this table is not computed by any ScheduleOperator
ScheduleOperations produce new tables that can be passed as arguments to other ScheduleOperations. However source operations, i.e., those that are the sources of the DAG (they are the first to be computed), need arguments/tables that have been created before the Schedule. These tables should be inserted into the schedule using this insert method
| table | the table to be inserted into the schedule. Note that this creates a ScheduleMultiDim that references this table (the latter is not copied). |
| DuplicateScheduleMultiDim | is thrown if the schedule already contains a table with the same id |
| NodeId gum::Schedule::nodeId | ( | const ScheduleOperator & | ) | const |
returns the id of the node corresponding to a given ScheduleOperator
| const ScheduleOperator & gum::Schedule::operation | ( | const NodeId | id | ) | const |
| const IScheduleMultiDim * gum::Schedule::scheduleMultiDim | ( | const NodeId | id | ) | const |
returns the ScheduleMultiDim corresponding to a given id
| const ScheduleOperator * gum::Schedule::scheduleMultiDimCreator | ( | const IScheduleMultiDim * | multidim | ) | const |
returns the operation, if any, that created a given scheduleMultiDim
| const ScheduleOperator * gum::Schedule::scheduleMultiDimCreator | ( | const NodeId | id | ) | const |
returns the operation, if any, that created a given scheduleMultiDim
| NodeId gum::Schedule::scheduleMultiDimId | ( | const IScheduleMultiDim * | multidim | ) | const |
returns the id of a given IScheduleMultiDim
| void gum::Schedule::updateAfterExecution | ( | const NodeId | exec_node, |
| std::vector< NodeId > & | new_available_nodes, | ||
| const bool | check = false ) |
updates the schedule after a given operation has been executed
| exec_node | The node id of the operation that has just been executed |
| new_available_nodes | a vector that will be filled with all the new operations becoming available due to exec_node being executed. |
| check | if true, we check that the operation could be executed and has actually been executed. |
| UnavailableScheduleOperation | exception is thrown in check mode if the operation was not available and, hence, should not have been executed. This should never happen. |
| UnknownScheduleOperation | exception is thrown in check mode if the DAG does not contain the node of the executed operation. This should never happen. |
| UnexecutedScheduleOperation | exception is thrown in check mode if the operation has not yet been executed. This should never happen. |
| void gum::Schedule::updateAfterExecution | ( | const ScheduleOperator & | exec_op, |
| std::vector< NodeId > & | new_available_nodes, | ||
| const bool | check = false ) |
updates the schedule after executing a given operation
| exec_op | The operation that has just been executed |
| new_available_nodes | a vector that will be filled with all the new operations becoming available due to exec_op being executed. |
| check | if true, we check that the operation could be executed and has actually been executed. |
| UnavailableScheduleOperation | exception is thrown in check mode if the operation was not available and, hence, should not have been executed. This should never happen. |
| UnknownScheduleOperation | exception is thrown in check mode if the DAG does not contain the node of the executed operation. This should never happen. |
| UnexecutedScheduleOperation | exception is thrown in check mode if the operation has not yet been executed. This should never happen. |
| Idx gum::Schedule::versionNumber | ( | ) | const |
returns the version number of the schedule
|
private |
the DAG of the operations to perform
Operations can be scheduled as a DAG: nodes without parents can be executed directly. The other nodes need their parents to be executed to get all their arguments constructed.
Definition at line 378 of file schedule.h.
|
private |
A bijection mapping ScheduleMultiDims to be deleted with the operations that will delete them.
This information is of interest because, to limit the memory consumption, a scheduler should consider executing the operations stored into this bijection as soon as possible
Definition at line 421 of file schedule.h.
|
private |
indicates which ScheduleMultiDims were emplaced
Definition at line 405 of file schedule.h.
|
private |
a bijection between pointers to IScheduleMultiDim and their Ids
Definition at line 402 of file schedule.h.
|
private |
maps the multidims to the set of operations that use them
Definition at line 408 of file schedule.h.
|
private |
a structure to indicate precisely where a ScheduleMultiDim comes from
ScheduleMultiDims can either result from the execution of some operation or reference a MultiDim created outside of the schedule. This structure enables to discriminate these situations:
Definition at line 399 of file schedule.h.
|
private |
a mapping between the ids of the operations and their pointer
Definition at line 384 of file schedule.h.
|
staticprivate |
Definition at line 446 of file schedule.h.
|
private |
a number that identifies the current version of the schedule
schedules' versions change whenever new ScheduleMultiDims or ScheduleOperations are inserted
Definition at line 426 of file schedule.h.