souffle  2.0.2-371-g6315b36
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
souffle::ast::analysis::RelationScheduleAnalysis Class Reference

Analysis pass computing a schedule for computing relations. More...

#include <RelationSchedule.h>

Inheritance diagram for souffle::ast::analysis::RelationScheduleAnalysis:
Inheritance graph
Collaboration diagram for souffle::ast::analysis::RelationScheduleAnalysis:
Collaboration graph

Public Member Functions

void print (std::ostream &os) const override
 Dump this relation schedule to standard error. More...
 
 RelationScheduleAnalysis ()
 
void run (const TranslationUnit &translationUnit) override
 run analysis for a Ast translation unit More...
 
const std::vector< RelationScheduleAnalysisStep > & schedule () const
 
- Public Member Functions inherited from souffle::ast::analysis::Analysis
 Analysis (std::string identifier)
 
virtual const std::string & getName () const
 get name of the analysis More...
 
virtual ~Analysis ()=default
 

Static Public Attributes

static constexpr const char * name = "relation-schedule"
 

Private Member Functions

std::vector< std::set< const Relation * > > computeRelationExpirySchedule (const TranslationUnit &translationUnit)
 

Private Attributes

PrecedenceGraphAnalysisprecedenceGraph = nullptr
 
std::vector< RelationScheduleAnalysisSteprelationSchedule
 Relations computed and expired relations at each step. More...
 
TopologicallySortedSCCGraphAnalysistopsortSCCGraphAnalysis = nullptr
 

Additional Inherited Members

- Protected Attributes inherited from souffle::ast::analysis::Analysis
const std::string identifier
 

Detailed Description

Analysis pass computing a schedule for computing relations.

Definition at line 82 of file RelationSchedule.h.

Constructor & Destructor Documentation

◆ RelationScheduleAnalysis()

souffle::ast::analysis::RelationScheduleAnalysis::RelationScheduleAnalysis ( )
inline

Definition at line 86 of file RelationSchedule.h.

Member Function Documentation

◆ computeRelationExpirySchedule()

std::vector< std::set< const Relation * > > souffle::ast::analysis::RelationScheduleAnalysis::computeRelationExpirySchedule ( const TranslationUnit translationUnit)
private

Definition at line 79 of file RelationSchedule.cpp.

86  {
87  /* Add alive set of previous step */
88  alive[orderedSCC].insert(alive[orderedSCC - 1].begin(), alive[orderedSCC - 1].end());
89 
90  /* Add predecessors of relations computed in this step */
91  auto scc = topsortSCCGraphAnalysis->order()[numSCCs - orderedSCC];
92  for (const Relation* r : sccGraph->getInternalRelations(scc)) {
93  for (const Relation* predecessor : precedenceGraph->graph().predecessors(r)) {
94  alive[orderedSCC].insert(predecessor);
95  }
96  }
97 
98  /* Compute expired relations in reverse topological order using the set difference of the alive sets
99  between steps. */
100  std::set_difference(alive[orderedSCC].begin(), alive[orderedSCC].end(), alive[orderedSCC - 1].begin(),
101  alive[orderedSCC - 1].end(),
102  std::inserter(relationExpirySchedule[numSCCs - orderedSCC],
103  relationExpirySchedule[numSCCs - orderedSCC].end()));
104  }
105 
106  return relationExpirySchedule;
107 }
108 
109 void RelationScheduleAnalysis::print(std::ostream& os) const {
110  os << "begin schedule\n";
111  for (const RelationScheduleAnalysisStep& step : relationSchedule) {
112  os << step;
113  os << "computed: ";
114  for (const Relation* compRel : step.computed()) {
115  os << compRel->getQualifiedName() << ", ";

◆ print()

void souffle::ast::analysis::RelationScheduleAnalysis::print ( std::ostream &  os) const
overridevirtual

Dump this relation schedule to standard error.

Reimplemented from souffle::ast::analysis::Analysis.

Definition at line 117 of file RelationSchedule.cpp.

117  : ";
118  for (const Relation* compRel : step.expired()) {
119  os << compRel->getQualifiedName() << ", ";
120  }
121  os << "\n";
122  if (step.recursive()) {
123  os << "recursive";
124  } else {
125  os << "not recursive";
126  }
127  os << "\n";
128  }
129  os << "end schedule\n";
130 }
131 
132 } // namespace souffle::ast::analysis

◆ run()

void souffle::ast::analysis::RelationScheduleAnalysis::run ( const TranslationUnit )
overridevirtual

run analysis for a Ast translation unit

Implements souffle::ast::analysis::Analysis.

Definition at line 61 of file RelationSchedule.cpp.

62  {
63  auto scc = topsortSCCGraphAnalysis->order()[i];
64  const std::set<const Relation*> computedRelations =
65  translationUnit.getAnalysis<SCCGraphAnalysis>()->getInternalRelations(scc);
66  relationSchedule.emplace_back(computedRelations, relationExpirySchedule[i],
67  translationUnit.getAnalysis<SCCGraphAnalysis>()->isRecursive(scc));
68  }
69 }
70 
71 std::vector<std::set<const Relation*>> RelationScheduleAnalysis::computeRelationExpirySchedule(
72  const TranslationUnit& translationUnit) {
73  std::vector<std::set<const Relation*>> relationExpirySchedule;
74  /* Compute for each step in the reverse topological order
75  of evaluating the SCC the set of alive relations. */
76  size_t numSCCs = topsortSCCGraphAnalysis->order().size();
77 

References i, souffle::ast::analysis::SCCGraphAnalysis::isRecursive(), souffle::ast::analysis::TopologicallySortedSCCGraphAnalysis::order(), relationSchedule, and topsortSCCGraphAnalysis.

Here is the call graph for this function:

◆ schedule()

const std::vector<RelationScheduleAnalysisStep>& souffle::ast::analysis::RelationScheduleAnalysis::schedule ( ) const
inline

Definition at line 90 of file RelationSchedule.h.

Field Documentation

◆ name

constexpr const char* souffle::ast::analysis::RelationScheduleAnalysis::name = "relation-schedule"
staticconstexpr

Definition at line 84 of file RelationSchedule.h.

◆ precedenceGraph

PrecedenceGraphAnalysis* souffle::ast::analysis::RelationScheduleAnalysis::precedenceGraph = nullptr
private

Definition at line 99 of file RelationSchedule.h.

◆ relationSchedule

std::vector<RelationScheduleAnalysisStep> souffle::ast::analysis::RelationScheduleAnalysis::relationSchedule
private

Relations computed and expired relations at each step.

Definition at line 102 of file RelationSchedule.h.

Referenced by run().

◆ topsortSCCGraphAnalysis

TopologicallySortedSCCGraphAnalysis* souffle::ast::analysis::RelationScheduleAnalysis::topsortSCCGraphAnalysis = nullptr
private

Definition at line 98 of file RelationSchedule.h.

Referenced by run().


The documentation for this class was generated from the following files:
souffle::ast::analysis::TopologicallySortedSCCGraphAnalysis::order
const std::vector< size_t > & order() const
Definition: TopologicallySortedSCCGraph.h:57
souffle::ast::analysis::RelationScheduleAnalysis::print
void print(std::ostream &os) const override
Dump this relation schedule to standard error.
Definition: RelationSchedule.cpp:117
souffle::ast::analysis::RelationScheduleAnalysis::computeRelationExpirySchedule
std::vector< std::set< const Relation * > > computeRelationExpirySchedule(const TranslationUnit &translationUnit)
Definition: RelationSchedule.cpp:79
souffle::ast::analysis::PrecedenceGraphAnalysis::graph
const Graph< const Relation *, NameComparison > & graph() const
Definition: PrecedenceGraph.h:54
n
var n
Definition: htmlJsChartistMin.h:15
souffle::ast::analysis::RelationScheduleAnalysis::relationSchedule
std::vector< RelationScheduleAnalysisStep > relationSchedule
Relations computed and expired relations at each step.
Definition: RelationSchedule.h:102
i
size_t i
Definition: json11.h:663
souffle::ast::analysis::RelationScheduleAnalysis::topsortSCCGraphAnalysis
TopologicallySortedSCCGraphAnalysis * topsortSCCGraphAnalysis
Definition: RelationSchedule.h:98
souffle::ast::analysis::RelationScheduleAnalysis::precedenceGraph
PrecedenceGraphAnalysis * precedenceGraph
Definition: RelationSchedule.h:99