"vscode:/vscode.git/clone" did not exist on "b0b90270d8760957c154dce5c9e51fab9f0eaa09"
Commit 0721ddc1 authored by Paul's avatar Paul
Browse files

Formatting

parent d9fe1c6c
......@@ -15,24 +15,25 @@ void schedule::apply(program& p) const
std::unordered_map<instruction_ref, std::size_t> weights;
auto last = std::prev(p.end());
fix<std::size_t>([&](auto self, auto ins) -> std::size_t {
if (weights.count(ins) == 0)
if(weights.count(ins) == 0)
{
weights[ins] = std::accumulate(ins->inputs().begin(), ins->inputs().end(), model.weight(ins->get_operator()), [&](std::size_t w, instruction_ref i) {
return w + self(i);
});
weights[ins] =
std::accumulate(ins->inputs().begin(),
ins->inputs().end(),
model.weight(ins->get_operator()),
[&](std::size_t w, instruction_ref i) { return w + self(i); });
}
return weights[ins];
})(last);
// Topo sort
fix([&](auto self, auto ins) {
for(auto i:ins->inputs())
for(auto i : ins->inputs())
p.move_instruction(i, p.begin());
for(auto i:ins->inputs())
for(auto i : ins->inputs())
self(i);
})(last);
}
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......@@ -18,7 +18,10 @@ struct schedule_model
std::size_t n = 4;
std::size_t concurrency() const;
void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const;
void wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const;
void wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const;
std::size_t weight(const operation& op) const;
};
......
......@@ -6,18 +6,15 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
std::size_t schedule_model::concurrency() const
std::size_t schedule_model::concurrency() const { return n; }
void schedule_model::schedule_instruction(program& p, instruction_ref ins, std::size_t n) const {}
void schedule_model::wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const
{
return n;
}
void schedule_model::schedule_instruction(program& p, instruction_ref ins, std::size_t n) const
{}
void schedule_model::wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const
{}
std::size_t schedule_model::weight(const operation& op) const
{
return 1;
}
std::size_t schedule_model::weight(const operation& op) const { return 1; }
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -27,8 +27,11 @@ struct schedule_model
std::size_t concurrency() const;
/// Schedule a concurrent instruction
void schedule_instruction(program& p, instruction_ref ins, std::size_t n) const;
// Insert necessary waits before an instruction
void wait(program& p, instruction_ref ins, std::size_t wait_on, const std::vector<std::size_t>& wait_for) const;
// Insert necessary waits before an instruction
void wait(program& p,
instruction_ref ins,
std::size_t wait_on,
const std::vector<std::size_t>& wait_for) const;
/// Compute weights for an operation
std::size_t weight(const operation& op) const;
};
......
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