Include core allocation in time measurement.

This commit is contained in:
Michael Mueller
2024-10-14 15:15:13 +02:00
parent 7a2bce669b
commit f34f8948f0
3 changed files with 31 additions and 17 deletions

View File

@@ -4,6 +4,9 @@
#include <json.hpp> #include <json.hpp>
#include <memory> #include <memory>
#include <mx/memory/global_heap.h> #include <mx/memory/global_heap.h>
#include <runtime/thread.h>
#define SHENANGO
using namespace application::blinktree_benchmark; using namespace application::blinktree_benchmark;
@@ -26,6 +29,7 @@ Benchmark::Benchmark(benchmark::Cores &&cores, const std::uint16_t iterations, s
//this->_chronometer.add(benchmark::Perf::STALLS_MEM_ANY); //this->_chronometer.add(benchmark::Perf::STALLS_MEM_ANY);
//this->_chronometer.add(benchmark::Perf::SW_PREFETCH_ACCESS_NTA); //this->_chronometer.add(benchmark::Perf::SW_PREFETCH_ACCESS_NTA);
//this->_chronometer.add(benchmark::Perf::SW_PREFETCH_ACCESS_WRITE); //this->_chronometer.add(benchmark::Perf::SW_PREFETCH_ACCESS_WRITE);
this->_chronometer.add(benchmark::Perf::L1_MISSES);
this->_chronometer.add(benchmark::Perf::LLC_MISSES); this->_chronometer.add(benchmark::Perf::LLC_MISSES);
this->_chronometer.add(benchmark::Perf::DTLB_READ_MISSES); this->_chronometer.add(benchmark::Perf::DTLB_READ_MISSES);
this->_chronometer.add(benchmark::Perf::DTLB_STORE_MISSES); this->_chronometer.add(benchmark::Perf::DTLB_STORE_MISSES);
@@ -79,6 +83,7 @@ void Benchmark::start()
{ {
mx::tasking::runtime::profile(this->profile_file_name()); mx::tasking::runtime::profile(this->profile_file_name());
} }
//this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)), //this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
// this->_current_iteration + 1, this->_cores.current()); // this->_current_iteration + 1, this->_cores.current());
} }
@@ -120,8 +125,8 @@ void Benchmark::requests_finished()
if (open_requests == 0U) // All request schedulers are done. if (open_requests == 0U) // All request schedulers are done.
{ {
std::uint16_t core_id = mx::system::topology::core_id(); auto core_id = get_current_affinity();
/*if (core_id != 0) { /* if (core_id != start_core) {
this->_open_requests++; this->_open_requests++;
auto *stop_task = mx::tasking::runtime::new_task<StopMeasurementTask>(0U, *this); auto *stop_task = mx::tasking::runtime::new_task<StopMeasurementTask>(0U, *this);
stop_task->annotate(static_cast<mx::tasking::TaskInterface::channel>(0)); stop_task->annotate(static_cast<mx::tasking::TaskInterface::channel>(0));
@@ -209,11 +214,21 @@ void Benchmark::requests_finished()
this->_tree.reset(nullptr); this->_tree.reset(nullptr);
} }
if (this->core_set())
{
this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
this->_current_iteration + 1, this->_cores.current());
auto *restart_task = mx::tasking::runtime::new_task<RestartTask>(0U, *this); auto *restart_task = mx::tasking::runtime::new_task<RestartTask>(0U, *this);
restart_task->annotate(static_cast<mx::tasking::TaskInterface::channel>(0)); restart_task->annotate(static_cast<mx::tasking::TaskInterface::channel>(0));
mx::tasking::runtime::spawn(*restart_task, core_id); mx::tasking::runtime::spawn(*restart_task, core_id);
mx::tasking::runtime::resume(); mx::tasking::runtime::resume();
} }
else
{
std::cout << "Benchmark finished." << std::endl;
mx::tasking::runtime::stop();
}
}
} }
std::string Benchmark::profile_file_name() const std::string Benchmark::profile_file_name() const

View File

@@ -47,6 +47,11 @@ public:
*/ */
void start(); void start();
void start_chronometer() {
this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
this->_current_iteration + 1, this->_cores.current());
}
private: private:
// Collection of cores the benchmark should run on. // Collection of cores the benchmark should run on.
benchmark::Cores _cores; benchmark::Cores _cores;
@@ -101,6 +106,7 @@ private:
*/ */
[[nodiscard]] std::string profile_file_name() const; [[nodiscard]] std::string profile_file_name() const;
std::uint16_t start_core{0};
friend class StartMeasurementTask; friend class StartMeasurementTask;
friend class StopMeasurementTask; friend class StopMeasurementTask;
}; };
@@ -116,7 +122,7 @@ class StartMeasurementTask : public mx::tasking::TaskInterface
mx::tasking::TaskResult execute(const std::uint16_t, const std::uint16_t) override mx::tasking::TaskResult execute(const std::uint16_t, const std::uint16_t) override
{ {
_benchmark._chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(_benchmark._workload)), _benchmark._current_iteration + 1, _benchmark._cores.current()); //_benchmark._chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(_benchmark._workload)), _benchmark._current_iteration + 1, _benchmark._cores.current());
std::cout << "Started benchmark" << std::endl; std::cout << "Started benchmark" << std::endl;
return mx::tasking::TaskResult::make_remove(); return mx::tasking::TaskResult::make_remove();
} }
@@ -146,16 +152,8 @@ public:
~RestartTask() override = default; ~RestartTask() override = default;
mx::tasking::TaskResult execute(const std::uint16_t core_id, const std::uint16_t channel_id) override mx::tasking::TaskResult execute(const std::uint16_t core_id, const std::uint16_t channel_id) override
{
if (_benchmark.core_set())
{ {
_benchmark.start(); _benchmark.start();
}
else
{
std::cout << "Benchmark finished." << std::endl;
mx::tasking::runtime::stop();
}
return mx::tasking::TaskResult::make_remove(); return mx::tasking::TaskResult::make_remove();
} }
}; };

View File

@@ -48,6 +48,7 @@ int main(int count_arguments, char **arguments)
while ((cores = benchmark->core_set())) while ((cores = benchmark->core_set()))
{ {
mx::tasking::runtime_guard _(use_system_allocator, cores, prefetch_distance); mx::tasking::runtime_guard _(use_system_allocator, cores, prefetch_distance);
benchmark->start_chronometer();
benchmark->start(); benchmark->start();
} }