souffle  2.0.2-371-g6315b36
Parallel.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 Parallel.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Program.h"
18 #include "ram/TranslationUnit.h"
19 #include "ram/analysis/Relation.h"
21 #include <string>
22 
23 namespace souffle::ram::transform {
24 
25 /**
26  * @class ParallelTransformer
27  * @brief Transforms Choice/IndexChoice/IndexScan/Scan into parallel versions.
28  *
29  * For example ..
30  *
31  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
32  * QUERY
33  * FOR t0 in A
34  * ...
35  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
36  *
37  * will be rewritten to
38  *
39  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
40  * QUERY
41  * PARALLEL FOR t0 in A
42  * ...
43  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
44  *
45  */
46 class ParallelTransformer : public Transformer {
47 public:
48  std::string getName() const override {
49  return "ParallelTransformer";
50  }
51 
52  /**
53  * @brief Parallelize operations
54  * @param program Program that is transformed
55  * @return Flag showing whether the program has been changed by the transformation
56  */
57  bool parallelizeOperations(Program& program);
58 
59 protected:
60  bool transform(TranslationUnit& translationUnit) override {
62  return parallelizeOperations(translationUnit.getProgram());
63  }
65 };
66 
67 } // namespace souffle::ram::transform
souffle::ram::transform
Definition: ChoiceConversion.cpp:30
souffle::ram::Program
RAM program relation declaration and functions.
Definition: Program.h:58
souffle::ram::TranslationUnit::getAnalysis
Analysis * getAnalysis() const
Get an analysis.
Definition: TranslationUnit.h:66
souffle::ram::transform::ParallelTransformer::parallelizeOperations
bool parallelizeOperations(Program &program)
Parallelize operations.
Definition: Parallel.cpp:36
Program.h
souffle::ram::TranslationUnit::getProgram
Program & getProgram() const
Get the RAM Program of the translation unit
Definition: TranslationUnit.h:107
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
Relation.h
souffle::ram::transform::ParallelTransformer::getName
std::string getName() const override
@Brief get name of the transformer
Definition: Parallel.h:52
TranslationUnit.h
Transformer.h
souffle::ram::transform::ParallelTransformer::transform
bool transform(TranslationUnit &translationUnit) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: Parallel.h:64
souffle::ram::analysis::RelationAnalysis
A RAM Analysis for finding relations by name.
Definition: Relation.h:36
souffle::ram::transform::ParallelTransformer::relAnalysis
analysis::RelationAnalysis * relAnalysis
Definition: Parallel.h:68