Commit 3981467b authored by mei-ye's avatar mei-ye
Browse files

make separated literal coloring a default

parent 477e6c47
......@@ -83,13 +83,6 @@ bool memory_coloring_impl::allocate(interval_ptr interval)
offset += (element_size - (offset % element_size));
conflict_queue.pop();
}
#if 1
if (interval->get_end() == latest_end_point) {
offset = required_bytes;
if((offset % element_size) != 0)
offset += (element_size - (offset % element_size));
}
#endif
segment.offset = offset;
MIGRAPH_DEBUG(segment.dump());
required_bytes = std::max(required_bytes, offset + segment.size);
......@@ -124,6 +117,7 @@ void memory_coloring_impl::build()
live_range& range = def_interval->segment;
def_interval->result = iter->result;
def_interval->is_literal = is_lit;
if(!is_lit || unify_literals)
alloc_queue.push(def_interval);
range.begin = cur_points;
def_interval->def_point = cur_points;
......@@ -172,7 +166,7 @@ void memory_coloring_impl::build()
live_set.insert(max_value_number);
live_ranges[max_value_number] = &(interval->segment);
earliest_end_point = cur_points;
if (latest_end_point == -1)
if(latest_end_point == -1)
latest_end_point = cur_points;
}
else
......@@ -219,6 +213,9 @@ void memory_coloring_impl::rewrite()
if(interval->get_begin() == invalid_offset)
continue;
if(!unify_literals && interval->is_literal)
continue;
std::size_t offset = 0;
if(interval->get_offset() == invalid_offset)
{
......
......@@ -50,7 +50,8 @@ using interval_ptr = live_interval*;
struct memory_coloring_impl
{
memory_coloring_impl(program* p, std::string alloc_op) : p_program(p), allocation_op(std::move(alloc_op))
memory_coloring_impl(program* p, std::string alloc_op)
: p_program(p), allocation_op(std::move(alloc_op))
{
instr2_live.clear();
live_ranges.clear();
......@@ -61,6 +62,7 @@ struct memory_coloring_impl
operand_alias.clear();
earliest_end_point = -1;
latest_end_point = -1;
unify_literals = false;
}
bool allocate(interval_ptr);
void add_conflicts(std::set<int>& live_set, int val)
......@@ -171,6 +173,8 @@ struct memory_coloring_impl
int earliest_end_point;
// The latest program point where an live interval ends.
int latest_end_point;
// Whether to unify literals into coloring.
bool unify_literals;
std::string allocation_op{};
};
} // namespace migraph
......
......@@ -31,7 +31,6 @@ std::vector<pass> target::get_passes(migraph::context& gctx) const
dead_code_elimination{},
lowering{ctx},
memory_coloring{"hip::allocate"},
lowering_memory_coloring{&ctx},
fuse_ops{},
dead_code_elimination{},
eliminate_workspace{},
......
......@@ -26,9 +26,6 @@ struct hip_load_literal
void write_literals::apply(program& p) const
{
if(!enabled(MIGRAPH_DISABLE_MEMORY_COLORING{}))
return;
assert(ctx != nullptr);
for(auto ins : iterator_for(p))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment