SDK: remove majority of exceptions (#176)

* SDK: remove majority of exceptions

- replace with ROCP_FATAL, ROCP_CI_LOG(WARNING), etc.
- improve logging of symbolic link
- add --readlink and --realpath (hidden options) to rocprofv3 to follow symlinks for preloaded libraries

* Add rocprofv3 --rocm-root argument

* Fix registration resolved_exists

* Fix rocprofv3_avail.py

* Update logging for rocprofiler_configure search

- relax failure conditions

* Misc clang-tidy fixes

* Fix merge

* Fix merge

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Bhardwaj, Gopesh <Gopesh.Bhardwaj@amd.com>
This commit is contained in:
Madsen, Jonathan
2025-02-18 10:44:37 -06:00
committed by GitHub
parent fd99654433
commit 470f347e50
17 changed files with 270 additions and 140 deletions
@@ -78,14 +78,16 @@ amd_intercept_marker_handler_callback(const struct amd_aql_intercept_marker_s* p
if(ext_table_->hsa_amd_queue_get_info_fn(queue, HSA_AMD_QUEUE_INFO_AGENT, &hsa_agent) !=
HSA_STATUS_SUCCESS)
{
throw std::runtime_error("Cannot map hsa_queue_t* to hsa_agent_t");
ROCP_CI_LOG(WARNING) << "Cannot map hsa_queue_t* to hsa_agent_t";
return;
}
uint64_t doorbell_id = 0;
if(ext_table_->hsa_amd_queue_get_info_fn(queue, HSA_AMD_QUEUE_INFO_DOORBELL_ID, &doorbell_id) !=
HSA_STATUS_SUCCESS)
{
throw std::runtime_error("Cannot map hsa_queue_t* to doorbell_id");
ROCP_CI_LOG(WARNING) << "Cannot map hsa_queue_t* to doorbell id";
return;
}
auto internal_correlation = packet->user_data[0];
@@ -21,12 +21,12 @@
// SOFTWARE.
#include "lib/rocprofiler-sdk/pc_sampling/ioctl/ioctl_adapter.hpp"
#include "lib/rocprofiler-sdk/details/kfd_ioctl.h"
#include "lib/common/logging.hpp"
#include "lib/rocprofiler-sdk/details/kfd_ioctl.h"
#include "lib/rocprofiler-sdk/pc_sampling/ioctl/ioctl_adapter_types.hpp"
#include <rocprofiler-sdk/fwd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
@@ -61,14 +61,15 @@ struct pc_sampling_ioctl_version_t
int
kfd_open()
{
int fd = -1;
static const char kfd_device_name[] = "/dev/kfd";
int fd = -1;
constexpr auto* kfd_device_name = "/dev/kfd";
fd = open(kfd_device_name, O_RDWR | O_CLOEXEC);
if(fd == -1)
{
throw std::runtime_error("Cannot open /dev/kfd");
ROCP_CI_LOG(WARNING) << fmt::format("Cannot open {} for pc sampling", kfd_device_name);
return -1;
}
return fd;
@@ -485,6 +486,8 @@ ioctl_pcs_create(const rocprofiler_agent_t* agent,
args.num_sample_info = 1;
args.trace_id = INVALID_TRACE_ID;
if(get_kfd_fd() == -1) return ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE;
auto ioctl_ret = ioctl(get_kfd_fd(), AMDKFD_IOC_PC_SAMPLE, &args);
*ioctl_pcs_id = args.trace_id;
@@ -21,6 +21,7 @@
// SOFTWARE.
#include "lib/rocprofiler-sdk/pc_sampling/utils.hpp"
#include "lib/common/logging.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/defines.hpp"
#if ROCPROFILER_SDK_HSA_PC_SAMPLING > 0
@@ -49,7 +50,7 @@ get_matching_hsa_pcs_method(rocprofiler_pc_sampling_method_t method)
case ROCPROFILER_PC_SAMPLING_METHOD_LAST: break;
}
throw std::runtime_error("Illegal pc sampling method\n");
ROCP_FATAL << "Illegal pc sampling method " << method;
}
hsa_ven_amd_pcs_units_t
@@ -66,7 +67,7 @@ get_matching_hsa_pcs_units(rocprofiler_pc_sampling_unit_t unit)
case ROCPROFILER_PC_SAMPLING_UNIT_LAST: break;
}
throw std::runtime_error("Illegal pc sampling units\n");
ROCP_FATAL << "Illegal pc sampling unit " << unit;
}
} // namespace utils
} // namespace pc_sampling