[Rocprofiler-systems] : Refactor papi enumeration to fix a hang on Intel systems (#1672)

* Refactor papi enumeration to fix a hang on Intel systems

- Add an exclude argument to available_events_info() for
  perf_event_uncore causing hang like case on Intel systems with large
number of uncore events.
- Enumerate papi available events only when papi events are specified by
  users inside early initialization logic
- Move papi available event query for ROCPROFSYS_SAMPLING_OVERFLOW_EVENT
  config setting to the avail component, to move the heavy logic outside
initialization.
- Make category option for rocprof-sys-avail -H -c case insensitive
- Provide new option to query available overflow events that can be
  specified for ROCPROFSYS_SAMPLING_OVERFLOW_EVENT using new command
option rocprof-sys-avail -H -c overflow

* Update projects/rocprofiler-systems/source/bin/rocprof-sys-avail/common.cpp

Co-authored-by: Milan Radosavljevic <milan.radosavljevic@amd.com>

* Update timemory submodule pointer

Signed-off-by: David Galiffi <David.Galiffi@amd.com>

* Fix errors on compile

* Change 1: Optimization for the category matching lambda

Optmization changes.

* Modify the rocprof-sys-avail -c option for overflow

Overflow should not be displayed as a device in rocprof-sys-avail -H -c CPU

Users can instead do regex on summary where overflow is appended in description

User can do rocprof-sys-avail -H -c CPU -d -r overflow

* Revert change to column width

---------

Signed-off-by: David Galiffi <David.Galiffi@amd.com>
Co-authored-by: Milan Radosavljevic <milan.radosavljevic@amd.com>
Co-authored-by: David Galiffi <David.Galiffi@amd.com>
This commit is contained in:
Sajina PK
2025-11-21 00:19:58 -05:00
committed by GitHub
parent 4f4352acd0
commit d77b245730
6 changed files with 106 additions and 69 deletions
@@ -1075,19 +1075,33 @@ write_hw_counter_info(std::ostream& os, const array_t<bool, N>& options,
using width_bool = array_t<bool, N>;
using hwcounter_info_t = std::vector<tim::hardware_counters::info>;
auto _papi_events = tim::papi::available_events_info();
auto _papi_events = tim::papi::available_events_info({ "perf_event_uncore" });
auto _rocm_events =
(gpu_count > 0) ? rocprofsys::rocm::rocm_events() : hwcounter_info_t{};
if(alphabetical)
// Tag overflow events by modifying both short and long descriptions upfront
{
auto _sorter = [](const auto& lhs, const auto& rhs) {
return (lhs.symbol() < rhs.symbol());
};
std::sort(_papi_events.begin(), _papi_events.end(), _sorter);
std::sort(_rocm_events.begin(), _rocm_events.end(), _sorter);
namespace regex_const = ::std::regex_constants;
auto _regex =
std::regex{ "^(perf::|)PERF_COUNT_(HW|SW|HW_CACHE)_([A-Z_]+)(|:[A-Z]+)$",
regex_const::optimize };
for(auto& itr : _papi_events)
{
if(std::regex_match(itr.symbol(), _regex))
{
itr.short_description() += " (overflow event)";
itr.long_description() += " (overflow event)";
}
}
}
// sort the events alphabetically
auto _sorter = [](const auto& lhs, const auto& rhs) {
return (lhs.symbol() < rhs.symbol());
};
std::sort(_papi_events.begin(), _papi_events.end(), _sorter);
std::sort(_rocm_events.begin(), _rocm_events.end(), _sorter);
auto _process_counters = [](auto& _events_v, int32_t _offset_v) {
for(auto& iitr : _events_v)
iitr.offset() += _offset_v;