PandA-2024.02
omp_allocation.cpp
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) 2015-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  */
40 #include "omp_allocation.hpp"
41 #include "Parameter.hpp"
42 #include "area_info.hpp"
43 #include "behavioral_helper.hpp"
44 #include "function_behavior.hpp"
45 #include "hls_device.hpp"
46 #include "hls_manager.hpp"
47 #include "op_graph.hpp"
48 #include "structural_manager.hpp"
49 #include "technology_manager.hpp"
50 #include "technology_node.hpp"
51 #include "time_info.hpp"
52 #include "tree_helper.hpp"
53 #include "tree_manager.hpp"
54 #include "utility.hpp"
55 
56 OmpAllocation::OmpAllocation(const ParameterConstRef _Param, const HLS_managerRef _HLSMgr, unsigned int _funId,
57  const DesignFlowManagerConstRef _design_flow_manager)
58  : allocation(_Param, _HLSMgr, _funId, _design_flow_manager, HLSFlowStep_Type::OMP_ALLOCATION)
59 {
60  debug_level = parameters->get_class_debug_level(GET_CLASS(*this));
61 }
62 
64 
66 {
68  const FunctionBehaviorConstRef function_behavior = HLSMgr->CGetFunctionBehavior(funId);
69  const OpGraphConstRef op_graph = function_behavior->CGetOpGraph(FunctionBehavior::CFG);
70  VertexIterator operation, operation_end;
71  for(boost::tie(operation, operation_end) = boost::vertices(*op_graph); operation != operation_end; operation++)
72  {
73  const auto current_op = tree_helper::NormalizeTypename(op_graph->CGetOpNodeInfo(*operation)->GetOperation());
74  if(current_op == "panda_pthread_mutex")
75  {
76  const auto tn = TechM->get_fu("panda_pthread_mutex", OPENMP_LIBRARY);
77  if(not tn)
78  {
80  }
81  }
82  }
83 }
84 
86 {
87  const auto TreeM = HLSMgr->get_tree_manager();
89  std::string fu_name = "panda_pthread_mutex";
90  std::string op_name = "panda_pthread_mutex";
92  CM->set_top_info(fu_name, module_type);
93  const auto top = CM->get_circ();
95  GetPointer<module>(top)->set_description("Implementation of panda_pthread_mutex");
96  GetPointer<module>(top)->set_copyright("Copyright (C) 2012-2024 Politecnico di Milano");
97  GetPointer<module>(top)->set_authors("Marco Lattuada marco.lattuada@polimi.it");
98  GetPointer<module>(top)->set_license("PANDA_GPLv3");
99  CM->add_NP_functionality(top, NP_functionality::LIBRARY, "panda_pthread_mutex");
101  TechM->add_resource(OPENMP_LIBRARY, fu_name, CM);
102  TechM->add_operation(OPENMP_LIBRARY, fu_name, op_name);
103  const auto tn = TechM->get_fu(fu_name, OPENMP_LIBRARY);
104  auto* fu = GetPointer<functional_unit>(tn);
105  auto op = GetPointer<operation>(fu->get_operation(op_name));
106  op->time_m = time_info::factory(parameters);
107  fu->area_m = area_info::factory(parameters);
108  structural_type_descriptorRef boolean_type =
110  CM->add_port(START_PORT_NAME, port_o::IN, top, boolean_type);
111  const auto behavioral_helper =
112  HLSMgr->CGetFunctionBehavior(TreeM->GetFunction("panda_pthread_mutex")->index)->CGetBehavioralHelper();
113  size_t parameter_index = 0;
114  const auto function_parameters = behavioral_helper->get_parameters();
115  THROW_ASSERT(function_parameters.size() == 2, STR(function_parameters.size()));
116  for(const auto function_parameter : function_parameters)
117  {
118  CM->add_port(
119  parameter_index == 0 ? "mutex" : "locking", port_o::IN, top,
120  structural_type_descriptorRef(new structural_type_descriptor(function_parameter, behavioral_helper)));
121  parameter_index++;
122  }
123  parameter_index = 0;
124  for(const auto function_parameter : function_parameters)
125  {
126  CM->add_port(
127  parameter_index == 0 ? "out_mutex" : "out_locking", port_o::OUT, top,
128  structural_type_descriptorRef(new structural_type_descriptor(function_parameter, behavioral_helper)));
129  parameter_index++;
130  }
131  CM->add_port(DONE_PORT_NAME, port_o::OUT, top, boolean_type);
132 }
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
Data structure representing the entire HLS information.
void * top(node_stack *head)
Definition: tree.c:75
Collect information about resource area.
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
#define START_PORT_NAME
technology_nodeRef get_fu(const std::string &fu_name, const std::string &Library) const
Return the reference to a component given its name.
Structure representing the most relevant information about the type of a structural object...
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const structural_objectRef get_circ() const
Get a reference to circ field.
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
This class manages the circuit structures.
#define OPENMP_LIBRARY
OpenMP library.
Collect information about resource performance.
Class specification of the manager of the technology library data structures.
technology_nodeRef add_operation(const std::string &Library, const std::string &fu_name, const std::string &operation_name)
Add an operation to the specified functional unit.
~OmpAllocation() override
Destructor.
#define STR(s)
Macro which performs a lexical_cast to a string.
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
Definition: op_graph.hpp:843
static void add_NP_functionality(structural_objectRef cir, NP_functionality::NP_functionaly_type dt, std::string functionality_description)
Add a not-parsed functionality.
This class specifies the characteristic of a particular operation working on a given functional unit...
void set_top_info(const std::string &id, const technology_managerRef &LM, const std::string &Library="")
#define DONE_PORT_NAME
Control flow graph.
HLSFlowStep_Type
Definition: hls_step.hpp:95
Class specification of the data structures used to manage technology information. ...
static structural_objectRef add_port(const std::string &id, port_o::port_direction pdir, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port.
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Definition: graph.hpp:1307
static std::string NormalizeTypename(const std::string &id)
Return normalized name of types and variables.
const ParameterConstRef parameters
Set of input parameters.
void IntegrateTechnologyLibraries() override
Integrate technology libraries with special functional units.
This file collects some utility functions and macros.
This wrapper collects all the methods used by the High-level synthesis classes to retrieve informatio...
Definition: allocation.hpp:102
refcount< structural_manager > structural_managerRef
RefCount type definition of the structural_manager class structure.
This file collects some utility functions.
technology_managerRef TechM
The technology manager.
Definition: allocation.hpp:119
static area_infoRef factory(const ParameterConstRef &Param)
Factory method.
Definition: area_info.cpp:52
OmpAllocation(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
void AddPandaPthreadMutex()
Add the module implementing panda_pthread_mutex.
const OpGraphConstRef CGetOpGraph(FunctionBehavior::graph_type gt) const
This method returns the operation graphs.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
virtual void IntegrateTechnologyLibraries()
Integrate technology libraries with special functional units.
this class is used to manage the command-line or XML options.
Class implementation of the structural_manager.
int debug_level
The debug level.
This package is used by all HLS packages to manage resource constraints and characteristics.
static time_infoRef factory(const ParameterConstRef Param)
Definition: time_info.cpp:110
Class specification of the manager of the tree structures extracted from the raw file.
HLS specialization of generic_device.
A brief description of the C++ Header File.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

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