MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / build_conflict_table

Function build_conflict_table

src/memory_coloring.cpp:50–79  ·  view source on GitHub ↗

This will build the conflict table or interference graph. This is essentially a map from one instruction to a set of instruction that are used together. Each instruction will be the allocation instruction.

Source from the content-addressed store, hash-verified

48// essentially a map from one instruction to a set of instruction that are
49// used together. Each instruction will be the allocation instruction.
50static instruction_set_map build_conflict_table(const module& m, std::string allocation_op)
51{
52 instruction_set_map conflict_table;
53 liveness(m, [&](auto ins, const auto& live_set) {
54 // Skip variables that aren't allocations
55 if(ins->name() != allocation_op)
56 return;
57 // Skip zero allocations
58 if(ins->get_shape().bytes() == 0)
59 return;
60 conflict_table[ins];
61 for(auto i : live_set)
62 {
63 if(i == ins)
64 continue;
65 // Skip variables that aren't allocations
66 if(i->name() != allocation_op)
67 continue;
68 // Skip zero allocations
69 if(i->get_shape().bytes() == 0)
70 continue;
71 conflict_table[i].insert(ins);
72 conflict_table[ins].insert(i);
73 }
74 });
75 assert(std::all_of(conflict_table.begin(), conflict_table.end(), [](auto&& pp) {
76 return pp.second.count(pp.first) == 0;
77 }));
78 return conflict_table;
79}
80
81// Check if intervals overlap
82static bool is_overlap(std::pair<std::size_t, std::size_t> x, std::pair<std::size_t, std::size_t> y)

Callers 1

applyMethod · 0.85

Calls 8

livenessFunction · 0.85
all_ofFunction · 0.50
nameMethod · 0.45
bytesMethod · 0.45
get_shapeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected