From 34087e09108d4ed8ca9788f38c810bceab33f41c Mon Sep 17 00:00:00 2001 From: Christian von Elm Date: Wed, 14 Feb 2024 18:54:04 +0100 Subject: [PATCH] remove Trace::location(), use Trace::sample_writer().location() instead --- include/lo2s/perf/counter/metric_writer.hpp | 2 +- include/lo2s/trace/trace.hpp | 27 --------------------- src/trace/trace.cpp | 22 +++++++++++++++-- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/include/lo2s/perf/counter/metric_writer.hpp b/include/lo2s/perf/counter/metric_writer.hpp index da72fa93..23220fd6 100644 --- a/include/lo2s/perf/counter/metric_writer.hpp +++ b/include/lo2s/perf/counter/metric_writer.hpp @@ -38,7 +38,7 @@ class MetricWriter MetricWriter(MeasurementScope scope, trace::Trace& trace) : time_converter_(time::Converter::instance()), writer_(trace.metric_writer(scope)), metric_instance_(trace.metric_instance(trace.perf_metric_class(scope), writer_.location(), - trace.location(scope.scope))), + trace.sample_writer(scope.scope).location())), metric_event_(otf2::chrono::genesis(), metric_instance_) { } diff --git a/include/lo2s/trace/trace.hpp b/include/lo2s/trace/trace.hpp index 5c0d1e8c..ae2f349b 100644 --- a/include/lo2s/trace/trace.hpp +++ b/include/lo2s/trace/trace.hpp @@ -258,33 +258,6 @@ class Trace return registry_.get(ByProcess(groups_.get_process(thread))); } - const otf2::definition::location& location(const ExecutionScope& scope) - { - MeasurementScope sample_scope = MeasurementScope::sample(scope); - - const auto& intern_location = registry_.emplace( - ByMeasurementScope(sample_scope), intern(sample_scope.name()), - registry_.get( - ByExecutionScope(groups_.get_parent(scope))), - otf2::definition::location::location_type::cpu_thread); - - comm_locations_group_.add_member(intern_location); - - if (groups_.get_parent(scope).is_process()) - { - registry_ - .get( - ByProcess(groups_.get_process(scope.as_thread()))) - .add_member(intern_location); - } - - // You can not have a location withouth a writer, so create one here. calling archive_ on - // the same location twice is harmless in case some requires a real writer later on - archive_(intern_location); - - return intern_location; - } - private: /** Add a thread with the required lock (#mutex_) held. * diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 00e6a0d7..824c3fb2 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -403,12 +403,30 @@ void Trace::add_lo2s_property(const std::string& name, const std::string& value) system_tree_root_node_, intern(property_name), otf2::attribute_value{ intern(value) }); } -otf2::writer::local& Trace::sample_writer(const ExecutionScope& writer_scope) +otf2::writer::local& Trace::sample_writer(const ExecutionScope& scope) { // TODO we call this function in a hot-loop, locking doesn't sound like a good idea std::lock_guard guard(mutex_); - return archive_(location(writer_scope)); + MeasurementScope sample_scope = MeasurementScope::sample(scope); + + const auto& intern_location = registry_.emplace( + ByMeasurementScope(sample_scope), intern(sample_scope.name()), + registry_.get( + ByExecutionScope(groups_.get_parent(scope))), + otf2::definition::location::location_type::cpu_thread); + + comm_locations_group_.add_member(intern_location); + + if (groups_.get_parent(scope).is_process()) + { + registry_ + .get( + ByProcess(groups_.get_process(scope.as_thread()))) + .add_member(intern_location); + } + + return archive_(intern_location); } otf2::writer::local& Trace::nec_writer(NecDevice device, const Thread& nec_thread)