Add support for device counter collection ioctl (#46)

Add support for device counter colleciton ioctl

Adds support for the device counter collection IOCTL. This IOCTL
allows for device wide counters to be collected even if the queue
is not intercepted by rocprofiler-sdk (required for system profilers).

A test is also included which checks this behavior by creating a queue
that does not have profiling enabled on it and checks to see if SQ
counters can be read from it. Note: this test will be skipped if the KFD
version does not contain this IOCTL.

Right now the check is "soft" in that if the IOCTL is present and there
is an error with permissions, rocprofiler will continue but will print
an error stating that system wide device profiling and collected counter
values may be degraded. This is primarily to avoid breaking existing
users (like PAPI) who may not need the IOCTL's capability and to give
them time to update.

Co-authored-by: Benjamin Welton <ben@amd.com>
This commit is contained in:
Welton, Benjamin
2024-12-19 13:27:35 -08:00
committed by GitHub
parent 9c21c49aa1
commit c574881cdb
12 changed files with 305 additions and 61 deletions
@@ -1,6 +1,6 @@
// MIT License
//
// Copyright (c) 2023 ROCm Developer Tools
// Copyright (c) 2024 ROCm Developer Tools
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -74,13 +74,6 @@ kfd_open()
return fd;
}
int
get_kfd_fd()
{
static auto _v = kfd_open();
return _v;
}
/** Call ioctl, restarting if it is interrupted
* Taken from libhsakmt.c
*/
@@ -283,7 +276,7 @@ ioctl_query_pc_sampling_capabilities(uint32_t kfd_gpu_id,
// which is not supported.
return ROCPROFILER_IOCTL_STATUS_UNAVAILABLE;
}
ROCP_ERROR << "IOCTL failed to query PC sampling configs: " << ret << "\n";
ROCP_WARNING << "IOCTL failed to query PC sampling configs: " << ret << "\n";
}
*size = args.num_sample_info;
@@ -352,6 +345,13 @@ convert_ioctl_pcs_config_to_rocp(const rocprofiler_ioctl_pc_sampling_info_t& ioc
}
} // namespace
int
get_kfd_fd()
{
static auto _v = kfd_open();
return _v;
}
rocprofiler_status_t
ioctl_query_pcs_configs(const rocprofiler_agent_t* agent, rocp_pcs_cfgs_vec_t& rocp_configs)
{
@@ -381,7 +381,7 @@ ioctl_query_pcs_configs(const rocprofiler_agent_t* agent, rocp_pcs_cfgs_vec_t& r
}
else if(ret != ROCPROFILER_IOCTL_STATUS_SUCCESS)
{
ROCP_ERROR << "......... Failed while iterating over PC sampling configurations\n";
ROCP_WARNING << "......... Failed while iterating over PC sampling configurations\n";
return ROCPROFILER_STATUS_ERROR;
}