48 #include "config_HAVE_HOST_PROFILING_BUILT.hpp" 56 #if HAVE_HOST_PROFILING_BUILT 77 const auto function_behavior =
HLSMgr.
lock()->CGetFunctionBehavior(
funId);
84 std::list<vertex>::const_iterator i, i_end;
100 os <<
"< " <<
name <<
" | { ";
104 const auto first_index = op_function_graph->CGetOpNodeInfo(op)->GetNodeId();
106 const bool critical = critical_paths.find(first_index) != critical_paths.end();
107 if(detail_level == 0)
111 os <<
"<font color=\"gold2\">";
115 os <<
"<font color=\"red3\">";
119 os <<
"<font color=\"blue\">";
122 const auto first_starting_time = schedule->GetStartingTime(first_index);
123 const auto first_ending_time = schedule->GetEndingTime(first_index);
124 if(detail_level == 0)
128 <<
NumberToString(first_ending_time - first_starting_time, 2, 7) <<
")" 131 std::string vertex_print = BH->
print_vertex(op_function_graph, op, vpp,
true);
132 boost::replace_all(vertex_print,
"&",
"&");
133 boost::replace_all(vertex_print,
"|",
"\\|");
134 boost::replace_all(vertex_print,
">",
">");
135 boost::replace_all(vertex_print,
"<",
"<");
136 boost::replace_all(vertex_print, R
"(\\")", "\"");
137 boost::replace_all(vertex_print,
"\\\"",
""");
138 boost::replace_all(vertex_print,
":",
":");
139 boost::replace_all(vertex_print,
"\\n",
"");
140 boost::replace_all(vertex_print,
"{",
"\\{");
141 boost::replace_all(vertex_print,
"}",
"\\}");
143 if(detail_level == 0)
151 os <<
"<br align=\"left\"/>";
158 const auto first_index = op_function_graph->CGetOpNodeInfo(op)->GetNodeId();
159 const auto critical = critical_paths.find(first_index) != critical_paths.end();
160 if(std::find(executing_operations.begin(), executing_operations.end(), op) == executing_operations.end())
162 os <<
"<font color=\"green2\">";
166 os <<
"<font color=\"red3\">";
170 os <<
"<font color=\"blue\">";
172 const auto first_starting_time = schedule->GetStartingTime(first_index);
173 const auto first_ending_time = schedule->GetEndingTime(first_index);
176 <<
NumberToString(first_ending_time - first_starting_time, 2, 7) <<
")" 178 std::string vertex_print = BH->
print_vertex(op_function_graph, op, vpp,
true);
179 boost::replace_all(vertex_print,
"&",
"&");
180 boost::replace_all(vertex_print,
"|",
"\\|");
181 boost::replace_all(vertex_print,
">",
">");
182 boost::replace_all(vertex_print,
"<",
"<");
183 boost::replace_all(vertex_print, R
"(\\")", "\"");
184 boost::replace_all(vertex_print,
"\\\"",
""");
185 boost::replace_all(vertex_print,
"\\n",
"");
186 boost::replace_all(vertex_print,
":",
":");
187 boost::replace_all(vertex_print,
"{",
"\\{");
188 boost::replace_all(vertex_print,
"}",
"\\}");
191 std::find(executing_operations.begin(), executing_operations.end(), op) == executing_operations.end() or
196 os <<
"<br align=\"left\"/>";
205 for(
const auto& bb_i :
BB_ids)
207 os << bb_i <<
" <br align=\"left\"/>";
214 #if HAVE_HOST_PROFILING_BUILT 215 if(function_behavior->CGetProfilingInformation() and
BB_ids.size() == 1 && detail_level == 0)
217 const auto BB_id = *(
BB_ids.begin());
218 const auto BB_vertex =
219 function_behavior->CGetBBGraph(
FunctionBehavior::BB)->CGetBBGraphInfo()->bb_index_map.find(BB_id)->second;
220 const auto bb_executions = function_behavior->CGetProfilingInformation()->GetBBExecutions(BB_vertex);
223 os <<
"<br/>Executed " <<
STR(bb_executions) <<
" times";
240 if(detail_level == 0)
242 os <<
GET_NAME(op_function_graph, get_operation()) <<
"(T)\\n";
251 if(detail_level == 0)
253 os <<
GET_NAME(op_function_graph, get_operation()) <<
"(F)\\n";
262 auto op = get_operation();
263 if(detail_level == 0)
265 os <<
GET_NAME(op_function_graph, op);
270 for(
auto label : labels)
279 os <<
"," << BH->
PrintNode(label, op, std);
302 os <<
GET_NAME(op_function_graph, op);
307 os <<
"," <<
GET_NAME(op_function_graph, op);
310 os <<
"(ALL_FINISHED)\\n";
319 os <<
GET_NAME(op_function_graph, op);
324 os <<
"," <<
GET_NAME(op_function_graph, op);
327 os <<
"(NOT_ALL_FINISHED)\\n";
333 if(epp_incrementValid)
335 os <<
"epp: " << epp_increment <<
"\\n";
352 : op_function_graph(_op_function_graph),
372 :
graph(state_transition_graphs_collection.get(), _selector)
378 :
graph(state_transition_graphs_collection.get(), _selector, _sub)
386 const auto output_directory =
collection->
parameters->getOption<std::string>(OPT_dot_directory);
389 for(boost::tie(state, state_end) = boost::vertices(*
this); state != state_end; state++)
392 const auto critical_path =
393 si->HLSMgr.lock()->get_HLS(si->funId)->Rsch->ComputeCriticalPath(
CGetStateInfo(*state));
394 critical_paths.insert(critical_path.begin(), critical_path.end());
396 if(!std::filesystem::exists(output_directory))
398 std::filesystem::create_directories(output_directory);
401 const std::string function_name = op_function_graph->
CGetOpGraphInfo()->BH->get_function_name();
402 const std::string complete_file_name = output_directory + function_name +
"/";
403 if(!std::filesystem::exists(complete_file_name))
405 std::filesystem::create_directories(complete_file_name);
407 const VertexWriterConstRef state_writer(
new StateWriter(
this, op_function_graph, detail_level));
408 const EdgeWriterConstRef transition_writer(
new TransitionWriter(
this, op_function_graph, detail_level));
409 InternalWriteDot<const StateWriter, const TransitionWriter>(complete_file_name + file_name, state_writer,
412 for(boost::tie(state, state_end) = boost::vertices(*
this); state != state_end; state++)
420 state_ops.insert(state_info->starting_operations.begin(), state_info->starting_operations.end());
421 state_ops.insert(state_info->ending_operations.begin(), state_info->ending_operations.end());
422 const auto st_op_graph = state_info->HLSMgr.lock()->CGetFunctionBehavior(state_info->funId)->CGetOpGraph(
FunctionBehavior::DFG, state_ops);
423 auto st_file_name = file_name.substr(0, file_name.find(
".dot"));
424 st_op_graph->WriteDot(st_file_name +
"_" + state_info->name +
".dot", state_info->HLSMgr.lock()->get_HLS(state_info->funId), state_info->HLSMgr.lock()->get_HLS(state_info->funId)->Rsch->ComputeCriticalPath(state_info));
431 BH(_op_function_graph->CGetOpGraphInfo()->BH),
432 op_function_graph(_op_function_graph),
444 out <<
"color=blue,shape=Msquare,";
448 out <<
"shape=record,";
457 BH(_op_function_graph->CGetOpGraphInfo()->
BH),
464 const auto* temp = Cget_edge_info<TransitionInfo>(e, *
printing_graph);
467 out <<
"[color=red3";
471 out <<
"[color=green2";
475 out <<
"[color=blue";
CustomOrderedSet< unsigned int > BB_ids
set of BB ids associated with the state
int GetSelector() const
Return the selector of this graph.
Data structure representing the entire HLS information.
virtual std::string PrintNode(const tree_nodeConstRef &node, vertex v, const var_pp_functorConstRef vppf) const
Print the operations corresponding to the node.
#define GET_TYPE(data, vertex_index)
Helper macro returning the type associated with a node.
const int detail_level
The detail level.
void operator()(std::ostream &out, const EdgeDescriptor &e) const override
Functor actually called by the boost library to perform the writing.
Basic block control flow graph.
const ParameterConstRef parameters
Set of input parameters.
const graph * printing_graph
The graph to be printed.
vertex exit_node
vertex that contains exit node
Simple pretty print functor.
void print(std::ostream &os, const int detail_level) const override
Implementation of print method for this kind of node.
vertex entry_node
vertex that contains entry node
StateTransitionGraphInfo(const OpGraphConstRef op_function_graph)
Constructor.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
std::string NumberToString(const T number, const size_t precision, const size_t size)
Function with print number in desired format.
Definition of hash function for EdgeDescriptor.
~StateTransitionGraph() override
Destructor.
~StateTransitionGraphsCollection() override
Destructor.
const OpGraphConstRef op_function_graph
reference to operation graph
A set of operation vertices.
vertex get_ref_state() const
std::list< vertex > executing_operations
set of operation vertices which require inputs in this state
#define STR(s)
Macro which performs a lexical_cast to a string.
unsigned int funId
function identifier of the function from which the state has been derived
StateTransitionGraphsCollection(const StateTransitionGraphInfoRef state_transition_graph_info, const ParameterConstRef parameters)
Constructor.
const graph * printing_graph
The graph to be printed.
#define TYPE_EXIT
constant identifying the node type of an exit node.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Standard functor that returns the name of a variable.
Data structure used to store the schedule of the operations.
refcount< const StateInfo > StateInfoConstRef
Functor used to write the content of a vertex to dotty file.
const StateTransitionGraphInfoConstRef CGetStateTransitionGraphInfo() const
Return the info associated with the graph.
vertex get_operation() const
const OpGraphInfoConstRef CGetOpGraphInfo() const
Returns the property associated with the graph.
#define TYPE_STORE
Constant string identifying a memory store operation.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
This file contains the structures needed to manage a graph that will represent the state transition g...
General class used to describe a graph in PandA.
Functor used to write the content of the edges to a dotty file and it is used to write specific edge ...
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
const int detail_level
The detail level.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
void print(std::ostream &os, const int detail_level) const
Print the information associated with the edge of the graph.
void WriteDot(const std::string &file_name, const int detail_level=0) const
Writes this graph in dot format.
StateWriter(const graph *_stg, const OpGraphConstRef _op_function_graph, int _detail_level)
Constructor.
std::string print_vertex(const OpGraphConstRef g, const vertex v, const var_pp_functorConstRef vppf, const bool dot=false) const
Print the operations corrisponding to the vertex.
refcount< T > lock() const
std::string name
string used to give a label to the state
Functor used to write the content of the edges to a dotty file.
const GraphInfoConstRef CGetGraphInfo() const
FIXME: this method should become protected and called by equivalent method in subclasses Get the grap...
std::list< vertex > ending_operations
set of operation vertices completing their execution in this state
T * GetPointer(const refcount< U > &t)
Template function used to hide dynamic_cast The template parameter T represents a type of an object h...
Data structures used in operations graph.
Wrefcount< const HLS_manager > HLSMgr
Weak Reference to function behavior.
StateTransitionGraph(const StateTransitionGraphsCollectionRef state_transition_graphs_collection, int selector)
Standard constructor.
this class is used to manage the command-line or XML options.
void operator()(std::ostream &out, const vertex &v) const override
Functor actually called by the boost library to perform the writing.
#define TYPE_ENTRY
constant identifying the node type of an entry node.
graphs_collection * collection
The graph collection.
refcount< const var_pp_functor > var_pp_functorConstRef
TransitionWriter(const graph *stg, const OpGraphConstRef op_function_graph, int _detail_level)
Constructor.
const BehavioralHelperConstRef BH
this is the helper associated to the actual module
Data structure definition for high-level synthesis flow.
Structure holding information about the whole graph.
const StateInfoConstRef CGetStateInfo(const vertex state) const
Return the info associated with a state.
#define NULL_VERTEX
null vertex definition
Functor template used to write the content of the nodes to a dotty file.
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...