("num_runs,r", po::value<int>()->default_value(1), "The number of runs")
("warmup_runs,w", po::value<int>()->default_value(0), "The number of warmup runs")
("gpumem_poll,g", po::value<bool>()->default_value(false), "Check gpu memory polling separately")
+ ("mem_poll,m", po::value<bool>()->default_value(false), "Check memory polling")
+ ("write_report,p", po::value<bool>()->default_value(false), "Write report")
;
// clang-format on
{
_gpumem_poll = vm["gpumem_poll"].as<bool>();
}
+
+ if (vm.count("mem_poll"))
+ {
+ _mem_poll = vm["mem_poll"].as<bool>();
+ }
+
+ if (vm.count("write_report"))
+ {
+ _write_report = vm["write_report"].as<bool>();
+ }
}
} // end of namespace NNPackageRun
NNPackageRun::Args args(argc, argv);
auto nnpackage_path = args.getPackageFilename();
- benchmark::MemoryPoller mp(std::chrono::milliseconds(5), args.getGpuMemoryPoll());
- std::vector<uint32_t> mp_results;
+ std::unique_ptr<benchmark::MemoryPoller> mp{nullptr};
+ if (args.getMemoryPoll())
+ {
+ try
+ {
+ mp.reset(new benchmark::MemoryPoller(std::chrono::milliseconds(5), args.getGpuMemoryPoll()));
+ }
+ catch (const std::runtime_error &error)
+ {
+ std::cerr << error.what() << std::endl;
+ return 1;
+ }
+ }
+
+ std::vector<uint32_t> mp_results({0, 0});
nnfw_session *session = nullptr;
NNPR_ENSURE_STATUS(nnfw_create_session(&session));
// prepare execution
// TODO When nnfw_{prepare|run} are failed, can't catch the time
- mp.Start("Compiling");
+ if (mp)
+ mp->Start("Compiling");
uint64_t prepare_us = benchmark::NowMicros();
NNPR_ENSURE_STATUS(nnfw_prepare(session));
prepare_us = benchmark::NowMicros() - prepare_us;
- mp_results.emplace_back(mp.End("Compiling"));
+ if (mp)
+ mp_results[0] = mp->End("Compiling");
// prepare input
}
// poll memories before warming up
- mp.Start("Executing");
+ if (mp)
+ mp->Start("Executing");
uint64_t run_us = benchmark::NowMicros();
NNPR_ENSURE_STATUS(nnfw_run(session));
run_us = benchmark::NowMicros() - run_us;
- mp_results.emplace_back(mp.End("Executing"));
+ if (mp)
+ mp_results[1] = mp->End("Executing");
// warmup runs
for (uint32_t i = 1; i < args.getWarmupRuns(); i++)
std::cout << "- Max: " << acc.max() / 1e3 << "ms" << std::endl;
std::cout << "- Mean: " << acc.mean() / 1e3 << "ms" << std::endl;
- assert(mp_results.size() == 2);
- std::cout << "===================================" << std::endl;
- std::cout << "nnfw_prepare takes " << mp_results[0] << " kb" << std::endl;
- std::cout << "nnfw_run takes " << mp_results[1] << " kb" << std::endl;
+ if (mp)
+ {
+ assert(mp_results.size() == 2);
+ std::cout << "===================================" << std::endl;
+ std::cout << "nnfw_prepare takes " << mp_results[0] << " kb" << std::endl;
+ std::cout << "nnfw_run takes " << mp_results[1] << " kb" << std::endl;
+ }
std::cout << "===================================" << std::endl;
}
+ if (args.getWriteReport() == false)
+ return 0;
+
// prepare csv task
std::string csv_filename;
std::string model_name;