Skip to content

Commit

Permalink
Write system_tree_node hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
cvonelm authored and bmario committed Mar 10, 2022
1 parent e2bd1bf commit f6889c4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
7 changes: 6 additions & 1 deletion include/lo2s/trace/reg_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ struct Holder<otf2::definition::io_handle>
using type = otf2::lookup_definition_holder<otf2::definition::io_handle, ByDev>;
};
template <>
struct Holder<otf2::definition::io_regular_file>
{
using type = otf2::lookup_definition_holder<otf2::definition::io_regular_file, ByDev>;
};
template <>
struct Holder<otf2::definition::string>
{
using type = otf2::lookup_definition_holder<otf2::definition::string, ByString>;
Expand Down Expand Up @@ -174,7 +179,7 @@ struct Holder<otf2::definition::source_code_location>
template <>
struct Holder<otf2::definition::comm>
{
using type = otf2::lookup_definition_holder<otf2::definition::comm, ByProcess>;
using type = otf2::lookup_definition_holder<otf2::definition::comm, ByProcess, ByDev>;
};
template <>
struct Holder<otf2::definition::comm_group>
Expand Down
12 changes: 12 additions & 0 deletions include/lo2s/trace/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ class Trace
}
}

const otf2::definition::system_tree_node bio_parent_node(BlockDevice& device)
{
if (device.type == BlockDeviceType::PARTITION)
{
if (registry_.has<otf2::definition::system_tree_node>(ByDev(device.parent)))
{
return registry_.get<otf2::definition::system_tree_node>(ByDev(device.parent));
}
}
return bio_system_tree_node_;
}

void create_userspace_metric_class()
{
const auto& counter_collection_ = perf::counter::requested_userspace_counters();
Expand Down
31 changes: 27 additions & 4 deletions src/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ Trace::Trace()
bio_comm_group_ = registry_.create<otf2::definition::comm_group>(
intern("block devices"), otf2::common::paradigm_type::hardware,
otf2::common::group_flag_type::none);

for (auto& device : get_block_devices())
{
if (device.type == BlockDeviceType::DISK)
{
block_io_handle(device);
bio_writer(device);
}
}
}
}

Expand Down Expand Up @@ -402,7 +411,7 @@ otf2::writer::local& Trace::bio_writer(BlockDevice& device)

const auto& intern_location = registry_.emplace<otf2::definition::location>(
ByDev(device.id), name, bio_location_group,
otf2::definition::location::location_type::cpu_thread);
otf2::definition::location::location_type::process);

hardware_comm_locations_group_.add_member(intern_location);
return archive_(intern_location);
Expand Down Expand Up @@ -437,14 +446,28 @@ otf2::definition::io_handle& Trace::block_io_handle(BlockDevice& device)
{

std::lock_guard<std::recursive_mutex> guard(mutex_);

// io_pre_created_handle can not be emplaced because it has no ref.
// So we have to check if we already created everything
if (registry_.has<otf2::definition::io_handle>(ByDev(device.id)))
{
return registry_.get<otf2::definition::io_handle>(ByDev(device.id));
}

const auto& device_name = intern(device.name);

const otf2::definition::system_tree_node& parent = bio_parent_node(device);
Log::error() << parent.name();
std::string device_class = (device.type == BlockDeviceType::PARTITION) ? "partition" : "disk";

const auto& node = registry_.emplace<otf2::definition::system_tree_node>(
ByDev(device.id), device_name, intern("block device"), bio_system_tree_node_);
ByDev(device.id), device_name, intern(device_class), bio_system_tree_node_);

const auto& file = registry_.create<otf2::definition::io_regular_file>(device_name, node);
const auto& file =
registry_.emplace<otf2::definition::io_regular_file>(ByDev(device.id), device_name, node);

const auto& block_comm = registry_.create<otf2::definition::comm>(device_name, bio_comm_group_);
const auto& block_comm =
registry_.emplace<otf2::definition::comm>(ByDev(device.id), device_name, bio_comm_group_);

// we could have io handle parents and childs here (block device being the parent (sda),
// partition being the child (sda1)) but that seems like it would be overkill.
Expand Down

0 comments on commit f6889c4

Please sign in to comment.