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
+51 -28
View File
@@ -207,11 +207,17 @@ read_file(const std::string& fname)
auto data = std::vector<std::string>{};
if(!is_readable(fs::path{fname}))
throw std::runtime_error{fmt::format("file '{}' cannot be read", fname)};
{
ROCP_CI_LOG(WARNING) << fmt::format("file '{}' cannot be read", fname);
return data;
}
auto ifs = std::ifstream{fname};
if(!ifs || !ifs.good())
throw std::runtime_error{fmt::format("file '{}' cannot be read", fname)};
{
ROCP_CI_LOG(WARNING) << fmt::format("file '{}' cannot be read", fname);
return data;
}
while(true)
{
@@ -231,11 +237,17 @@ read_map(const std::string& fname)
auto data = std::unordered_map<std::string, std::string>{};
if(!is_readable(fs::path{fname}))
throw std::runtime_error{fmt::format("file '{}' cannot be read", fname)};
{
ROCP_CI_LOG(WARNING) << fmt::format("file '{}' cannot be read", fname);
return data;
}
auto ifs = std::ifstream{fname};
if(!ifs || !ifs.good())
throw std::runtime_error{fmt::format("file '{}' cannot be read", fname)};
{
ROCP_CI_LOG(WARNING) << fmt::format("file '{}' cannot be read", fname);
return data;
}
auto last_label = std::string{};
while(true)
@@ -247,17 +259,23 @@ read_map(const std::string& fname)
auto entry = std::string{};
ifs >> entry;
if(ifs.eof())
throw std::runtime_error{
fmt::format("unexpected file format in '{}' at {}", fname, label)};
{
ROCP_CI_LOG(WARNING) << fmt::format(
"unexpected file format in '{}' at {}", fname, label);
continue;
}
auto ret = data.emplace(label, entry);
if(!ret.second)
throw std::runtime_error{
fmt::format("duplicate entry in '{}': '{}' (='{}'). last label was '{}'",
fname,
label,
entry,
last_label)};
{
ROCP_CI_LOG(WARNING) << fmt::format(
"duplicate entry in '{}': '{}' (='{}'). last label was '{}'",
fname,
label,
entry,
last_label);
continue;
}
if(!label.empty()) last_label = std::move(label);
}
@@ -305,21 +323,22 @@ read_property(const MapT& data, const std::string& label, Tp& value)
constexpr auto max_value = std::numeric_limits<Tp>::max();
if(local_value < min_value)
{
throw std::runtime_error{
fmt::format("data with label {} has a value (={}) which is less "
"than the min value for the type (={})",
label,
local_value,
min_value)};
ROCP_CI_LOG(WARNING) << fmt::format(
"data with label {} has a value (={}) which is less "
"than the min value for the type (={})",
label,
local_value,
min_value);
return;
}
else if(local_value > max_value)
{
throw std::runtime_error{fmt::format("data with label {} has a value (={}) which is "
"greater "
"than the max value for the type (={})",
label,
local_value,
max_value)};
ROCP_CI_LOG(WARNING) << fmt::format("data with label {} has a value (={}) which is "
"greater than the max value for the type (={})",
label,
local_value,
max_value);
return;
}
if constexpr(std::is_const<Tp>::value)
@@ -544,13 +563,17 @@ using unique_agent_t = std::unique_ptr<rocprofiler_agent_t, void (*)(rocprofiler
auto
read_topology()
{
auto sysfs_nodes_path = fs::path{"/sys/class/kfd/kfd/topology/nodes/"};
auto data = std::vector<unique_agent_t>{};
const auto sysfs_nodes_path = fs::path{"/sys/class/kfd/kfd/topology/nodes"};
if(!fs::exists(sysfs_nodes_path))
throw std::runtime_error{
fmt::format("sysfs nodes path '{}' does not exist", sysfs_nodes_path.string())};
{
ROCP_CI_LOG(WARNING) << fmt::format("sysfs nodes path '{}' does not exist",
sysfs_nodes_path.string());
return data;
}
const auto& cpu_info_v = get_cpu_info();
auto data = std::vector<unique_agent_t>{};
uint64_t idcount = 0;
uint64_t nodecount = 0;
uint64_t cpucount = 0;