Skip to content

Commit

Permalink
Merge pull request #168 from tud-zih-energy/issue-167-extraneous-metr…
Browse files Browse the repository at this point in the history
…ic_class

Create cpu/perf_metric_class on demand
  • Loading branch information
cvonelm authored Nov 13, 2020
2 parents 8680b78 + 7b1406a commit 9d57d8c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
46 changes: 42 additions & 4 deletions include/lo2s/trace/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <lo2s/config.hpp>
#include <lo2s/line_info.hpp>
#include <lo2s/mmap.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/process_info.hpp>
#include <lo2s/trace/reg_keys.hpp>

Expand Down Expand Up @@ -128,12 +129,49 @@ class Trace
const otf2::definition::location& recorder,
const otf2::definition::system_tree_node& scope);

otf2::definition::metric_class& cpuid_metric_class()
otf2::definition::metric_class cpuid_metric_class()
{
if (!cpuid_metric_class_)
{
cpuid_metric_class_ = registry_.create<otf2::definition::metric_class>(
otf2::common::metric_occurence::async, otf2::common::recorder_kind::abstract);
cpuid_metric_class_->add_member(metric_member("CPU", "CPU executing the task",
otf2::common::metric_mode::absolute_point,
otf2::common::type::int64, "cpuid"));
}
return cpuid_metric_class_;
}
otf2::definition::metric_class& perf_metric_class()
otf2::definition::metric_class perf_metric_class()
{
if (!perf_metric_class_)
{
perf_metric_class_ = registry_.create<otf2::definition::metric_class>(
otf2::common::metric_occurence::async, otf2::common::recorder_kind::abstract);
const perf::counter::CounterCollection& counter_collection =
perf::counter::requested_counters();
if (!counter_collection.counters.empty())
{
perf_metric_class_->add_member(metric_member(
counter_collection.leader.name, counter_collection.leader.name,
otf2::common::metric_mode::accumulated_start, otf2::common::type::Double, "#"));

for (const auto& counter : counter_collection.counters)
{
perf_metric_class_->add_member(metric_member(
counter.name, counter.name, otf2::common::metric_mode::accumulated_start,
otf2::common::type::Double, "#"));
}

perf_metric_class_->add_member(
metric_member("time_enabled", "time event active",
otf2::common::metric_mode::accumulated_start,
otf2::common::type::uint64, "ns"));
perf_metric_class_->add_member(
metric_member("time_running", "time event on CPU",
otf2::common::metric_mode::accumulated_start,
otf2::common::type::uint64, "ns"));
}
}
return perf_metric_class_;
}

Expand Down Expand Up @@ -213,8 +251,8 @@ class Trace
otf2::definition::comm_locations_group& comm_locations_group_;
otf2::definition::regions_group& lo2s_regions_group_;

otf2::definition::metric_class& perf_metric_class_;
otf2::definition::metric_class& cpuid_metric_class_;
otf2::definition::detail::weak_ref<otf2::definition::metric_class> cpuid_metric_class_;
otf2::definition::detail::weak_ref<otf2::definition::metric_class> perf_metric_class_;

const otf2::definition::system_tree_node& system_tree_root_node_;
};
Expand Down
33 changes: 0 additions & 33 deletions src/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <lo2s/config.hpp>
#include <lo2s/line_info.hpp>
#include <lo2s/mmap.hpp>
#include <lo2s/perf/counter/counter_collection.hpp>
#include <lo2s/perf/tracepoint/format.hpp>
#include <lo2s/summary.hpp>
#include <lo2s/time/time.hpp>
Expand Down Expand Up @@ -95,41 +94,9 @@ Trace::Trace()
otf2::common::group_flag_type::none)),
lo2s_regions_group_(registry_.create<otf2::definition::regions_group>(
intern("lo2s"), otf2::common::paradigm_type::user, otf2::common::group_flag_type::none)),

perf_metric_class_(registry_.create<otf2::definition::metric_class>(
otf2::common::metric_occurence::async, otf2::common::recorder_kind::abstract)),
cpuid_metric_class_(registry_.create<otf2::definition::metric_class>(
otf2::common::metric_occurence::async, otf2::common::recorder_kind::abstract)),
system_tree_root_node_(registry_.create<otf2::definition::system_tree_node>(
intern(nitro::env::hostname()), intern("machine")))
{
cpuid_metric_class_.add_member(metric_member("CPU", "CPU executing the task",
otf2::common::metric_mode::absolute_point,
otf2::common::type::int64, "cpuid"));

const perf::counter::CounterCollection& counter_collection =
perf::counter::requested_counters();
if (!counter_collection.counters.empty())
{
perf_metric_class_.add_member(metric_member(
counter_collection.leader.name, counter_collection.leader.name,
otf2::common::metric_mode::accumulated_start, otf2::common::type::Double, "#"));

for (const auto& counter : counter_collection.counters)
{
perf_metric_class_.add_member(metric_member(
counter.name, counter.name, otf2::common::metric_mode::accumulated_start,
otf2::common::type::Double, "#"));
}

perf_metric_class_.add_member(metric_member("time_enabled", "time event active",
otf2::common::metric_mode::accumulated_start,
otf2::common::type::uint64, "ns"));
perf_metric_class_.add_member(metric_member("time_running", "time event on CPU",
otf2::common::metric_mode::accumulated_start,
otf2::common::type::uint64, "ns"));
}

Log::info() << "Using trace directory: " << trace_name_;
summary().set_trace_dir(trace_name_);

Expand Down

0 comments on commit 9d57d8c

Please sign in to comment.