Phalanx
Development
|
Class to generate the directed acyclic graph (DAG) for evaluation. Determined which Evaluators should be called and the order in which to call them such that all dependencies are met with consistency. More...
#include <Phalanx_DAG_Manager.hpp>
Public Member Functions | |
DagManager (const std::string &evaluator_type_name="???") | |
void | requireField (const PHX::FieldTag &v) |
Require a variable to be evaluated. | |
void | registerEvaluator (const Teuchos::RCP< PHX::Evaluator< Traits > > &p) |
Registers a variable provider with the manager. | |
void | setDefaultGraphvizFilenameForErrors (const std::string &file_name) |
Sets the default filename for graphiz file generation for DAG construction errors. | |
void | setWriteGraphvizFileOnError (bool write_file) |
If set to true, a graphviz file will be written during for DAG construction errors. | |
void | sortAndOrderEvaluators () |
void | postRegistrationSetup (typename Traits::SetupData d, PHX::FieldManager< Traits > &vm) |
void | evaluateFields (typename Traits::EvalData d) |
Evaluate the required fields using data parallel evalaution on topological sort of tasks. | |
void | preEvaluate (typename Traits::PreEvalData d) |
This routine is called before each residual/Jacobian fill. More... | |
void | postEvaluate (typename Traits::PostEvalData d) |
This routine is called after each residual/Jacobian fill. More... | |
void | setEvaluationTypeName (const std::string &evaluation_type_name) |
const std::vector< Teuchos::RCP< PHX::FieldTag > > & | getFieldTags () |
bool | sortingCalled () const |
void | writeGraphvizFile (const std::string filename, bool writeEvaluatedFields, bool writeDependentFields, bool debugRegisteredEvaluators) const |
void | writeGraphvizFileNew (const std::string filename, bool writeEvaluatedFields, bool writeDependentFields) const |
void | print (std::ostream &os) const |
Printing. | |
const std::vector< int > & | getEvaluatorInternalOrdering () const |
Returns the Topological sort ordering. Used for unit testing. | |
const std::vector< PHX::DagNode< Traits > > & | getDagNodes () const |
Returns the internally registered nodes. Used for unit testing. | |
void | analyzeGraph (double &speedup, double ¶llelizability) const |
Returns the speedup and parallelizability of the graph. More... | |
std::vector< Teuchos::RCP< PHX::Evaluator< Traits > > > & | getEvaluatorsBindingField (const PHX::FieldTag &ft) |
Returns all evalautors that either evaluate or require the given field. This is used to bind memory for unmanaged views. More... | |
Protected Member Functions | |
void | dfsVisit (PHX::DagNode< Traits > &node, int &time) |
Depth-first search algorithm. | |
void | writeGraphvizDfsVisit (PHX::DagNode< Traits > &node, std::vector< PHX::DagNode< Traits >> &nodes_copy, std::ostream &os, const bool writeEvaluatedFields, const bool writeDependentFields) const |
Depth-first search algorithm specialized for writing graphviz output. | |
void | printEvaluator (const PHX::Evaluator< Traits > &e, std::ostream &os) const |
Helper function. | |
void | createEvalautorBindingFieldMap () |
Protected Attributes | |
std::vector< Teuchos::RCP< PHX::FieldTag > > | required_fields_ |
Fields required by the user. | |
std::vector< PHX::DagNode< Traits > > | nodes_ |
Vector of all registered evaluators. More... | |
std::unordered_map< std::string, int > | field_to_node_index_ |
Hash map of field key to evaluator index. | |
std::unordered_map< std::string, std::unordered_set< int > > | contributed_field_to_node_index_ |
Hash map of contributed field key to evaluator index. | |
std::vector< Teuchos::RCP< PHX::FieldTag > > | fields_ |
All fields that are needed for the evaluation. | |
std::vector< Teuchos::RCP< Teuchos::Time > > | evalTimers |
Evaluation Order Objects | |
Stores results from a topological sort on the evaluator DAG: the order to call evaluators to evaluate fields correctly. | |
std::vector< int > | topoSortEvalIndex |
std::string | graphviz_filename_for_errors_ |
Use this name for graphviz file output for DAG construction errors. | |
bool | write_graphviz_file_on_error_ |
If set to true, will write graphviz file for DAG construction errors. | |
std::string | evaluation_type_name_ |
bool | sorting_called_ |
Flag to tell the setup has been called. | |
bool | allow_multiple_evaluators_for_same_field_ |
Backwards compatibility option: set to true to disable a check that throws if multiple registered evaluators can evaluate the same field. Original DFS algortihm allowed this. Refactor checks and throws. | |
std::unordered_map< std::string, std::vector< Teuchos::RCP< PHX::Evaluator< Traits > > > > | field_to_evaluators_binding_ |
A map that returns all evalautors that bind the memory of a particular field. Key is unique field identifier. | |
Class to generate the directed acyclic graph (DAG) for evaluation. Determined which Evaluators should be called and the order in which to call them such that all dependencies are met with consistency.
void PHX::DagManager< Traits >::analyzeGraph | ( | double & | speedup, |
double & | parallelizability | ||
) | const |
Returns the speedup and parallelizability of the graph.
Estimates are based on execution times. This will return garbage if the evaluateFields() call has not been made to log execution times.
std::vector< Teuchos::RCP< PHX::Evaluator< Traits > > > & PHX::DagManager< Traits >::getEvaluatorsBindingField | ( | const PHX::FieldTag & | ft | ) |
Returns all evalautors that either evaluate or require the given field. This is used to bind memory for unmanaged views.
CAUTION: The returned vector is non-const to rebind memory for fields in evalautors. Be careful not to corrupt the actual vector.
References PHX::FieldTag::identifier().
void PHX::DagManager< Traits >::postEvaluate | ( | typename Traits::PostEvalData | d | ) |
This routine is called after each residual/Jacobian fill.
This routine is called ONCE on the provider after the fill loop over elements is completed. This allows us to evaluate any post fill data. An example is to print out some statistics such as the maximum grid peclet number in a cell.
void PHX::DagManager< Traits >::postRegistrationSetup | ( | typename Traits::SetupData | d, |
PHX::FieldManager< Traits > & | vm | ||
) |
Calls post registration setup on all variable providers.
void PHX::DagManager< Traits >::preEvaluate | ( | typename Traits::PreEvalData | d | ) |
This routine is called before each residual/Jacobian fill.
This routine is called ONCE on the provider before the fill loop over elements is started. This allows us to reset global objects between each fill. An example is to reset a provider that monitors the maximum grid peclet number in a cell. This call would zero out the maximum for a new fill.
void PHX::DagManager< Traits >::sortAndOrderEvaluators | ( | ) |
Builds the evaluation DAG. This should only be called after all required fields and evaluators are registered. Must be called prior to making calls to postRegistrationSetup(), evaluateFields(), preEvaluate(), and postEvaluate(). This can be called multiple times to build a new DAG if requirements have changed or more evaluators have been added.
|
protected |
Vector of all registered evaluators.
This list may include more nodes than what is needed for the DAG evaluation of required fields.