souffle  2.0.2-371-g6315b36
ProfileUse.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ProfileUse.h
12  *
13  * Defines a simple class to query profile data from a profile
14  * for profile-guided optimisation.
15  *
16  ***********************************************************************/
17 
18 #pragma once
19 
20 #include "ast/QualifiedName.h"
21 #include "ast/analysis/Analysis.h"
23 #include <cstddef>
24 #include <iostream>
25 #include <memory>
26 #include <string>
27 
28 namespace souffle::ast {
29 class TranslationUnit;
30 
31 namespace analysis {
32 
33 /**
34  * Analysis that loads profile data and has a profile query interface.
35  */
36 class ProfileUseAnalysis : public Analysis {
37 public:
38  /** Name of analysis */
39  static constexpr const char* name = "profile-use";
40 
42  : Analysis(name), programRun(std::make_shared<profile::ProgramRun>(profile::ProgramRun())) {}
43 
44  /** Run analysis */
45  void run(const TranslationUnit& translationUnit) override;
46 
47  /** Output some profile information */
48  void print(std::ostream& os) const override;
49 
50  /** Check whether the relation size exists in profile */
51  bool hasRelationSize(const QualifiedName& rel) const;
52 
53  /** Return size of relation in the profile */
54  size_t getRelationSize(const QualifiedName& rel) const;
55 
56 private:
57  /** performance model of profile run */
58  std::shared_ptr<profile::ProgramRun> programRun;
59 };
60 
61 } // namespace analysis
62 } // namespace souffle::ast
souffle::ast::analysis::Analysis::Analysis
Analysis(std::string identifier)
Definition: Analysis.h:40
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::analysis::ProfileUseAnalysis::programRun
std::shared_ptr< profile::ProgramRun > programRun
performance model of profile run
Definition: ProfileUse.h:65
souffle::ast::analysis::ProfileUseAnalysis::hasRelationSize
bool hasRelationSize(const QualifiedName &rel) const
Check whether the relation size exists in profile.
Definition: ProfileUse.cpp:54
ProgramRun.h
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::analysis::ProfileUseAnalysis::print
void print(std::ostream &os) const override
Output some profile information.
Definition: ProfileUse.cpp:49
souffle::ast::analysis::ProfileUseAnalysis::name
static constexpr const char * name
Name of analysis.
Definition: ProfileUse.h:46
QualifiedName.h
std
Definition: Brie.h:3053
souffle::ast::analysis::ProfileUseAnalysis::run
void run(const TranslationUnit &translationUnit) override
Run analysis.
Definition: ProfileUse.cpp:39
souffle::ast::analysis::ProfileUseAnalysis::ProfileUseAnalysis
ProfileUseAnalysis()
Definition: ProfileUse.h:48
souffle::ast
Definition: Aggregator.h:35
souffle::ast::QualifiedName
Qualified Name class defines fully/partially qualified names to identify objects in components.
Definition: QualifiedName.h:39
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
Analysis.h