Phalanx  Development
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PHX::DagManager< Traits > Class Template Reference

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)
 Compute the required variables for the fill on the specific element.
 
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 intrenally registered nodes. Used for unit testing.
 
void analyzeGraph (double &speedup, double &parallelizability) const
 Returns the speedup and parallelizability of the graph. 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.
 

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::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.
 

Detailed Description

template<typename Traits>
class PHX::DagManager< Traits >

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.

Member Function Documentation

template<typename Traits >
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.

References PHX::DagManager< Traits >::nodes_.

Referenced by PHX::DagManager< Traits >::print().

template<typename Traits >
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.

References PHX::DagManager< Traits >::field_to_node_index_, PHX::DagManager< Traits >::nodes_, PHX::DagManager< Traits >::required_fields_, and PHX::DagManager< Traits >::writeGraphvizDfsVisit().

Referenced by PHX::DagManager< Traits >::preEvaluate().

template<typename Traits >
void PHX::DagManager< Traits >::postRegistrationSetup ( typename Traits::SetupData  d,
PHX::FieldManager< Traits > &  vm 
)

Calls post registration setup on all variable providers.

References PHX::DagManager< Traits >::evaluateFields(), and PHX::DagManager< Traits >::nodes_.

Referenced by PHX::DagManager< Traits >::printEvaluator().

template<typename Traits >
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.

References PHX::DagManager< Traits >::nodes_, and PHX::DagManager< Traits >::postEvaluate().

Referenced by PHX::DagManager< Traits >::evaluateFields().

template<typename Traits >
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.

References PHX::DagManager< Traits >::dfsVisit(), PHX::DagManager< Traits >::field_to_node_index_, PHX::DagManager< Traits >::fields_, PHX::DagManager< Traits >::graphviz_filename_for_errors_, PHX::DagManager< Traits >::nodes_, PHX::DagManager< Traits >::required_fields_, PHX::DagManager< Traits >::sorting_called_, and PHX::DagManager< Traits >::write_graphviz_file_on_error_.

Referenced by PHX::DagManager< Traits >::setWriteGraphvizFileOnError().

Member Data Documentation

template<typename Traits>
std::vector<PHX::DagNode<Traits> > PHX::DagManager< Traits >::nodes_
protected

The documentation for this class was generated from the following files: