PandA-2024.02
vectorize.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
42 
43 #include "custom_map.hpp"
44 #include "panda_types.hpp"
45 
52 
54 using Transformation = enum Transformation {
55  NONE,
56  COND_CON,
58  COND_DIV,
59  INC,
61  INIT,
62  SCALAR,
63  SIMD,
64 };
65 
67 {
68  private:
71 
74 
77 
80 
83 
85  using SimdLoop = enum {
86  SIMD_NONE,
87  SIMD_INNER,
88  SIMD_OUTER
89  };
90 
93 
96 
99 
102 
105 
111  void ClassifyLoop(const LoopConstRef loop, const size_t parallel_degree);
112 
118  void ClassifyTreeNode(const unsigned int loop_id, const tree_nodeConstRef tree_node);
119 
126 
135  unsigned int Transform(const unsigned int tree_node_index, const size_t parallel_degree, const size_t scalar_index,
136  std::list<tree_nodeRef>& new_stmt_list, std::vector<tree_nodeRef>& new_phi_list);
137 
144  unsigned int DuplicateIncrement(const unsigned int loop_id, const tree_nodeRef statement);
145 
149  void AddGuards();
150 
154  void FixPhis();
155 
159  void SetPredication();
160 
166  ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override;
167 
168  public:
176  Vectorize(const application_managerRef AppM, unsigned int function_id,
177  const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters);
178 
182  ~Vectorize() override;
183 
189 
194  bool HasToBeExecuted() const override;
195 };
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Definition: vectorize.cpp:3228
void ClassifyTreeNode(const unsigned int loop_id, const tree_nodeConstRef tree_node)
Classify a statement.
Definition: vectorize.cpp:485
This struct specifies the field bloc (basic block).
CustomUnorderedMap< unsigned int, CustomUnorderedMapStable< size_t, unsigned int > > scalar_to_scalar
Map between scalar tree node and versioned scalar tree node.
Definition: vectorize.hpp:73
void SetPredication()
Set predicate of predicated instructions.
Definition: vectorize.cpp:1484
#define INIT(x, y)
Definition: spider.cpp:73
CustomMap< unsigned int, SimdLoop > simd_loop_type
Loop classification.
Definition: vectorize.hpp:92
bool LookForScalar(const tree_nodeConstRef tree_node)
Check recursively if at least an ssa operand is defined an operation outside simd outer loop...
Definition: vectorize.cpp:1052
RelationshipType
The relationship type.
This class manages the tree structures extracted from the raw file.
DesignFlowStep_Status InternalExec() override
Restructures the unstructured code.
Definition: vectorize.cpp:169
CONSTREF_FORWARD_DECL(Loop)
CustomMap< unsigned int, bool > basic_block_divergence
Basic block classification: if value is true, the basic block can be executed or not in parallel inst...
Definition: vectorize.hpp:98
CustomOrderedMap< T, U > CustomMap
Definition: custom_map.hpp:167
Vectorize(const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
Definition: vectorize.cpp:111
enum Transformation { NONE, COND_CON, COND_DIV, INC, INIT, SCALAR, SIMD, } Transformation
Enum used to classify the statement according to the required transformation.
Definition: vectorize.hpp:64
This class contains the base representation for a generic frontend flow step which works on a single ...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapUnstable
Definition: custom_map.hpp:156
redefinition of map to manage ordered/unordered structures
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
CustomMap< unsigned int, integer_cst_t > iv_increment
The increment of induction variables; id is the index of the ssa name defined in the init gimple...
Definition: vectorize.hpp:82
REF_FORWARD_DECL(bloc)
unsigned int DuplicateIncrement(const unsigned int loop_id, const tree_nodeRef statement)
Duplicate increment statement and update uses of defined variable when necessary. ...
Definition: vectorize.cpp:932
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
Definition: custom_map.hpp:148
CustomUnorderedMapUnstable< unsigned int, unsigned int > scalar_to_vector
Map between scalar tree node and vector tree node.
Definition: vectorize.hpp:70
void ClassifyLoop(const LoopConstRef loop, const size_t parallel_degree)
Classify a loop.
Definition: vectorize.cpp:332
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
CustomMap< unsigned int, size_t > loop_parallel_degree
Loop parallel degree.
Definition: vectorize.hpp:95
~Vectorize() override
Destructor.
unsigned int Transform(const unsigned int tree_node_index, const size_t parallel_degree, const size_t scalar_index, std::list< tree_nodeRef > &new_stmt_list, std::vector< tree_nodeRef > &new_phi_list)
Transform a tree node.
Definition: vectorize.cpp:1519
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Definition: loop.hpp:153
const tree_manipulationRef tree_man
The tree_manipulation.
Definition: vectorize.hpp:79
void AddGuards()
Add the guards for predicated operations.
Definition: vectorize.cpp:1117
CustomMap< unsigned int, tree_nodeRef > guards
The guards for each basic block.
Definition: vectorize.hpp:104
const unsigned int function_id
The index of the function to be analyzed.
const application_managerRef AppM
The application manager.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
Definition: vectorize.cpp:123
enum { SIMD_NONE, SIMD_INNER, SIMD_OUTER } SimdLoop
Enum used to classify the loop according to the required transformation.
Definition: vectorize.hpp:89
CustomMap< unsigned int, Transformation > transformations
Statement classification.
Definition: vectorize.hpp:101
void FixPhis()
Fix the phis to consider implicitly predicated operations.
Definition: vectorize.cpp:1332
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
const tree_managerRef TM
The tree manager.
Definition: vectorize.hpp:76

Generated on Mon Feb 12 2024 13:02:52 for PandA-2024.02 by doxygen 1.8.13