souffle  2.0.2-371-g6315b36
ProfileUse.cpp
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.cpp
12  *
13  * Implements an Analysis that provides profile information
14  * from a profile log file for profile-guided optimisations.
15  *
16  ***********************************************************************/
17 
19 #include "Global.h"
20 #include "ast/QualifiedName.h"
22 #include "souffle/profile/Reader.h"
24 #include <limits>
25 #include <string>
26 
27 namespace souffle::ast::analysis {
28 
29 /**
30  * Run analysis, i.e., retrieve profile information
31  */
32 void ProfileUseAnalysis::run(const TranslationUnit&) {
33  if (Global::config().has("profile-use")) {
34  std::string filename = Global::config().get("profile-use");
35  profile::Reader(filename, programRun).processFile();
36  }
37 }
38 
39 /**
40  * Print analysis
41  */
42 void ProfileUseAnalysis::print(std::ostream&) const {}
43 
44 /**
45  * Check whether relation size is defined in profile
46  */
48  return programRun->getRelation(rel.toString()) != nullptr;
49 }
50 
51 /**
52  * Get relation size from profile
53  */
55  if (const auto* profRel = programRun->getRelation(rel.toString())) {
56  return profRel->size();
57  } else {
58  return std::numeric_limits<size_t>::max();
59  }
60 }
61 
62 } // namespace souffle::ast::analysis
souffle::ast::analysis::ProfileUseAnalysis::getRelationSize
size_t getRelationSize(const QualifiedName &rel) const
Return size of relation in the profile.
Definition: ProfileUse.cpp:61
Reader.h
souffle::ast::analysis::ProfileUseAnalysis::programRun
std::shared_ptr< profile::ProgramRun > programRun
performance model of profile run
Definition: ProfileUse.h:65
ProfileUse.h
souffle::ast::analysis::ProfileUseAnalysis::hasRelationSize
bool hasRelationSize(const QualifiedName &rel) const
Check whether the relation size exists in profile.
Definition: ProfileUse.cpp:54
Global.h
ProgramRun.h
souffle::Global::config
static MainConfig & config()
Definition: Global.h:141
souffle::ast::analysis::ProfileUseAnalysis::print
void print(std::ostream &os) const override
Output some profile information.
Definition: ProfileUse.cpp:49
QualifiedName.h
souffle::ast::analysis::ProfileUseAnalysis::run
void run(const TranslationUnit &translationUnit) override
Run analysis.
Definition: ProfileUse.cpp:39
souffle::ast::analysis
Definition: Aggregate.cpp:39
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
Relation.h