Skip to content

Commit

Permalink
remove Trace::location(), use Trace::sample_writer().location() instead
Browse files Browse the repository at this point in the history
  • Loading branch information
cvonelm committed Feb 14, 2024
1 parent d8e0589 commit 34087e0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion include/lo2s/perf/counter/metric_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
{
}
Expand Down
27 changes: 0 additions & 27 deletions include/lo2s/trace/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,33 +258,6 @@ class Trace
return registry_.get<otf2::definition::comm>(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<otf2::definition::location>(
ByMeasurementScope(sample_scope), intern(sample_scope.name()),
registry_.get<otf2::definition::location_group>(
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<otf2::definition::comm_group>(
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.
*
Expand Down
22 changes: 20 additions & 2 deletions src/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::recursive_mutex> guard(mutex_);

return archive_(location(writer_scope));
MeasurementScope sample_scope = MeasurementScope::sample(scope);

const auto& intern_location = registry_.emplace<otf2::definition::location>(
ByMeasurementScope(sample_scope), intern(sample_scope.name()),
registry_.get<otf2::definition::location_group>(
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<otf2::definition::comm_group>(
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)
Expand Down

0 comments on commit 34087e0

Please sign in to comment.