Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizioferrandi committed Apr 6, 2024
1 parent d12313f commit ef03699
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/BambuParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ void BambuParameter::PrintHelp(std::ostream& os) const
<< " The speculative SDC is more conservative, in case \n"
<< " --panda-parameter=enable-conservative-sdc=1 is passed.\n\n"
#endif
<< " --pipelining,-p\n"
<< " Perform functional pipelining starting from the top function.\n\n"
<< " --pipelining,-p=<func_name>[=<init_interval>][,<func_name>[=<init_interval>]]*\n"
<< " Perform pipelining of comma separated list of specified functions with optional \n"
<< " initiation interval (default II=1).\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ DesignFlowStep_Status chordal_coloring_register::RegisterBinding()
const auto vEnd = support.end();
for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
{
const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
const auto& live = HLS->Rliv->get_live_in(*vIt);
auto k_end = live.end();
for(auto k = live.begin(); k != k_end; ++k)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ void conflict_based_register::create_conflict_graph()
const auto vEnd = support.end();
for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
{
const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
const auto& live = HLS->Rliv->get_live_in(*vIt);
register_lower_bound = std::max(static_cast<unsigned int>(live.size()), register_lower_bound);
const CustomOrderedSet<unsigned int>::const_iterator k_end = live.end();
const auto k_end = live.end();
for(auto k = live.begin(); k != k_end; ++k)
{
auto k_inner = k;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ DesignFlowStep_Status vertex_coloring_register::RegisterBinding()
const auto vEnd = support.end();
for(auto vIt = support.begin(); vIt != vEnd; ++vIt)
{
const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
const auto& live = HLS->Rliv->get_live_in(*vIt);
auto k_end = live.end();
for(auto k = live.begin(); k != k_end; ++k)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ DesignFlowStep_Status weighted_clique_register::RegisterBinding()
{
if(clique_covering_algorithm == CliqueCovering_Algorithm::BIPARTITE_MATCHING)
{
const std::list<vertex>& support = HLS->Rliv->get_support();
const auto& support = HLS->Rliv->get_support();
unsigned current_partition = 0;
for(auto vState : support)
{
const CustomOrderedSet<unsigned int>& live = HLS->Rliv->get_live_in(vState);
const auto& live = HLS->Rliv->get_live_in(vState);
for(auto l : live)
{
unsigned int sv = HLS->storage_value_information->get_storage_value_index(vState, l);
Expand Down Expand Up @@ -175,7 +175,7 @@ DesignFlowStep_Status weighted_clique_register::RegisterBinding()
HLS->Rreg = reg_binding::create_reg_binding(HLS, HLSMgr);
for(const auto v : HLS->Rliv->get_support())
{
for(const auto k : HLS->Rliv->get_live_in(v))
for(const auto& k : HLS->Rliv->get_live_in(v))
{
unsigned int storage_value_index = HLS->storage_value_information->get_storage_value_index(v, k);
HLS->Rreg->bind(storage_value_index, v2c[verts[storage_value_index]]);
Expand Down Expand Up @@ -207,6 +207,7 @@ DesignFlowStep_Status weighted_clique_register::RegisterBinding()
(num_registers == register_lower_bound ? "" : ("(LB:" + STR(register_lower_bound) + ")")));
if(output_level >= OUTPUT_LEVEL_VERY_PEDANTIC)
{
THROW_ASSERT(HLS->Rreg, "unexpected condition");
HLS->Rreg->print();
}
if(output_level >= OUTPUT_LEVEL_MINIMUM && output_level <= OUTPUT_LEVEL_PEDANTIC)
Expand Down
8 changes: 4 additions & 4 deletions src/HLS/binding/register/reg_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void reg_binding::compute_is_without_enable()
{
const auto dummy_offset = HLS->Rliv->is_a_dummy_state(v) ? 1U : 0U;
const auto& live_in = HLS->Rliv->get_live_in(v);
for(const auto li : live_in)
for(const auto& li : live_in)
{
if(n_in.find(li) == n_in.end())
{
Expand All @@ -202,7 +202,7 @@ void reg_binding::compute_is_without_enable()
}
}
const auto& live_out = HLS->Rliv->get_live_out(v);
for(const auto lo : live_out)
for(const auto& lo : live_out)
{
if(!n_out.count(lo))
{
Expand All @@ -222,8 +222,8 @@ void reg_binding::compute_is_without_enable()
for(auto i = 0U; i < get_used_regs(); i++)
{
const auto all_woe = [&]() {
const auto store_vars_set = get_vars(i);
for(const auto sv : store_vars_set)
const auto& store_vars_set = get_vars(i);
for(const auto& sv : store_vars_set)
{
if(n_in.find(sv) == n_in.end() || n_in.find(sv)->second != 1 || n_out.find(sv) == n_out.end() ||
n_out.find(sv)->second != 1)
Expand Down
1 change: 1 addition & 0 deletions src/HLS/hls_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @brief Data structure representing the entire HLS information
*
* @author Christian Pilato <pilato@elet.polimi.it>
* @author Fabrizio Ferrandi <fabrizio.ferrandi@polimi.it>
* $Revision$
* $Date$
* Last modified by $Author$
Expand Down
2 changes: 1 addition & 1 deletion src/HLS/module_allocation/allocation_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ void AllocationInformation::GetNodeTypePrec(const vertex node, const OpGraphCons
info->real_output_nelem = 0;
info->base128_output_nelem = 0;
}
if(current_op == "cond_expr" && max_size_in > 64 && info->node_kind == "VECTOR_BOOL")
if(current_op == "cond_expr" && max_size_in > 64)
{
max_size_in = 64;
}
Expand Down
9 changes: 3 additions & 6 deletions src/HLS/virtual_components/commandport_obj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class commandport_obj : public generic_obj
SWITCH, /// switch value, it represents the value of the switch statement
MULTIIF, /// represents the multi conditions
SELECTOR, /// mux selector
ALUSELECTOR, /// ALU selector
UNBOUNDED, /// signal representing a communication for an unbounded object (function call)
UNBOUNDED, /// signal representing a communication for an unbounded object (function call)
MULTI_UNBOUNDED, /// signal representing when a multi unbounded call ends
MULTI_UNBOUNDED_ENABLE, /// signal enabling the multi unbounded component
WRENABLE /// enable for register writing
Expand Down Expand Up @@ -123,8 +122,7 @@ class commandport_obj : public generic_obj
commandport_obj(generic_objRef _elem, unsigned int _mode, const std::string& _name)
: generic_obj(COMMAND_PORT, _name), elem(_elem), mode(_mode), is_a_phi_write_enable(false)
{
THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == ALUSELECTOR or mode == MULTI_UNBOUNDED or
mode == MULTI_UNBOUNDED_ENABLE,
THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == MULTI_UNBOUNDED or mode == MULTI_UNBOUNDED_ENABLE,
"Selector port is wrong");
}

Expand Down Expand Up @@ -183,8 +181,7 @@ class commandport_obj : public generic_obj

const generic_objRef& get_elem() const
{
THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == ALUSELECTOR || mode == MULTI_UNBOUNDED or
mode == MULTI_UNBOUNDED_ENABLE,
THROW_ASSERT(mode == SELECTOR || mode == WRENABLE || mode == MULTI_UNBOUNDED or mode == MULTI_UNBOUNDED_ENABLE,
"Selector port is wrong");
return elem;
}
Expand Down
4 changes: 0 additions & 4 deletions src/behavior/behavioral_writer_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ void OpEdgeWriter::operator()(std::ostream& out, const EdgeDescriptor& e) const
{
out << "[color=gold";
}
else if((FB_DFG_SELECTOR)&selector & printing_graph->GetSelector(e))
{
out << "[color=lightblue";
}
else if((FLG_SELECTOR)&selector & printing_graph->GetSelector(e))
{
out << "[color=red3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ class BasicBlocksProfilingCWriter final : public EdgeCWriter
* Dump operations requested for record information about a loop path which ends
* @param e is the feedback or outgoing edge
*/
void print_loop_ending(EdgeDescriptor e) override;
void print_loop_ending(EdgeDescriptor e) final;

/**
* Dump operations requested for record information about a path which exit from a loop
* @param e is the feedback or outgoing edge
*/
void print_loop_escaping(EdgeDescriptor e) override;
void print_loop_escaping(EdgeDescriptor e) final;

/**
* Dump initializations of variable for recording a loop path
* @param e is the incoming edged
*/
void print_loop_starting(EdgeDescriptor e) override;
void print_loop_starting(EdgeDescriptor e) final;

/**
* Dump operation requested for instrument an edges
* @param e is the edge
* @param index is the index of the variable to be incremented
*/
void print_edge(EdgeDescriptor e, unsigned int index) override;
void print_edge(EdgeDescriptor e, unsigned int index) final;

/**
* Print operation requested for record information about a path which exit from a loop and immediately enter in
* another
* @param e is the edge
*/
void print_loop_switching(EdgeDescriptor e) override;
void print_loop_switching(EdgeDescriptor e) final;

void InternalWriteGlobalDeclarations() final;

Expand Down
24 changes: 14 additions & 10 deletions src/frontend_analysis/IR_analysis/loops_analysis_bambu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ DesignFlowStep_Status LoopsAnalysisBambu::InternalExec()
}
#endif
const auto nexit = loop->num_exits();
if(nexit != 1)
if(nexit == 0)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Multiple exits loop");
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--No loop");
continue;
}
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Single exit loop considered");
loop->loop_type |= SINGLE_EXIT_LOOP;
if(nexit == 1)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Single exit loop considered");
loop->loop_type |= SINGLE_EXIT_LOOP;
}
const auto exit_vertex = *loop->exit_block_iter_begin();
bool do_while = false;
if(exit_vertex == header && loop->num_blocks() != 1)
Expand All @@ -150,6 +153,12 @@ DesignFlowStep_Status LoopsAnalysisBambu::InternalExec()
loop->loop_type |= DO_WHILE_LOOP;
do_while = true;
}
/// very simple condition
if(do_while && loop->is_innermost() && loop->num_blocks() == 1)
{
loop->loop_type |= PIPELINABLE_LOOP;
}

/// Get exit condition of the loop
const tree_nodeRef last_stmt = GET_NODE(fbb->CGetBBNodeInfo(exit_vertex)->block->CGetStmtList().back());
if(last_stmt->get_kind() != gimple_cond_K)
Expand Down Expand Up @@ -326,9 +335,9 @@ DesignFlowStep_Status LoopsAnalysisBambu::InternalExec()
"---Comparison is " + STR(cond) + " (" + cond->get_kind_text() + ")");
if(GET_NODE(init)->get_kind() == integer_cst_K && GET_NODE(cond_be->op1)->get_kind() == integer_cst_K)
{
const auto cond_type = cond_be->get_kind();
loop->lower_bound = tree_helper::GetConstValue(init);
loop->upper_bound = tree_helper::GetConstValue(cond_be->op1);
const auto cond_type = cond_be->get_kind();
if(cond_type == ge_expr_K || cond_type == le_expr_K || cond_type == unge_expr_K || cond_type == unle_expr_K)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Close interval");
Expand All @@ -343,11 +352,6 @@ DesignFlowStep_Status LoopsAnalysisBambu::InternalExec()
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Bound " + GET_NODE(loop->upper_bound_tn)->ToString());
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Increment " + GET_NODE(loop->increment_tn)->ToString());
/// very simple condition
if(do_while && loop->is_innermost() && loop->num_blocks() == 1)
{
loop->loop_type |= PIPELINABLE_LOOP;
}

return_value = DesignFlowStep_Status::SUCCESS;
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Analyzed loop " + STR(loop->GetId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,12 @@ DesignFlowStep_Status DataDependenceComputation::Computedependencies(const int d
function_behavior->ogc->add_edge_info(this_def, *vi, DFG_SELECTOR, local_use);
if(function_behavior->CheckFeedbackReachability(*vi, this_def))
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding fb_adg_selector dependence " + GET_NAME(cfg, *vi) + "-->" +
GET_NAME(cfg, this_def));
function_behavior->ogc->AddEdge(*vi, this_def, fb_adg_selector);
/// NOTE: label associated with forward selector also on feedback edge
function_behavior->ogc->add_edge_info(this_def, *vi, ADG_SELECTOR, local_use);
function_behavior->ogc->add_edge_info(*vi, this_def, ADG_SELECTOR, local_use);
}
}

Expand All @@ -275,19 +278,30 @@ DesignFlowStep_Status DataDependenceComputation::Computedependencies(const int d
GET_NAME(cfg, *vi));
if(*vi != this_def)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding adg_selector dependence " + GET_NAME(cfg, *vi) + "-->" +
GET_NAME(cfg, this_def));
function_behavior->ogc->AddEdge(*vi, this_def, adg_selector);
function_behavior->ogc->add_edge_info(*vi, this_def, ADG_SELECTOR, local_use);
}
if(function_behavior->CheckFeedbackReachability(this_def, *vi))
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding fb_dfg_selector dependence " + GET_NAME(cfg, this_def) + "-->" +
GET_NAME(cfg, *vi));
function_behavior->ogc->AddEdge(this_def, *vi, fb_dfg_selector);
/// NOTE: label associated with forward selector also on feedback edge
/// NOTE: label associated with forward selector also on feedback edgeADG_SELECTOR
/// (ADG_SCA_SELECTADG_SELECTOR (ADG_SCA_SELECTOR | ADG_AGG_SELECTOR) FeedOR | ADG_AGG_SELECTOR)
/// Feed
function_behavior->ogc->add_edge_info(this_def, *vi, DFG_SELECTOR, local_use);
}
}

if(*vi == this_def)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding2 fb_dfg_selector dependence " + GET_NAME(cfg, *vi) + "-->" +
GET_NAME(cfg, *vi));
function_behavior->ogc->AddEdge(*vi, *vi, fb_dfg_selector);
function_behavior->ogc->add_edge_info(*vi, *vi, DFG_SELECTOR, local_use);
}
Expand All @@ -301,7 +315,8 @@ DesignFlowStep_Status DataDependenceComputation::Computedependencies(const int d
if(dependence)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding anti dependence " + GET_NAME(cfg, *vi) + "-->" + GET_NAME(cfg, this_over));
"---Adding adg_selector dependence " + GET_NAME(cfg, *vi) + "-->" +
GET_NAME(cfg, this_over));
function_behavior->ogc->AddEdge(*vi, this_over, adg_selector);
function_behavior->ogc->add_edge_info(*vi, this_over, ADG_SELECTOR, local_use);
}
Expand All @@ -322,10 +337,15 @@ DesignFlowStep_Status DataDependenceComputation::Computedependencies(const int d
const bool forward_dependence = function_behavior->CheckReachability(this_def, *vi);
if(forward_dependence)
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding output dependence " + GET_NAME(cfg, this_def) + "-->" + GET_NAME(cfg, *vi));
function_behavior->ogc->AddEdge(this_def, *vi, ODG_AGG_SELECTOR);
function_behavior->ogc->add_edge_info(this_def, *vi, ODG_SELECTOR, local_def);
if(function_behavior->CheckFeedbackReachability(*vi, this_def))
{
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Adding FB_ODG_AGG_SELECTOR dependence " + GET_NAME(cfg, *vi) + "-->" +
GET_NAME(cfg, this_def));
function_behavior->ogc->AddEdge(*vi, this_def, FB_ODG_AGG_SELECTOR);
/// NOTE: label associated with forward selector also on feedback edge
function_behavior->ogc->add_edge_info(*vi, this_def, ODG_SELECTOR, local_def);
Expand Down
2 changes: 1 addition & 1 deletion src/utility/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ constexpr void string_to_container(_OutputIt first, const std::string& str, cons
}
last += _len + 1;
curr += _len + 1;
} while(last < str.size());
} while(last <= str.size());
}

template <typename _Container>
Expand Down

0 comments on commit ef03699

Please sign in to comment.