souffle  2.0.2-371-g6315b36
Public Member Functions | Protected Member Functions | Private Attributes
souffle::ast::ProfileUseSips Class Reference

Goal: reorder based on the given profiling information Metric: cost(atom_R) = log(|atom_R|) * #free/#args. More...

#include <SipsMetric.h>

Inheritance diagram for souffle::ast::ProfileUseSips:
Inheritance graph
Collaboration diagram for souffle::ast::ProfileUseSips:
Collaboration graph

Public Member Functions

 ProfileUseSips (const analysis::ProfileUseAnalysis &profileUse)
 
- Public Member Functions inherited from souffle::ast::SipsMetric
std::vector< unsigned int > getReordering (const Clause *clause) const
 Determines the new ordering of a clause after the SIPS is applied. More...
 
virtual ~SipsMetric ()=default
 

Protected Member Functions

std::vector< double > evaluateCosts (const std::vector< Atom * > atoms, const BindingStore &bindingStore) const override
 Evaluates the cost of choosing each atom next in the current schedule. More...
 

Private Attributes

const analysis::ProfileUseAnalysisprofileUse
 

Additional Inherited Members

- Static Public Member Functions inherited from souffle::ast::SipsMetric
static std::unique_ptr< SipsMetriccreate (const std::string &heuristic, const TranslationUnit &tu)
 Create a SIPS metric based on a given heuristic. More...
 

Detailed Description

Goal: reorder based on the given profiling information Metric: cost(atom_R) = log(|atom_R|) * #free/#args.

Definition at line 138 of file SipsMetric.h.

Constructor & Destructor Documentation

◆ ProfileUseSips()

souffle::ast::ProfileUseSips::ProfileUseSips ( const analysis::ProfileUseAnalysis profileUse)
inline

Definition at line 140 of file SipsMetric.h.

Member Function Documentation

◆ evaluateCosts()

std::vector< double > souffle::ast::ProfileUseSips::evaluateCosts ( const std::vector< Atom * >  atoms,
const BindingStore bindingStore 
) const
overrideprotectedvirtual

Evaluates the cost of choosing each atom next in the current schedule.

Parameters
atomsatoms to choose from; may be nullptr
bindingStorethe variables already bound to a value

Implements souffle::ast::SipsMetric.

Definition at line 242 of file SipsMetric.cpp.

242  : atoms) {
243  if (atom == nullptr) {
244  cost.push_back(std::numeric_limits<double>::max());
245  continue;
246  }
247 
248  // prioritise propositions
249  int arity = atom->getArity();
250  if (arity == 0) {
251  cost.push_back(0);
252  continue;
253  }
254 
255  // calculate log(|R|) * #free/#args
256  int numBound = bindingStore.numBoundArguments(atom);
257  int numFree = arity - numBound;
258  double value = log(profileUse.getRelationSize(atom->getQualifiedName()));
259  value *= (numFree * 1.0) / arity;
260  }
261  return cost;
262 }
263 
264 std::vector<double> DeltaSips::evaluateCosts(
265  const std::vector<Atom*> atoms, const BindingStore& bindingStore) const {
266  // Goal: prioritise (1) all-bound, then (2) deltas, and then (3) left-most
267  std::vector<double> cost;
268  for (const auto* atom : atoms) {

References souffle::ast::analysis::ProfileUseAnalysis::getRelationSize(), and profileUse.

Here is the call graph for this function:

Field Documentation

◆ profileUse

const analysis::ProfileUseAnalysis& souffle::ast::ProfileUseSips::profileUse
private

Definition at line 147 of file SipsMetric.h.

Referenced by evaluateCosts().


The documentation for this class was generated from the following files:
souffle::ast::analysis::ProfileUseAnalysis::getRelationSize
size_t getRelationSize(const QualifiedName &rel) const
Return size of relation in the profile.
Definition: ProfileUse.cpp:61
souffle::ast::DeltaSips::evaluateCosts
std::vector< double > evaluateCosts(const std::vector< Atom * > atoms, const BindingStore &bindingStore) const override
Evaluates the cost of choosing each atom next in the current schedule.
Definition: SipsMetric.cpp:270
souffle::ast::ProfileUseSips::profileUse
const analysis::ProfileUseAnalysis & profileUse
Definition: SipsMetric.h:147