[Rocprofiler-system]: Fix GPU event enumeration for rocprof-sys-avail and CLI option for parsing GPU HW Counters (#2476)
## Motivation The `rocprof-sys-avail -H -c GPU` command is returning blank output which is expected to display a list of available GPU hardware counters instead. The `rocprof-sys-sample` and `rocprof-sys-run` is missing the `--gpu-events` option for specifying GPU counter events during profiling. ## Technical Details The initialize_event_info() function had a logic bug where it only called set_agents() if the agent_manager was empty, but the actual issue was that the gpu_agents and cpu_agents vectors were empty even when agents were discovered. Fixed the conditional logic to properly call set_agents() when gpu_agents and cpu_agents are empty, regardless of the agent_manager state. Added the `--gpu-events (-G)` option which sets the `ROCPROFSYS_ROCM_EVENTS` environment variable to the specified values. Fixes an issue where unsupported GPU/APU arch is being skipped gracefully - more details about this issue in the below comment.
This commit is contained in:
@@ -213,6 +213,18 @@ create_agent_profile(rocprofiler_agent_id_t agent_id,
|
||||
auto counters_v = counter_vec_t{};
|
||||
const auto* tool_agent_v = data->get_gpu_tool_agent(agent_id);
|
||||
|
||||
// Check if agent info is available (may not be for unsupported architectures)
|
||||
auto agent_info_it = data->agent_counter_info.find(agent_id);
|
||||
if(agent_info_it == data->agent_counter_info.end())
|
||||
{
|
||||
ROCPROFSYS_WARNING_F(0,
|
||||
"Skipping GPU agent %lu (device %lu) due to unsupported "
|
||||
"architecture or missing counter info\n",
|
||||
agent_id.handle, tool_agent_v->device_id);
|
||||
data->agent_counter_profiles.emplace(agent_id, profile);
|
||||
return counter_vec_t{};
|
||||
}
|
||||
|
||||
constexpr auto device_qualifier = std::string_view{ ":device=" };
|
||||
for(const auto& itr : counters)
|
||||
{
|
||||
@@ -263,7 +275,7 @@ create_agent_profile(rocprofiler_agent_id_t agent_id,
|
||||
}
|
||||
|
||||
// search the gpu agent counter info for a counter with a matching name
|
||||
for(const auto& citr : data->agent_counter_info.at(agent_id))
|
||||
for(const auto& citr : agent_info_it->second)
|
||||
{
|
||||
if(name_v == std::string_view{ citr.name })
|
||||
{
|
||||
@@ -280,11 +292,34 @@ create_agent_profile(rocprofiler_agent_id_t agent_id,
|
||||
auto found_counters =
|
||||
timemory::join::join(timemory::join::array_config{ ", ", "", "" }, found_v);
|
||||
|
||||
ROCPROFSYS_ABORT_F(
|
||||
"Unable to find all counters for agent %i (gpu-%li, %s) in %s. Found: %s\n",
|
||||
// Determine which counters were not found
|
||||
auto missing_counters = std::vector<std::string>{};
|
||||
for(const auto& counter : counters)
|
||||
{
|
||||
if(std::find(found_v.begin(), found_v.end(), counter) == found_v.end())
|
||||
missing_counters.emplace_back(counter);
|
||||
}
|
||||
auto missing_counters_str = timemory::join::join(
|
||||
timemory::join::array_config{ ", ", "", "" }, missing_counters);
|
||||
|
||||
// In production, warn and continue with available counters
|
||||
ROCPROFSYS_WARNING_F(0,
|
||||
"Unable to find all counters for agent %i (gpu-%li, %s). "
|
||||
"Requested: %s. Found: %s. Missing: %s. Continuing with "
|
||||
"available counters.\n",
|
||||
tool_agent_v->agent->node_id, tool_agent_v->device_id,
|
||||
tool_agent_v->agent->name.c_str(),
|
||||
requested_counters.c_str(), found_counters.c_str(),
|
||||
missing_counters_str.c_str());
|
||||
|
||||
// In CI, throw to catch issues early
|
||||
ROCPROFSYS_CI_THROW(
|
||||
true,
|
||||
"Unable to find all counters for agent %i (gpu-%li, %s). Requested: %s. "
|
||||
"Found: %s. Missing: %s",
|
||||
tool_agent_v->agent->node_id, tool_agent_v->device_id,
|
||||
tool_agent_v->agent->name.c_str(), requested_counters.c_str(),
|
||||
found_counters.c_str());
|
||||
found_counters.c_str(), missing_counters_str.c_str());
|
||||
}
|
||||
|
||||
if(!counters_v.empty())
|
||||
|
||||
Reference in New Issue
Block a user