Commit 4886f3e8 authored by Paul's avatar Paul
Browse files

Formatting

parent f4059729
......@@ -6,7 +6,7 @@
#include <migraph/generate.hpp>
#include <migraph/verify.hpp>
migraph::program::parameter_map create_param_map(const migraph::program& p, bool gpu=true)
migraph::program::parameter_map create_param_map(const migraph::program& p, bool gpu = true)
{
migraph::program::parameter_map m;
for(auto&& x : p.get_parameter_shapes())
......@@ -24,7 +24,7 @@ int main(int argc, char const* argv[])
if(argc > 1)
{
std::string file = argv[1];
auto p = migraph::parse_onnx(file);
auto p = migraph::parse_onnx(file);
p.compile(migraph::gpu::target{});
auto m = create_param_map(p);
p.perf_report(std::cout, 10, m);
......
......@@ -313,41 +313,37 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
eval(params);
// Run and time entire program
double total_acc = 0;
for(std::size_t i = 0; i< n;i++)
for(std::size_t i = 0; i < n; i++)
{
total_acc += time<milliseconds>([&] {
eval(params);
});
total_acc += time<milliseconds>([&] { eval(params); });
}
std::unordered_map<const instruction*, double> ins_acc;
// Fill the map
generic_eval(*this, this->impl->ctx, params, [&](auto& ins, auto) {
ins_acc[std::addressof(ins)] = 0;
});
generic_eval(
*this, this->impl->ctx, params, [&](auto& ins, auto) { ins_acc[std::addressof(ins)] = 0; });
// Run and time each instruction
for(std::size_t i = 0; i< n;i++)
for(std::size_t i = 0; i < n; i++)
{
generic_eval(*this, this->impl->ctx, params, [&](auto& ins, auto f) {
ins_acc[std::addressof(ins)] += time<milliseconds>(f);
generic_eval(*this, this->impl->ctx, params, [&](auto& ins, auto f) {
ins_acc[std::addressof(ins)] += time<milliseconds>(f);
});
}
// Run and time implicit overhead
double overhead_acc = 0;
for(std::size_t i = 0; i< n;i++)
for(std::size_t i = 0; i < n; i++)
{
overhead_acc += time<milliseconds>([&] {
generic_eval(*this, this->impl->ctx, params, [](auto&&...) {});
});
overhead_acc += time<milliseconds>(
[&] { generic_eval(*this, this->impl->ctx, params, [](auto&&...) {}); });
}
double total_time = total_acc / n;
double overhead_time = overhead_acc / n;
double overhead_percent = overhead_time*100.0 / total_time;
double total_time = total_acc / n;
double overhead_time = overhead_acc / n;
double overhead_percent = overhead_time * 100.0 / total_time;
double total_instruction_time = 0.0;
for(auto&& p: ins_acc)
for(auto&& p : ins_acc)
total_instruction_time += p.second / n;
double calculate_overhead_time = total_time - total_instruction_time;
double calculate_overhead_percent = calculate_overhead_time*100.0 / total_time;
double calculate_overhead_time = total_time - total_instruction_time;
double calculate_overhead_percent = calculate_overhead_time * 100.0 / total_time;
print_program(os, *this, [&](auto& ins, auto&&) {
os << ": " << ins_acc[std::addressof(ins)] / n << "ms";
......@@ -355,10 +351,10 @@ void program::perf_report(std::ostream& os, std::size_t n, parameter_map params)
os << "Total time: " << total_time << "ms" << std::endl;
os << "Total instructions time: " << total_instruction_time << "ms" << std::endl;
os << "Overhead time: " << overhead_time << "ms" << ", " << calculate_overhead_time << "ms" << std::endl;
os << "Overhead: " << std::round(overhead_percent) << "%" << ", " << std::round(calculate_overhead_percent) << "%" << std::endl;
os << "Overhead time: " << overhead_time << "ms"
<< ", " << calculate_overhead_time << "ms" << std::endl;
os << "Overhead: " << std::round(overhead_percent) << "%"
<< ", " << std::round(calculate_overhead_percent) << "%" << std::endl;
}
bool operator==(const program& x, const program& y) { return to_string(x) == to_string(y); }
......
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