Commit 90fbe73a authored by Florian Fischer's avatar Florian Fischer
Browse files

pulse: improve option parsing and use microseconds as pulse

parent 840e1f14
Pipeline #80771 passed with stages
in 37 minutes and 39 seconds
......@@ -3,7 +3,9 @@
#include <boost/program_options.hpp>
#include <chrono>
#include <compare>
#include <cstdint>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <fstream> // IWYU pragma: keep
#include <iostream>
......@@ -20,8 +22,8 @@ namespace po = boost::program_options;
using Clock = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::time_point<Clock>;
// Pulse of new work in seconds
static unsigned pulse = 1;
// Pulse of new work in microseconds
static int64_t pulse = 1L * 1000 * 1000;
// Number of pulses
static unsigned iterations = 30;
// Utilization of the runtime in percent
......@@ -39,7 +41,7 @@ class Work {
Work() : start(Clock::now()) {}
void run() {
const auto deadline = Clock::now() + std::chrono::seconds(pulse);
const auto deadline = Clock::now() + std::chrono::microseconds(pulse);
while (Clock::now() < deadline) {
}
......@@ -68,19 +70,16 @@ static void pulser(Runtime& runtime) {
}
// TODO: better calculate the time until the next pulse
emper::sleep(pulse);
struct timespec ts {
.tv_sec = 0, .tv_nsec = pulse * 1000
};
emper::nanosleep(&ts);
}
cps.wait();
runtime.initiateTermination();
}
static auto eval(const po::variables_map& vm) -> int {
if (vm.count("pulse")) pulse = vm["pulse"].as<unsigned>();
if (vm.count("iterations")) iterations = vm["iterations"].as<unsigned>();
if (vm.count("utilization")) utilization = vm["utilization"].as<unsigned>();
std::cerr << "Starting pulse evaluation with pulse=" << pulse;
std::cerr << ", iterations=" << iterations;
std::cerr << " and utilization=" << utilization;
......@@ -129,9 +128,11 @@ auto main(int argc, char* argv[]) -> int {
// clang-format off
desc.add_options()
("help", "Show help")
("pulse", po::value<unsigned>(), "The pulse of new work")
("iterations", po::value<unsigned>(), "The number of pulses")
("utilization", po::value<unsigned>(), "The target utilization of the runtime")
("pulse", po::value<int64_t>(&pulse)->default_value(pulse), "The pulse of new work")
("iterations", po::value<unsigned>(&iterations)->default_value(iterations),
"The number of pulses")
("utilization", po::value<unsigned>(&utilization)->default_value(utilization),
"The target utilization of the runtime")
("latencies-file", po::value<std::string>(), "File to store all collected latencies")
;
// clang-format on
......
Supports Markdown
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