* Update logging

* Remove unused function

* Fix lib/rocprofiler-sdk/hsa/pc_sampling.cpp logging compilation

* Fix logging FLAGS_vmodule string leak and numerical log level

* Update logging

* Update glog submodule

* Leak fixes

* format
Этот коммит содержится в:
Jonathan R. Madsen
2024-05-20 15:38:18 -05:00
коммит произвёл GitHub
родитель 2c7e9e8e8b
Коммит 4d5b71b0e7
67 изменённых файлов: 342 добавлений и 349 удалений
поставляемый
+1 -1
-2
Просмотреть файл
@@ -23,8 +23,6 @@
#include "lib/common/demangle.hpp"
#include "lib/common/logging.hpp"
#include <glog/logging.h>
#include <cxxabi.h>
#include <cstdarg>
#include <cstdint>
+2 -2
Просмотреть файл
@@ -22,7 +22,7 @@
#pragma once
#include <glog/logging.h>
#include "lib/common/logging.hpp"
#include <unistd.h>
#include <string>
@@ -89,7 +89,7 @@ struct env_config
auto operator()(bool _verbose = false) const
{
if(env_name.empty()) return -1;
LOG_IF(INFO, _verbose) << "[rocprofiler][set_env] setenv(\"" << env_name << "\", \""
ROCP_INFO_IF(_verbose) << "[rocprofiler][set_env] setenv(\"" << env_name << "\", \""
<< env_value << "\", " << overwrite << ")\n";
return setenv(env_name.c_str(), env_value.c_str(), overwrite);
}
+102 -33
Просмотреть файл
@@ -22,6 +22,7 @@
#include "lib/common/logging.hpp"
#include "lib/common/environment.hpp"
#include "lib/common/filesystem.hpp"
#include <fmt/format.h>
#include <glog/logging.h>
@@ -38,19 +39,27 @@ namespace common
{
namespace
{
namespace fs = ::rocprofiler::common::filesystem;
void
install_failure_signal_handler()
{
static auto _once = std::once_flag{};
std::call_once(_once, []() { google::InstallFailureSignalHandler(); });
}
struct log_level_info
{
int32_t google_level = 0;
int32_t verbose_level = 0;
};
} // namespace
void
init_logging(std::string_view env_var, logging_config cfg)
init_logging(std::string_view env_prefix, logging_config cfg)
{
static auto _once = std::once_flag{};
std::call_once(_once, [env_var, &cfg]() {
std::call_once(_once, [env_prefix, &cfg]() {
auto get_argv0 = []() {
auto ifs = std::ifstream{"/proc/self/cmdline"};
auto sarg = std::string{};
@@ -62,60 +71,93 @@ init_logging(std::string_view env_var, logging_config cfg)
return sarg;
};
auto loglvl = common::get_env(env_var, "");
for(auto& itr : loglvl)
itr = tolower(itr);
auto to_lower = [](std::string val) {
for(auto& itr : val)
itr = tolower(itr);
return val;
};
const auto env_opts = std::unordered_map<std::string_view, log_level_info>{
{"trace", {google::INFO, ROCP_LOG_LEVEL_TRACE}},
{"info", {google::INFO, ROCP_LOG_LEVEL_INFO}},
{"warning", {google::WARNING, ROCP_LOG_LEVEL_WARNING}},
{"error", {google::ERROR, ROCP_LOG_LEVEL_ERROR}},
{"fatal", {google::FATAL, ROCP_LOG_LEVEL_NONE}}};
auto supported = std::vector<std::string>{};
supported.reserve(env_opts.size());
for(auto itr : env_opts)
supported.emplace_back(itr.first);
if(cfg.name.empty()) cfg.name = to_lower(std::string{env_prefix});
cfg.logdir = get_env(fmt::format("{}_LOG_DIR", env_prefix), cfg.logdir);
cfg.vlog_modules = get_env(fmt::format("{}_vmodule", env_prefix), cfg.vlog_modules);
cfg.logtostderr = cfg.logdir.empty(); // log to stderr if no log dir set
// cfg.alsologtostderr = !cfg.logdir.empty(); // log to file if log dir set
auto loglvl = to_lower(common::get_env(fmt::format("{}_LOG_LEVEL", env_prefix), ""));
// default to warning
auto& loglvl_v = cfg.loglevel;
auto& vlog_level = cfg.vlog_level;
if(!loglvl.empty() && loglvl.find_first_not_of("0123456789") == std::string::npos)
if(!loglvl.empty() && loglvl.find_first_not_of("-0123456789") == std::string::npos)
{
loglvl_v = std::stoul(loglvl);
vlog_level = loglvl_v;
auto val = std::stol(loglvl);
if(val < 0)
{
loglvl_v = google::FATAL;
vlog_level = val;
}
else
{
// default to trace in case val > ROCP_LOG_LEVEL_TRACE
auto itr = env_opts.at("trace");
for(auto oitr : env_opts)
{
if(oitr.second.verbose_level == val)
{
itr = oitr.second;
break;
}
}
loglvl_v = itr.google_level;
vlog_level = itr.verbose_level;
}
}
else if(!loglvl.empty())
{
const auto opts = std::unordered_map<std::string_view, std::pair<uint32_t, uint32_t>>{
{"trace", {google::INFO, ROCP_LEVEL_TRACE}},
{"info", {google::INFO, ROCP_LEVEL_INFO}},
{"warning", {google::WARNING, ROCP_LEVEL_WARNING}},
{"error", {google::ERROR, ROCP_NO_VLOG}},
{"fatal", {google::ERROR, ROCP_NO_VLOG}}};
if(opts.find(loglvl) == opts.end())
if(env_opts.find(loglvl) == env_opts.end())
throw std::runtime_error{fmt::format(
"invalid specifier for ROCPROFILER_LOG_LEVEL: {}. Supported: trace, info, "
"warning, error, fatal",
loglvl)};
"invalid specifier for {}_LOG_LEVEL: {}. Supported: {}",
env_prefix,
loglvl,
fmt::format("{}", fmt::join(supported.begin(), supported.end(), ", ")))};
else
{
loglvl_v = opts.at(loglvl).first;
vlog_level = opts.at(loglvl).second;
loglvl_v = env_opts.at(loglvl).google_level;
vlog_level = env_opts.at(loglvl).verbose_level;
}
}
update_logging(cfg, true);
update_logging(cfg, !google::IsGoogleLoggingInitialized());
if(!google::IsGoogleLoggingInitialized())
{
static auto argv0 = get_argv0();
// Prevent glog from crashing if vmodule is empty
if(FLAGS_vmodule.empty())
{
FLAGS_vmodule = " ";
}
if(FLAGS_vmodule.empty()) FLAGS_vmodule = " ";
google::InitGoogleLogging(argv0.c_str());
ROCP_WARNING << "Log Level: " << loglvl << " VLOG Level: " << vlog_level;
// Swap out memory to avoid leaking the string
if(FLAGS_vmodule == " ")
{
std::string().swap(FLAGS_vmodule);
}
if(!FLAGS_vmodule.empty()) std::string{}.swap(FLAGS_vmodule);
if(!FLAGS_log_dir.empty()) std::string{}.swap(FLAGS_log_dir);
}
update_logging(cfg);
ROCP_INFO << "logging initialized via " << env_var;
ROCP_INFO << "logging initialized via " << fmt::format("{}_LOG_LEVEL", env_prefix)
<< ". Log Level: " << loglvl << ". Verbose Log Level: " << vlog_level;
});
}
@@ -126,18 +168,45 @@ update_logging(const logging_config& cfg, bool setup_env, int env_override)
auto _lk = std::unique_lock<std::mutex>{_mtx};
FLAGS_timestamp_in_logfile_name = false;
FLAGS_logtostderr = cfg.logtostderr;
FLAGS_minloglevel = cfg.loglevel;
FLAGS_stderrthreshold = cfg.loglevel;
FLAGS_logtostderr = cfg.logtostderr;
FLAGS_alsologtostderr = cfg.alsologtostderr;
FLAGS_v = cfg.vlog_level;
// if(!cfg.logdir.empty()) FLAGS_log_dir = cfg.logdir.c_str();
if(cfg.install_failure_handler) install_failure_signal_handler();
if(!cfg.logdir.empty() && !fs::exists(cfg.logdir))
{
fs::create_directories(cfg.logdir);
if(cfg.logdir_gitignore)
{
auto ignore = fs::path{cfg.logdir} / ".gitignore";
if(!fs::exists(ignore))
{
std::ofstream ofs{ignore.string()};
ofs << "/**" << std::flush;
}
}
}
if(setup_env)
{
common::set_env("GLOG_minloglevel", cfg.loglevel, env_override);
common::set_env("GLOG_logtostderr", cfg.logtostderr ? 1 : 0, env_override);
common::set_env("GLOG_alsologtostderr", cfg.alsologtostderr ? 1 : 0, env_override);
common::set_env("GLOG_stderrthreshold", cfg.loglevel, env_override);
common::set_env("GLOG_v", cfg.vlog_level, env_override);
common::set_env("GOOGLE_LOG_DIR", get_env("PWD", ""), env_override);
if(!cfg.logdir.empty())
{
common::set_env("GOOGLE_LOG_DIR", cfg.logdir, env_override);
common::set_env("GLOG_log_dir", cfg.logdir, env_override);
}
if(!cfg.vlog_modules.empty())
common::set_env("GLOG_vmodule", cfg.vlog_modules, env_override);
}
}
} // namespace common
+36 -13
Просмотреть файл
@@ -22,38 +22,61 @@
#pragma once
#include "lib/common/defines.hpp"
#include <glog/logging.h>
#include <cstdint>
#include <optional>
#include <string_view>
#define ROCP_LEVEL_TRACE 12
#define ROCP_LEVEL_INFO 11
#define ROCP_LEVEL_WARNING 10
#define ROCP_NO_VLOG -1
#define ROCP_LOG_LEVEL_TRACE 4
#define ROCP_LOG_LEVEL_INFO 3
#define ROCP_LOG_LEVEL_WARNING 2
#define ROCP_LOG_LEVEL_ERROR 1
#define ROCP_LOG_LEVEL_NONE 0
#define ROCP_TRACE VLOG(ROCP_LEVEL_TRACE)
#define ROCP_INFO VLOG(ROCP_LEVEL_INFO)
#define ROCP_WARNING VLOG(ROCP_LEVEL_WARNING)
#define ROCP_TRACE VLOG(ROCP_LOG_LEVEL_TRACE)
#define ROCP_INFO LOG(INFO)
#define ROCP_WARNING LOG(WARNING)
#define ROCP_ERROR LOG(ERROR)
#define ROCP_FATAL LOG(FATAL)
#define ROCP_DFATAL DLOG(FATAL)
#define ROCP_TRACE_IF(CONDITION) VLOG_IF(ROCP_LOG_LEVEL_TRACE, (CONDITION))
#define ROCP_INFO_IF(CONDITION) LOG_IF(INFO, (CONDITION))
#define ROCP_WARNING_IF(CONDITION) LOG_IF(WARNING, (CONDITION))
#define ROCP_ERROR_IF(CONDITION) LOG_IF(ERROR, (CONDITION))
#define ROCP_FATAL_IF(CONDITION) LOG_IF(FATAL, (CONDITION))
#define ROCP_DFATAL_IF(CONDITION) DLOG_IF(FATAL, (CONDITION))
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) ROCP_FATAL_IF(__VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_FATAL
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) ROCP_##NON_CI_LEVEL##_IF(__VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_##NON_CI_LEVEL##
#endif
namespace rocprofiler
{
namespace common
{
struct logging_config
{
bool install_failure_handler = false;
bool logtostderr = true;
bool alsologtostderr = false;
int32_t vlog_level = ROCP_NO_VLOG;
int32_t loglevel = google::WARNING;
bool install_failure_handler = false;
bool logtostderr = true;
bool alsologtostderr = false;
bool logdir_gitignore = false; // add .gitignore to logdir
int32_t loglevel = google::WARNING;
int32_t vlog_level = ROCP_LOG_LEVEL_WARNING;
std::string vlog_modules = {};
std::string name = {};
std::string logdir = {};
};
void
init_logging(std::string_view env_var, logging_config cfg = logging_config{});
init_logging(std::string_view env_prefix, logging_config cfg = logging_config{});
void
update_logging(const logging_config& cfg, bool setup_env = false, int env_override = 0);
+2 -3
Просмотреть файл
@@ -23,8 +23,7 @@
#pragma once
#include "lib/common/defines.hpp"
#include <glog/logging.h>
#include "lib/common/logging.hpp"
#include <array>
#include <cstddef>
@@ -123,7 +122,7 @@ static_object<Tp, ContextT>::construct(Args&&... args)
});
}
LOG_IF(FATAL, m_object)
ROCP_FATAL_IF(m_object)
<< "reconstructing static object. Use get() function to retrieve pointer";
m_object = new(m_buffer.data()) Tp{std::forward<Args>(args)...};
+5 -6
Просмотреть файл
@@ -23,8 +23,7 @@
#pragma once
#include "lib/common/environment.hpp"
#include <glog/logging.h>
#include "lib/common/logging.hpp"
#include <unistd.h>
#include <cctype>
@@ -214,7 +213,7 @@ get_memory_unit(std::string _unit)
}
}
LOG(WARNING) << "Warning!! No memory unit matching \"" << _unit << "\". Using default...\n";
ROCP_WARNING << "Warning!! No memory unit matching \"" << _unit << "\". Using default...\n";
return return_type{"MB", units::megabyte};
}
@@ -250,7 +249,7 @@ get_timing_unit(std::string _unit)
}
}
LOG(WARNING) << "Warning!! No timing unit matching \"" << _unit << "\". Using default...\n";
ROCP_WARNING << "Warning!! No timing unit matching \"" << _unit << "\". Using default...\n";
return return_type{"sec", units::sec};
}
@@ -280,7 +279,7 @@ get_frequncy_unit(std::string _unit)
}
}
LOG(WARNING) << "Warning!! No frequency unit matching \"" << _unit << "\". Using default...\n";
ROCP_WARNING << "Warning!! No frequency unit matching \"" << _unit << "\". Using default...\n";
return return_type{"MHz", units::megahertz};
}
@@ -315,7 +314,7 @@ get_power_unit(const std::string& _unit)
}
}
LOG(WARNING) << "Warning!! No power unit matching \"" << _unit << "\". Using default...\n";
ROCP_WARNING << "Warning!! No power unit matching \"" << _unit << "\". Using default...\n";
return return_type{"watts", units::watt};
}
-2
Просмотреть файл
@@ -24,8 +24,6 @@
#include "lib/common/utility.hpp"
#include "lib/common/logging.hpp"
#include <glog/logging.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>
-2
Просмотреть файл
@@ -25,8 +25,6 @@
#include "lib/common/defines.hpp"
#include "lib/common/logging.hpp"
#include <glog/logging.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <unistd.h>
-2
Просмотреть файл
@@ -23,8 +23,6 @@
#include "lib/common/xml.hpp"
#include "lib/common/logging.hpp"
#include <glog/logging.h>
namespace rocprofiler
{
namespace common
+2 -3
Просмотреть файл
@@ -29,7 +29,6 @@
#include "lib/common/static_object.hpp"
#include "lib/common/utility.hpp"
#include <glog/logging.h>
#include <rocprofiler-register/rocprofiler-register.h>
#include <array>
@@ -179,7 +178,7 @@ struct roctx_api_table
auto*&
get_table_impl()
{
rocprofiler::common::init_logging("ROCTX_LOG_LEVEL");
rocprofiler::common::init_logging("ROCTX");
auto*& tbl = rocprofiler::common::static_object<roctx_api_table>::construct();
@@ -214,7 +213,7 @@ get_table_impl()
ROCP_INFO << "[rocprofiler-sdk-roctx][" << getpid() << "] rocprofiler-register returned code "
<< rocp_reg_status << ": " << rocprofiler_register_error_string(rocp_reg_status);
LOG_IF(WARNING, rocp_reg_status != ROCP_REG_SUCCESS && rocp_reg_status != ROCP_REG_NO_TOOLS)
ROCP_WARNING_IF(rocp_reg_status != ROCP_REG_SUCCESS && rocp_reg_status != ROCP_REG_NO_TOOLS)
<< "[rocprofiler-sdk-roctx][" << getpid()
<< "] rocprofiler-register failed with error code " << rocp_reg_status << ": "
<< rocprofiler_register_error_string(rocp_reg_status);
+2 -2
Просмотреть файл
@@ -383,7 +383,7 @@ format(std::string _fpath, const std::string& _tag)
}
} catch(std::exception& _e)
{
LOG(WARNING) << "[rocprofiler] " << __FUNCTION__ << " threw an exception :: " << _e.what()
ROCP_WARNING << "[rocprofiler] " << __FUNCTION__ << " threw an exception :: " << _e.what()
<< "\n";
}
@@ -395,7 +395,7 @@ format(std::string _fpath, const std::string& _tag)
_fpath = std::regex_replace(_fpath, _re, "$1$4");
} catch(std::exception& _e)
{
LOG(WARNING) << "[rocprofiler] " << __FUNCTION__ << " threw an exception :: " << _e.what()
ROCP_WARNING << "[rocprofiler] " << __FUNCTION__ << " threw an exception :: " << _e.what()
<< "\n";
}
-2
Просмотреть файл
@@ -25,8 +25,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <glog/logging.h>
#include <atomic>
#include <iostream>
#include <mutex>
+1 -1
Просмотреть файл
@@ -84,7 +84,7 @@ output_file::output_file(std::string name,
for(auto& itr : header)
{
LOG_IF(FATAL, itr.empty())
ROCP_FATAL_IF(itr.empty())
<< "CSV file for " << m_name << " was not provided the correct number of headers";
}
+8 -10
Просмотреть файл
@@ -44,8 +44,6 @@
#include <rocprofiler-sdk/cxx/hash.hpp>
#include <rocprofiler-sdk/cxx/operators.hpp>
#include <glog/logging.h>
#include <fmt/core.h>
#include <unistd.h>
#include <cassert>
@@ -632,7 +630,7 @@ get_file_name(buffer_type_t buffer_type)
case buffer_type_t::ROCPROFILER_TOOL_BUFFER_SCRATCH_MEMORY: return "scratch_memory"; break;
}
LOG(FATAL) << "buffer type " << static_cast<std::underlying_type_t<buffer_type_t>>(buffer_type)
ROCP_FATAL << "buffer type " << static_cast<std::underlying_type_t<buffer_type_t>>(buffer_type)
<< " not supported";
return std::string{};
}
@@ -839,7 +837,7 @@ callback_tracing_callback(rocprofiler_callback_tracing_record_t record,
{
if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER)
{
LOG_IF(FATAL, stacked_range.empty())
ROCP_FATAL_IF(stacked_range.empty())
<< "roctxRangePop invoked more times than roctxRangePush on thread "
<< rocprofiler::common::get_tid();
@@ -973,7 +971,7 @@ code_object_tracing_callback(rocprofiler_callback_tracing_record_t record,
->emplace(sym_data->kernel_id,
kernel_symbol_data{get_dereference(sym_data)});
}
LOG_IF(WARNING, !itr.second)
ROCP_WARNING_IF(!itr.second)
<< "duplicate kernel symbol data for kernel_id=" << sym_data->kernel_id;
// add the kernel to the kernel_targets if
@@ -1052,7 +1050,7 @@ buffered_tracing_callback(rocprofiler_context_id_t /*context*/,
{
ROCP_INFO << "Executing buffered tracing callback for " << num_headers << " headers";
LOG_IF(ERROR, headers == nullptr)
ROCP_ERROR_IF(headers == nullptr)
<< "rocprofiler invoked a buffer callback with a null pointer to the array of headers. "
"this should never happen";
@@ -1293,9 +1291,9 @@ counter_record_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_da
counter_record.sgpr_count = kernel_info->sgpr_count;
counter_record.lds_block_size_v = lds_block_size_v;
LOG_IF(FATAL, !kernel_info) << "missing kernel information for kernel_id=" << kernel_id;
ROCP_FATAL_IF(!kernel_info) << "missing kernel information for kernel_id=" << kernel_id;
LOG_IF(ERROR, record_count == 0) << "zero record count for kernel_id=" << kernel_id
ROCP_ERROR_IF(record_count == 0) << "zero record count for kernel_id=" << kernel_id
<< " (name=" << kernel_info->kernel_name << ")";
for(size_t count = 0; count < record_count; count++)
@@ -1798,7 +1796,7 @@ rocprofiler_configure(uint32_t version,
rocprofiler_client_id_t* id)
{
auto logging_cfg = rocprofiler::common::logging_config{.install_failure_handler = true};
common::init_logging("ROCPROF_LOG_LEVEL", logging_cfg);
common::init_logging("ROCPROF", logging_cfg);
FLAGS_colorlogtostderr = true;
// set the client name
@@ -1808,7 +1806,7 @@ rocprofiler_configure(uint32_t version,
client_identifier = id;
// note that rocprofv3 is not the primary tool
LOG_IF(WARNING, priority > 0) << id->name << " has a priority of " << priority
ROCP_WARNING_IF(priority > 0) << id->name << " has a priority of " << priority
<< " (not primary tool)";
// compute major/minor/patch version info
+8 -8
Просмотреть файл
@@ -25,6 +25,7 @@
#include <rocprofiler-sdk/rocprofiler.h>
#include "lib/common/filesystem.hpp"
#include "lib/common/logging.hpp"
#include "lib/common/scope_destructor.hpp"
#include "lib/common/static_object.hpp"
#include "lib/common/utility.hpp"
@@ -34,7 +35,6 @@
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <glog/logging.h>
#include <hsa/hsa.h>
#include <hsa/hsa_api_trace.h>
#include <libdrm/amdgpu.h>
@@ -222,7 +222,7 @@ is_readable(const fs::path& fpath)
{
auto ec = std::error_code{};
auto perms = fs::status(fpath, ec).permissions();
LOG_IF(ERROR, ec) << fmt::format(
ROCP_ERROR_IF(ec) << fmt::format(
"Error getting status for file '{}': {}", fpath.string(), ec.message());
return (!ec && (perms & fs::perms::owner_read) != fs::perms::none);
}
@@ -773,7 +773,7 @@ construct_agent_cache(::HsaApiTable* table)
static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_DRIVER_NODE_ID),
&internal_node_id);
LOG_IF(ERROR, ret != HSA_STATUS_SUCCESS)
ROCP_ERROR_IF(ret != HSA_STATUS_SUCCESS)
<< "hsa_agent_get_info(hsa_agent_t=" << hitr.handle
<< ", HSA_AMD_AGENT_INFO_DRIVER_NODE_ID, ...) returned " << ret
<< " :: " << get_hsa_status_string(ret);
@@ -782,7 +782,7 @@ construct_agent_cache(::HsaApiTable* table)
{
{
auto ret_emplace = rocp_hsa_agent_node_ids.emplace(internal_node_id).second;
LOG_IF(WARNING, !ret_emplace)
ROCP_WARNING_IF(!ret_emplace)
<< "duplicate internal node id " << internal_node_id;
}
@@ -800,7 +800,7 @@ construct_agent_cache(::HsaApiTable* table)
}
}
LOG_IF(FATAL, !rocp_hsa_agent_node_ids.empty())
ROCP_FATAL_IF(!rocp_hsa_agent_node_ids.empty())
<< "Found " << rocp_agents.size() << " rocprofiler agents and " << hsa_agents.size()
<< " HSA agents. HSA agents contained " << rocp_hsa_agent_node_ids.size()
<< " internal node ids not found by rocprofiler: "
@@ -848,7 +848,7 @@ construct_agent_cache(::HsaApiTable* table)
ROCP_INFO << "# agent node maps: " << hsa_agent_node_map.size();
LOG_IF(FATAL, agent_map.size() != hsa_agents.size())
ROCP_FATAL_IF(agent_map.size() != hsa_agents.size())
<< "rocprofiler was only able to map " << agent_map.size()
<< " rocprofiler agents to HSA agents, expected " << hsa_agents.size();
@@ -873,14 +873,14 @@ construct_agent_cache(::HsaApiTable* table)
auto _from = io_link.node_from;
auto _to = io_link.node_to;
LOG_IF(FATAL, _from != node_id)
ROCP_FATAL_IF(_from != node_id)
<< "unexpected condition for node_id=" << node_id << ". io_link[" << i
<< "].node_from=" << _from
<< ". Expected this to match the node_id (node_to=" << _to << ")";
if(agent_map.find(_to) == agent_map.end())
{
LOG(WARNING) << "no agent mapping for io_link[" << i << "].node_to=" << _to
ROCP_WARNING << "no agent mapping for io_link[" << i << "].node_to=" << _to
<< " in rocprofiler agent " << node_id;
continue;
}
-2
Просмотреть файл
@@ -23,8 +23,6 @@
#include "lib/rocprofiler-sdk/allocator.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include <glog/logging.h>
#include <mutex>
namespace rocprofiler
-1
Просмотреть файл
@@ -23,7 +23,6 @@
#include "lib/rocprofiler-sdk/aql/helpers.hpp"
#include <fmt/core.h>
#include <glog/logging.h>
#include <rocprofiler-sdk/fwd.h>
+1 -1
Просмотреть файл
@@ -83,7 +83,7 @@ CounterPacketConstruct::CounterPacketConstruct(rocprofiler_agent_id_t
aqlprofile_validate_pmc_event(aql_agent,
&_metrics.back().events.back(),
&validate_event_result) != HSA_STATUS_SUCCESS);
LOG_IF(FATAL, !validate_event_result)
ROCP_FATAL_IF(!validate_event_result)
<< "Invalid Metric: " << block_index << " " << event_id;
_event_to_metric[std::make_tuple(
static_cast<hsa_ven_amd_aqlprofile_block_name_t>(query_info.id),
+3 -4
Просмотреть файл
@@ -20,7 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <functional>
@@ -78,7 +77,7 @@ findDeviceMetrics(const hsa::AgentCache& agent, const std::unordered_set<std::st
std::vector<counters::Metric> ret;
auto all_counters = counters::getBaseHardwareMetrics();
ROCP_ERROR << "Looking up counters for " << std::string(agent.name());
ROCP_INFO << "Looking up counters for " << std::string(agent.name());
auto gfx_metrics = common::get_val(all_counters, std::string(agent.name()));
if(!gfx_metrics)
{
@@ -119,7 +118,7 @@ TEST(aql_profile, construct_packets)
ASSERT_GT(agents.size(), 0);
for(const auto& [_, agent] : agents)
{
LOG(WARNING) << fmt::format("Found Agent: {}", agent.get_hsa_agent().handle);
ROCP_INFO << fmt::format("Found Agent: {}", agent.get_hsa_agent().handle);
auto metrics = rocprofiler::findDeviceMetrics(agent, {"SQ_WAVES"});
ASSERT_EQ(metrics.size(), 1);
CounterPacketConstruct(agent.get_rocp_agent()->id, metrics);
@@ -135,7 +134,7 @@ TEST(aql_profile, too_many_counters)
ASSERT_GT(agents.size(), 0);
for(const auto& [_, agent] : agents)
{
LOG(WARNING) << fmt::format("Found Agent: {}", agent.get_hsa_agent().handle);
ROCP_INFO << fmt::format("Found Agent: {}", agent.get_hsa_agent().handle);
auto metrics = rocprofiler::findDeviceMetrics(agent, {});
EXPECT_THROW(
+1 -2
Просмотреть файл
@@ -20,7 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <functional>
@@ -81,7 +80,7 @@ findDeviceMetrics(const rocprofiler_agent_t& agent, const std::unordered_set<std
std::vector<counters::Metric> ret;
auto all_counters = counters::getBaseHardwareMetrics();
ROCP_ERROR << "Looking up counters for " << std::string(agent.name);
ROCP_INFO << "Looking up counters for " << std::string(agent.name);
auto gfx_metrics = common::get_val(all_counters, std::string(agent.name));
if(!gfx_metrics)
+2 -4
Просмотреть файл
@@ -34,8 +34,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <glog/logging.h>
#include <atomic>
#include <exception>
#include <mutex>
@@ -157,7 +155,7 @@ flush(rocprofiler_buffer_id_t buffer_id, bool wait)
auto* task_group =
internal_threading::get_task_group(rocprofiler_callback_thread_t{buff->task_group_id});
LOG_IF(FATAL, !task_group)
ROCP_FATAL_IF(!task_group)
<< "buffer (" << buffer_id.handle
<< ") flush request received after the task group for handling request was destroyed";
@@ -177,7 +175,7 @@ flush(rocprofiler_buffer_id_t buffer_id, bool wait)
auto idx = buff->buffer_idx++;
auto _task = [buffer_id, idx, offset]() {
LOG_IF(ERROR, registration::get_fini_status() > 0)
ROCP_ERROR_IF(registration::get_fini_status() > 0)
<< "executing buffer (" << buffer_id.handle << ") flush task finalization!";
auto& buff_v = CHECK_NOTNULL(get_buffers())->at(buffer_id.handle - offset);
+1 -2
Просмотреть файл
@@ -26,6 +26,7 @@
#include <rocprofiler-sdk/marker/table_id.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include "lib/common/logging.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
#include "lib/rocprofiler-sdk/context/domain.hpp"
#include "lib/rocprofiler-sdk/hip/hip.hpp"
@@ -37,8 +38,6 @@
#include "lib/rocprofiler-sdk/page_migration/page_migration.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include <glog/logging.h>
#include <atomic>
#include <limits>
#include <stdexcept>
+1 -3
Просмотреть файл
@@ -38,8 +38,6 @@
#include "lib/rocprofiler-sdk/marker/marker.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include <glog/logging.h>
#include <atomic>
#include <cstdint>
#include <vector>
@@ -358,7 +356,7 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
const char* name = "(unknown)";
rocprofiler_query_callback_tracing_kind_operation_name(
record.kind, record.operation, &name, nullptr);
LOG(WARNING) << __FUNCTION__
ROCP_WARNING << __FUNCTION__
<< " invoked with a max dereference count > 1 when the record.phase == "
<< "ROCPROFILER_CALLBACK_PHASE_ENTER for '" << name
<< "' record. This may result in a segmentation fault";
+22 -22
Просмотреть файл
@@ -35,7 +35,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
#include <glog/logging.h>
#include <hsa/hsa.h>
#include <hsa/hsa_api_trace.h>
#include <hsa/hsa_ven_amd_loader.h>
@@ -48,14 +47,6 @@
#include <utility>
#include <vector>
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(FATAL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(FATAL)
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(NON_CI_LEVEL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(NON_CI_LEVEL)
#endif
namespace rocprofiler
{
namespace code_object
@@ -259,7 +250,7 @@ accum_vgpr_count(std::string_view name, kernel_descriptor_t kernel_code)
emplaced = warned.emplace(name).second;
}
LOG_IF(WARNING, emplaced) << "Missing support for accum_vgpr_count for " << name;
ROCP_INFO_IF(emplaced) << "Missing support for accum_vgpr_count for " << name;
return 0;
}
@@ -292,7 +283,16 @@ sgpr_count(std::string_view name, kernel_descriptor_t kernel_code)
}
}
LOG(WARNING) << "Missing support for sgpr_count for " << name;
bool emplaced = false;
{
static auto warned = std::unordered_set<std::string>{};
static auto mtx = std::mutex{};
auto lk = std::unique_lock<std::mutex>{mtx};
emplaced = warned.emplace(name).second;
}
ROCP_INFO_IF(emplaced) << "Missing support for sgpr_count for " << name;
return 0;
}
@@ -363,7 +363,7 @@ get_kernel_descriptor(uint64_t kernel_object)
reinterpret_cast<const void**>(&kernel_code));
if(status == HSA_STATUS_SUCCESS) return kernel_code;
LOG(WARNING) << "hsa_ven_amd_loader_query_host_address(kernel_object=" << kernel_object
ROCP_WARNING << "hsa_ven_amd_loader_query_host_address(kernel_object=" << kernel_object
<< ") returned " << status << ": " << get_status_string(status);
// NOLINTNEXTLINE(performance-no-int-to-ptr)
@@ -425,7 +425,7 @@ executable_iterate_agent_symbols_load_callback(hsa_executable_t executabl
#define ROCP_HSA_CORE_GET_EXE_SYMBOL_INFO(...) \
{ \
auto _status = core_table.hsa_executable_symbol_get_info_fn(symbol, __VA_ARGS__); \
LOG_IF(ERROR, _status != HSA_STATUS_SUCCESS) \
ROCP_ERROR_IF(_status != HSA_STATUS_SUCCESS) \
<< "core_table.hsa_executable_symbol_get_info_fn(hsa_executable_symbol_t{.handle=" \
<< symbol.handle << "}, " << #__VA_ARGS__ << " failed"; \
if(_status != HSA_STATUS_SUCCESS) return _status; \
@@ -447,7 +447,7 @@ executable_iterate_agent_symbols_load_callback(hsa_executable_t executabl
// if there is an existing matching kernel symbol, return success and move onto next symbol
if(exists) return HSA_STATUS_SUCCESS;
LOG_IF(FATAL, data.size == 0) << "kernel symbol did not properly initialized the size field "
ROCP_FATAL_IF(data.size == 0) << "kernel symbol did not properly initialized the size field "
"upon construction (this is likely a compiler bug)";
auto type = hsa_symbol_kind_t{};
@@ -552,7 +552,7 @@ code_object_load_callback(hsa_executable_t executable,
{ \
auto _status = loader_table.hsa_ven_amd_loader_loaded_code_object_get_info( \
loaded_code_object, __VA_ARGS__); \
LOG_IF(ERROR, _status != HSA_STATUS_SUCCESS) \
ROCP_ERROR_IF(_status != HSA_STATUS_SUCCESS) \
<< "loader_table.hsa_ven_amd_loader_loaded_code_object_get_info(loaded_code_object, " \
<< #__VA_ARGS__ << " failed"; \
if(_status != HSA_STATUS_SUCCESS) return _status; \
@@ -563,7 +563,7 @@ code_object_load_callback(hsa_executable_t executable,
auto& data = code_obj_v.rocp_data;
uint32_t _storage_type = ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_NONE;
LOG_IF(FATAL, data.size == 0) << "code object did not properly initialized the size field upon "
ROCP_FATAL_IF(data.size == 0) << "code object did not properly initialized the size field upon "
"construction (this is likely a compiler bug)";
code_obj_v.hsa_executable = executable;
@@ -596,7 +596,7 @@ code_object_load_callback(hsa_executable_t executable,
ROCP_HSA_VEN_LOADER_GET_CODE_OBJECT_INFO(
HSA_VEN_AMD_LOADER_LOADED_CODE_OBJECT_INFO_CODE_OBJECT_STORAGE_TYPE, &_storage_type);
LOG_IF(FATAL, _storage_type >= ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_LAST)
ROCP_FATAL_IF(_storage_type >= ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_LAST)
<< "HSA_VEN_AMD_LOADER_LOADED_CODE_OBJECT_INFO_CODE_OBJECT_STORAGE_TYPE returned an "
"unsupported code object storage type. Expected 0=none, 1=file, or 2=memory but "
"received a value of "
@@ -621,7 +621,7 @@ code_object_load_callback(hsa_executable_t executable,
}
else if(_storage_type == HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_NONE)
{
LOG(WARNING) << "Code object storage type of none was ignored";
ROCP_WARNING << "Code object storage type of none was ignored";
return HSA_STATUS_SUCCESS;
}
@@ -920,7 +920,7 @@ shutdown(hsa_executable_t executable)
auto tidx = common::get_tid();
for(auto& itr : _unloaded)
{
LOG_IF(FATAL, itr.object == nullptr);
ROCP_FATAL_IF(itr.object == nullptr);
for(const auto* citr : itr.object->contexts)
{
if(citr->callback_tracer->domains(CODE_OBJECT_KIND, CODE_OBJECT_LOAD))
@@ -992,7 +992,7 @@ initialize(HsaApiTable* table)
auto _status = core_table.hsa_system_get_major_extension_table_fn(
HSA_EXTENSION_AMD_LOADER, 1, sizeof(hsa_loader_table_t), &get_loader_table());
LOG_IF(ERROR, _status != HSA_STATUS_SUCCESS)
ROCP_ERROR_IF(_status != HSA_STATUS_SUCCESS)
<< "hsa_system_get_major_extension_table failed: " << get_status_string(_status);
if(_status == HSA_STATUS_SUCCESS)
@@ -1001,9 +1001,9 @@ initialize(HsaApiTable* table)
get_destroy_function() = CHECK_NOTNULL(core_table.hsa_executable_destroy_fn);
core_table.hsa_executable_freeze_fn = executable_freeze;
core_table.hsa_executable_destroy_fn = executable_destroy;
LOG_IF(FATAL, get_freeze_function() == core_table.hsa_executable_freeze_fn)
ROCP_FATAL_IF(get_freeze_function() == core_table.hsa_executable_freeze_fn)
<< "infinite recursion";
LOG_IF(FATAL, get_destroy_function() == core_table.hsa_executable_destroy_fn)
ROCP_FATAL_IF(get_destroy_function() == core_table.hsa_executable_destroy_fn)
<< "infinite recursion";
}
}
-1
Просмотреть файл
@@ -27,7 +27,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
#include <glog/logging.h>
#include <hsa/hsa_api_trace.h>
#include <hsa/hsa_ven_amd_loader.h>
-1
Просмотреть файл
@@ -27,7 +27,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hsa.h>
#include <glog/logging.h>
#include <hsa/hsa_api_trace.h>
#include <hsa/hsa_ven_amd_loader.h>
-2
Просмотреть файл
@@ -34,8 +34,6 @@
#include "lib/rocprofiler-sdk/counters/core.hpp"
#include "lib/rocprofiler-sdk/thread_trace/att_core.hpp"
#include <glog/logging.h>
#include <unistd.h>
#include <atomic>
#include <cstddef>
+5 -7
Просмотреть файл
@@ -28,8 +28,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <glog/logging.h>
namespace rocprofiler
{
namespace context
@@ -64,7 +62,7 @@ correlation_id::add_ref_count()
{
auto _ret = m_ref_count.fetch_add(1);
LOG_IF(FATAL, _ret == 0) << "correlation id already retired";
ROCP_FATAL_IF(_ret == 0) << "correlation id already retired";
return _ret;
}
@@ -74,7 +72,7 @@ correlation_id::sub_ref_count()
{
auto _ret = m_ref_count.fetch_sub(1);
LOG_IF(FATAL, _ret == 0) << "correlation id underflow";
ROCP_FATAL_IF(_ret == 0) << "correlation id underflow";
if(_ret == 1)
{
@@ -102,7 +100,7 @@ correlation_id::sub_ref_count()
ROCPROFILER_BUFFER_TRACING_CORRELATION_ID_RETIREMENT,
record);
LOG_IF(FATAL, !success) << "failed to emplace correlation id retirement";
ROCP_FATAL_IF(!success) << "failed to emplace correlation id retirement";
}
}
}
@@ -125,7 +123,7 @@ correlation_id::sub_kern_count()
correlation_id*
correlation_tracing_service::construct(uint32_t _init_ref_count)
{
LOG_IF(FATAL, _init_ref_count == 0) << "must have reference count > 0";
ROCP_FATAL_IF(_init_ref_count == 0) << "must have reference count > 0";
auto _internal_id = get_unique_internal_id();
auto* corr_id_map = get_correlation_id_map();
@@ -160,7 +158,7 @@ pop_latest_correlation_id(correlation_id* val)
return nullptr;
}
LOG_IF(ERROR, get_latest_correlation_id_impl().back() != val)
ROCP_ERROR_IF(get_latest_correlation_id_impl().back() != val)
<< "pop_latest_correlation_id is happening out of order for " << val->internal
<< ". top of stack is " << get_latest_correlation_id_impl().back()->internal;
-2
Просмотреть файл
@@ -25,8 +25,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <glog/logging.h>
#include <limits>
namespace rocprofiler
+1 -1
Просмотреть файл
@@ -79,7 +79,7 @@ getBlockDimensions(std::string_view agent, const Metric& metric)
}
else
{
ROCP_ERROR << "Unknown AQL Profiler Dimension " << id << " " << extent;
ROCP_WARNING << "Unknown AQL Profiler Dimension " << id << " " << extent;
}
}
}
+5 -3
Просмотреть файл
@@ -22,11 +22,13 @@
#pragma once
#include <unordered_map>
#include <rocprofiler-sdk/fwd.h>
#include <glog/logging.h>
#include "lib/common/logging.hpp"
#include <limits>
#include <string_view>
#include <unordered_map>
namespace rocprofiler
{
+4 -4
Просмотреть файл
@@ -88,7 +88,7 @@ loadXml(const std::string& filename, bool load_constants = false)
ROCP_INFO << "Loading Counter Config: " << filename;
// todo: return unique_ptr....
auto xml = common::Xml::Create(filename);
LOG_IF(FATAL, !xml)
ROCP_FATAL_IF(!xml)
<< "Could not open XML Counter Config File (set env ROCPROFILER_METRICS_PATH)";
const auto& constant_metrics = get_constants();
@@ -128,7 +128,7 @@ loadXml(const std::string& filename, bool load_constants = false)
}
}
LOG_IF(FATAL, current_id() > 65536)
ROCP_FATAL_IF(current_id() > 65536)
<< "Counter count exceeds 16 bits, which may break counter id output";
return ret;
}
@@ -164,7 +164,7 @@ MetricMap
getDerivedHardwareMetrics()
{
auto counters_path = findViaEnvironment("derived_counters.xml");
LOG_IF(FATAL, !common::filesystem::exists(counters_path))
ROCP_FATAL_IF(!common::filesystem::exists(counters_path))
<< "metric xml file '" << counters_path << "' does not exist";
return loadXml(counters_path);
}
@@ -173,7 +173,7 @@ MetricMap
getBaseHardwareMetrics()
{
auto counters_path = findViaEnvironment("basic_counters.xml");
LOG_IF(FATAL, !common::filesystem::exists(counters_path))
ROCP_FATAL_IF(!common::filesystem::exists(counters_path))
<< "metric xml file '" << counters_path << "' does not exist";
return loadXml(counters_path, true);
}
-2
Просмотреть файл
@@ -70,8 +70,6 @@
#include <stdexcept>
#include <string>
#include <glog/logging.h>
#include "raw_ast.hpp"
int
+3 -5
Просмотреть файл
@@ -10,8 +10,6 @@ using namespace rocprofiler::counters;
#include <stdio.h>
#include <string>
#include <glog/logging.h>
#include "raw_ast.hpp"
int yyparse(rocprofiler::counters::RawAST** result);
@@ -81,17 +79,17 @@ exp: NUMBER { $$ = new RawAST(NUMBER_NODE, $1); }
reduce_dim_args: NAME { $$ = new LinkedList($1, NULL);
reduce_dim_args: NAME { $$ = new LinkedList($1, NULL);
free($1);
}
| NAME CM reduce_dim_args { $$ = new LinkedList($1, $3);
| NAME CM reduce_dim_args { $$ = new LinkedList($1, $3);
free($1);
}
;
select_dim_args: NAME EQUALS NUMBER { $$ = new LinkedList($1, $3, NULL);
select_dim_args: NAME EQUALS NUMBER { $$ = new LinkedList($1, $3, NULL);
free($1);
}
| NAME EQUALS NUMBER CM select_dim_args { $$ = new LinkedList($1, $3, $5);
+6 -7
Просмотреть файл
@@ -22,6 +22,12 @@
#pragma once
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/counters/id_decode.hpp"
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <map>
#include <optional>
#include <string>
@@ -31,13 +37,6 @@
#include <variant>
#include <vector>
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <glog/logging.h>
#include "lib/common/utility.hpp"
#include "lib/rocprofiler-sdk/counters/id_decode.hpp"
namespace rocprofiler
{
namespace counters
+2 -2
Просмотреть файл
@@ -111,7 +111,7 @@ findDeviceMetrics(const hsa::AgentCache& agent, const std::unordered_set<std::st
std::vector<counters::Metric> ret;
auto all_counters = counters::getMetricMap();
ROCP_ERROR << "Looking up counters for " << std::string(agent.name());
ROCP_INFO << "Looking up counters for " << std::string(agent.name());
auto gfx_metrics = common::get_val(*all_counters, std::string(agent.name()));
if(!gfx_metrics)
{
@@ -797,4 +797,4 @@ TEST(core, init_agent_collection)
rocprofiler_destroy_buffer(opt_buff_id);
registration::set_init_status(1);
context::pop_client(1);
}
}
+2 -2
Просмотреть файл
@@ -182,7 +182,7 @@ findDeviceMetrics(const hsa::AgentCache& agent, const std::unordered_set<std::st
std::vector<counters::Metric> ret;
auto all_counters = counters::getMetricMap();
ROCP_ERROR << "Looking up counters for " << std::string(agent.name());
ROCP_INFO << "Looking up counters for " << std::string(agent.name());
auto gfx_metrics = common::get_val(*all_counters, std::string(agent.name()));
if(!gfx_metrics)
{
@@ -234,7 +234,7 @@ TEST(dimension, block_dim_test)
*/
std::unordered_map<counters::rocprofiler_profile_counter_instance_types, uint64_t>
rocp_dims;
ROCP_ERROR << metric.name() << " " << metric.special();
ROCP_INFO << metric.name() << " " << metric.special();
if(!metric.special().empty())
{
rocp_dims[counters::rocprofiler_profile_counter_instance_types::
+2 -3
Просмотреть файл
@@ -22,7 +22,6 @@
#include "metrics_test.h"
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <algorithm>
@@ -75,7 +74,7 @@ TEST(metrics, base_load)
auto find = [&rocp_data_v](const auto& v) -> std::optional<counters::Metric> {
for(const auto& ditr : rocp_data_v)
{
ROCP_ERROR << fmt::format("{}", ditr);
ROCP_INFO << fmt::format("{}", ditr);
if(ditr.name() == v.name()) return ditr;
}
return std::nullopt;
@@ -197,4 +196,4 @@ TEST(metrics, check_public_api_query)
EXPECT_EQ(version.is_derived, !metric.expression().empty());
EXPECT_EQ(version.description, metric.description().c_str());
}
}
}
+3 -4
Просмотреть файл
@@ -35,7 +35,6 @@
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/fwd.h>
#include <glog/logging.h>
#include <hip/driver_types.h>
#include <hip/hip_runtime_api.h>
// must be included after runtime api
@@ -192,7 +191,7 @@ hip_api_impl<TableIdx, OpIdx>::functor(Args... args)
constexpr auto external_corr_id_domain_idx =
hip_domain_info<TableIdx>::external_correlation_id_domain_idx;
LOG_IF(INFO, registration::get_fini_status() != 0) << "Executing " << info_type::name;
ROCP_INFO_IF(registration::get_fini_status() != 0) << "Executing " << info_type::name;
constexpr auto ref_count = 2;
auto thr_id = common::get_tid();
@@ -216,7 +215,7 @@ hip_api_impl<TableIdx, OpIdx>::functor(Args... args)
return;
}
LOG_IF(FATAL, external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
ROCP_FATAL_IF(external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
<< "missing external correlation ids";
auto buffer_record = common::init_public_api_struct(buffered_api_data_t{});
@@ -438,7 +437,7 @@ copy_table(Tp* _orig, uint64_t _tbl_instance, std::integral_constant<size_t, OpI
auto& _copy_table = _info.get_table(get_table());
auto& _copy_func = _info.get_table_func(_copy_table);
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _info.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
+7 -9
Просмотреть файл
@@ -20,10 +20,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include "agent_cache.hpp"
#include "lib/rocprofiler-sdk/hsa/agent_cache.hpp"
#include "lib/common/logging.hpp"
#include <fmt/core.h>
#include <glog/logging.h>
#include <stdexcept>
namespace
@@ -45,16 +45,14 @@ FindGlobalPool(hsa_amd_memory_pool_t pool, void* data, bool kern_arg)
auto [api_ptr, pool_ptr] =
*static_cast<std::pair<const AmdExtTable*, hsa_amd_memory_pool_t*>*>(data);
hsa_amd_segment_t segment;
LOG_IF(FATAL,
api_ptr->hsa_amd_memory_pool_get_info_fn(
pool, HSA_AMD_MEMORY_POOL_INFO_SEGMENT, &segment) == HSA_STATUS_ERROR)
ROCP_FATAL_IF(api_ptr->hsa_amd_memory_pool_get_info_fn(
pool, HSA_AMD_MEMORY_POOL_INFO_SEGMENT, &segment) == HSA_STATUS_ERROR)
<< "Could not get pool segment";
if(HSA_AMD_SEGMENT_GLOBAL != segment) return HSA_STATUS_SUCCESS;
uint32_t flag;
LOG_IF(FATAL,
api_ptr->hsa_amd_memory_pool_get_info_fn(
pool, HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS, &flag) == HSA_STATUS_ERROR)
ROCP_FATAL_IF(api_ptr->hsa_amd_memory_pool_get_info_fn(
pool, HSA_AMD_MEMORY_POOL_INFO_GLOBAL_FLAGS, &flag) == HSA_STATUS_ERROR)
<< "Could not get flag value";
uint32_t karg_st = flag & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_KERNARG_INIT;
if((karg_st == 0 && kern_arg) || (karg_st != 0 && !kern_arg))
@@ -143,7 +141,7 @@ AgentCache::AgentCache(const rocprofiler_agent_t* rocp_agent,
init_gpu_pool(ext_table, *this);
} catch(std::runtime_error& e)
{
LOG(WARNING) << fmt::format(
ROCP_WARNING << fmt::format(
"Buffer creation for Agent {} failed ({}), Some profiling options will be unavailable.",
rocp_agent->node_id,
e.what());
+16 -18
Просмотреть файл
@@ -21,6 +21,7 @@
// THE SOFTWARE.
#include "lib/rocprofiler-sdk/hsa/async_copy.hpp"
#include "lib/common/logging.hpp"
#include "lib/common/scope_destructor.hpp"
#include "lib/common/static_object.hpp"
#include "lib/common/utility.hpp"
@@ -47,21 +48,14 @@
#define ROCP_HSA_TABLE_CALL(SEVERITY, EXPR) \
auto ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) = (EXPR); \
LOG_IF(SEVERITY, ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) != HSA_STATUS_SUCCESS) \
ROCP_CI_LOG_IF(SEVERITY, \
ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) != HSA_STATUS_SUCCESS) \
<< #EXPR << " returned non-zero status code " \
<< ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) << " :: " \
<< ::rocprofiler::hsa::get_hsa_status_string( \
ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__)) \
<< " "
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(FATAL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_FATAL
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(NON_CI_LEVEL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(NON_CI_LEVEL)
#endif
#define ROCPROFILER_LIB_ROCPROFILER_HSA_ASYNC_COPY_CPP_IMPL 1
// template specializations
@@ -184,7 +178,7 @@ struct async_copy_data
async_copy_data::callback_data_t
async_copy_data::get_callback_data(timestamp_t _beg, timestamp_t _end) const
{
LOG_IF(FATAL, direction == ROCPROFILER_MEMORY_COPY_NONE) << "direction has not been set";
ROCP_FATAL_IF(direction == ROCPROFILER_MEMORY_COPY_NONE) << "direction has not been set";
return common::init_public_api_struct(
callback_data_t{}, _beg, _end, dst_agent, src_agent, bytes_copied);
@@ -195,7 +189,7 @@ async_copy_data::get_buffered_record(const context_t* _ctx,
timestamp_t _beg,
timestamp_t _end) const
{
LOG_IF(FATAL, direction == ROCPROFILER_MEMORY_COPY_NONE) << "direction has not been set";
ROCP_FATAL_IF(direction == ROCPROFILER_MEMORY_COPY_NONE) << "direction has not been set";
auto _external_corr_id =
(_ctx) ? tracing_data.external_correlation_ids.at(_ctx) : context::null_user_data;
@@ -233,7 +227,11 @@ private:
std::atomic<int64_t> m_count = 0;
};
active_signals::active_signals() { create(); }
active_signals::active_signals()
{
// only create if not started finalization
if(registration::get_fini_status() == 0) create();
}
void
active_signals::create()
@@ -444,9 +442,9 @@ async_copy_handler(hsa_signal_value_t signal_value, void* arg)
const hsa_signal_value_t new_value =
get_core_table()->hsa_signal_load_relaxed_fn(_data->orig_signal) - 1;
LOG_IF(ERROR, signal_value != new_value) << "bad original signal value in " << __FUNCTION__;
ROCP_ERROR_IF(signal_value != new_value) << "bad original signal value in " << __FUNCTION__;
// Move to ROCP_TRACE when rebasing
LOG(INFO) << "Decrementing Signal: " << std::hex << _data->orig_signal.handle << std::dec;
ROCP_INFO << "Decrementing Signal: " << std::hex << _data->orig_signal.handle << std::dec;
get_core_table()->hsa_signal_store_screlease_fn(_data->orig_signal, signal_value);
}
@@ -582,10 +580,10 @@ async_copy_impl(Args... args)
}
else
{
LOG_IF(ERROR, !_rocp_src_agent)
ROCP_ERROR_IF(!_rocp_src_agent)
<< "failed to find source rocprofiler agent for hsa agent with handle="
<< _hsa_src_agent.handle;
LOG_IF(ERROR, !_rocp_dst_agent)
ROCP_ERROR_IF(!_rocp_dst_agent)
<< "failed to find destination rocprofiler agent for hsa agent with handle="
<< _hsa_dst_agent.handle;
}
@@ -712,7 +710,7 @@ async_copy_impl(Args... args)
_data->orig_signal = _completion_signal;
_completion_signal = _data->rocp_signal;
LOG(INFO) << "Memcpy Original Signal " << std::hex << _data->orig_signal.handle << std::dec
ROCP_INFO << "Memcpy Original Signal " << std::hex << _data->orig_signal.handle << std::dec
<< ": " << original_value << " | Replacement Signal: " << std::hex
<< _completion_signal.handle << std::dec << ": 1";
@@ -745,7 +743,7 @@ async_copy_save(hsa_amd_ext_table_t* _orig, uint64_t _tbl_instance)
// table with copy function
auto& _copy_func = get_next_dispatch<TableIdx, OpIdx>();
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _meta.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
+3 -5
Просмотреть файл
@@ -41,8 +41,6 @@
#include <rocprofiler-sdk/hsa/core_api_id.h>
#include <rocprofiler-sdk/hsa/table_id.h>
#include <glog/logging.h>
#include <atomic>
#include <cstddef>
#include <cstdint>
@@ -308,7 +306,7 @@ hsa_api_impl<TableIdx, OpIdx>::functor(Args... args)
constexpr auto external_corr_id_domain_idx =
hsa_domain_info<TableIdx>::external_correlation_id_domain_idx;
LOG_IF(INFO, registration::get_fini_status() != 0) << "Executing " << info_type::name;
ROCP_INFO_IF(registration::get_fini_status() != 0) << "Executing " << info_type::name;
if(registration::get_fini_status() != 0)
{
@@ -341,7 +339,7 @@ hsa_api_impl<TableIdx, OpIdx>::functor(Args... args)
return;
}
LOG_IF(FATAL, external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
ROCP_FATAL_IF(external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
<< "missing external correlation ids";
auto buffer_record = common::init_public_api_struct(buffer_hsa_api_record_t{});
@@ -563,7 +561,7 @@ copy_table(Tp* _orig, uint64_t _tbl_instance, std::integral_constant<size_t, OpI
auto& _copy_table = _info.get_table(hsa_table_lookup<TableIdx>{}(LookupT{}));
auto& _copy_func = _info.get_table_func(_copy_table);
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _info.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
+1 -1
Просмотреть файл
@@ -85,7 +85,7 @@ hsa_barrier::enqueue_packet(const Queue* queue)
rocprofiler_packet barrier{};
barrier.barrier_and.header = HSA_PACKET_TYPE_BARRIER_AND << HSA_PACKET_HEADER_TYPE;
barrier.barrier_and.dep_signal[0] = _barrier_signal;
ROCP_ERROR << "Barrier Added: " << _barrier_signal.handle;
ROCP_INFO << "Barrier Added: " << _barrier_signal.handle;
return barrier;
}
+4 -3
Просмотреть файл
@@ -24,6 +24,7 @@
#if ROCPROFILER_SDK_HSA_PC_SAMPLING > 0
# include "lib/common/logging.hpp"
# include "lib/rocprofiler-sdk/hsa/defines.hpp"
# include "lib/rocprofiler-sdk/hsa/hsa.hpp"
@@ -133,18 +134,18 @@ copy_table(hsa_pc_sampling_ext_table_t* _orig, uint64_t _tbl_instance)
auto& _copy_table = _info.get_table(hsa_table_lookup<TableIdx>{}(LookupT{}));
auto& _copy_func = _info.get_table_func(_copy_table);
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _info.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
if(!_copy_func)
{
LOG(INFO) << "copying table entry for " << _info.name;
ROCP_INFO << "copying table entry for " << _info.name;
_copy_func = _orig_func;
}
else
{
LOG(INFO) << "skipping copying table entry for " << _info.name
ROCP_INFO << "skipping copying table entry for " << _info.name
<< " from table instance " << _tbl_instance;
}
}
+6 -15
Просмотреть файл
@@ -36,7 +36,6 @@
#include <rocprofiler-sdk/external_correlation.h>
#include <rocprofiler-sdk/fwd.h>
#include <glog/logging.h>
#include <hsa/hsa.h>
#include <hsa/hsa_ext_amd.h>
@@ -59,14 +58,6 @@ static_assert(offsetof(hsa_ext_amd_aql_pm4_packet_t, completion_signal) ==
offsetof(hsa_barrier_or_packet_t, completion_signal),
"unexpected ABI incompatibility");
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(FATAL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_FATAL
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(NON_CI_LEVEL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(NON_CI_LEVEL)
#endif
namespace rocprofiler
{
namespace hsa
@@ -150,7 +141,7 @@ AsyncSignalHandler(hsa_signal_value_t /*signal_v*/, void* data)
auto* _corr_id = queue_info_session.correlation_id;
if(_corr_id)
{
LOG_IF(FATAL, _corr_id->get_ref_count() == 0)
ROCP_FATAL_IF(_corr_id->get_ref_count() == 0)
<< "reference counter for correlation id " << _corr_id->internal << " from thread "
<< _corr_id->thread_idx << " has no reference count";
_corr_id->sub_kern_count();
@@ -219,7 +210,7 @@ WriteInterceptor(const void* packets,
_packets.emplace_back(barrier);
};
LOG_IF(FATAL, data == nullptr) << "WriteInterceptor was not passed a pointer to the queue";
ROCP_FATAL_IF(data == nullptr) << "WriteInterceptor was not passed a pointer to the queue";
auto& queue = *static_cast<Queue*>(data);
@@ -419,7 +410,7 @@ WriteInterceptor(const void* packets,
transformed_packets.emplace_back(barrier);
}
LOG_IF(FATAL, packet_type != HSA_PACKET_TYPE_KERNEL_DISPATCH)
ROCP_FATAL_IF(packet_type != HSA_PACKET_TYPE_KERNEL_DISPATCH)
<< "get_kernel_id below might need to be updated";
// Enqueue the signal into the handler. Will call completed_cb when
@@ -520,7 +511,7 @@ Queue::signal_async_handler(const hsa_signal_t& signal, Queue::queue_info_sessio
#endif
hsa_status_t status = _ext_api.hsa_amd_signal_async_handler_fn(
signal, HSA_SIGNAL_CONDITION_EQ, -1, AsyncSignalHandler, static_cast<void*>(data));
LOG_IF(FATAL, status != HSA_STATUS_SUCCESS && status != HSA_STATUS_INFO_BREAK)
ROCP_FATAL_IF(status != HSA_STATUS_SUCCESS && status != HSA_STATUS_INFO_BREAK)
<< "Error: hsa_amd_signal_async_handler failed";
}
@@ -528,7 +519,7 @@ void
Queue::create_signal(uint32_t attribute, hsa_signal_t* signal) const
{
hsa_status_t status = _ext_api.hsa_amd_signal_create_fn(1, 0, nullptr, attribute, signal);
LOG_IF(FATAL, status != HSA_STATUS_SUCCESS && status != HSA_STATUS_INFO_BREAK)
ROCP_FATAL_IF(status != HSA_STATUS_SUCCESS && status != HSA_STATUS_INFO_BREAK)
<< "Error: hsa_amd_signal_create failed";
}
@@ -546,7 +537,7 @@ void
Queue::register_callback(ClientID id, queue_cb_t enqueue_cb, completed_cb_t complete_cb)
{
_callbacks.wlock([&](auto& map) {
LOG_IF(FATAL, rocprofiler::common::get_val(map, id)) << "ID already exists!";
ROCP_FATAL_IF(rocprofiler::common::get_val(map, id)) << "ID already exists!";
_notifiers++;
map[id] = std::make_pair(enqueue_cb, complete_cb);
});
-2
Просмотреть файл
@@ -29,8 +29,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <glog/logging.h>
namespace rocprofiler
{
namespace hsa
+6 -7
Просмотреть файл
@@ -35,7 +35,6 @@
#include <rocprofiler-sdk/hsa/api_id.h>
#include <rocprofiler-sdk/hsa/table_id.h>
#include <glog/logging.h>
#include <hsa/amd_hsa_signal.h>
#include <hsa/hsa.h>
#include <hsa/hsa_amd_tool.h>
@@ -311,18 +310,18 @@ copy_table(hsa_amd_tool_table_t* _orig, uint64_t _tbl_instance)
auto& _copy_table = _info.get_table(hsa_table_lookup<TableIdx>{}(LookupT{}));
auto& _copy_func = _info.get_table_func(_copy_table);
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _info.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
if(!_copy_func)
{
LOG(INFO) << "copying table entry for " << _info.name;
ROCP_INFO << "copying table entry for " << _info.name;
_copy_func = _orig_func;
}
else
{
LOG(INFO) << "skipping copying table entry for " << _info.name
ROCP_INFO << "skipping copying table entry for " << _info.name
<< " from table instance " << _tbl_instance;
}
}
@@ -414,7 +413,7 @@ get_tls_pair(rocprofiler_callback_phase_t phase)
// duplicate entries
using clear_containers = std::true_type;
LOG_IF(FATAL, held) << "Overwriting scratch memory TLS data";
ROCP_FATAL_IF(held) << "Overwriting scratch memory TLS data";
held = true;
tracing::populate_contexts(ROCPROFILER_CALLBACK_TRACING_SCRATCH_MEMORY,
ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY,
@@ -471,7 +470,7 @@ impl(Args... args)
}
});
LOG_IF(FATAL, !found_agent) << fmt::format(
ROCP_FATAL_IF(!found_agent) << fmt::format(
"Scratch memory tracing: Could not find a valid agent for queue id {}", hsa_queue->id);
return _agent_id;
};
@@ -581,7 +580,7 @@ update_table(const context_array_t& ctxs, hsa_amd_tool_table_t* _orig)
if(!should_wrap_functor(ctxs, OpIdx)) return;
LOG(INFO) << "updating table entry for " << _info.name;
ROCP_INFO << "updating table entry for " << _info.name;
auto _meta = hsa_api_meta<TableIdx, OpIdx>{};
auto& _table = _meta.get_table(_orig);
+1 -1
Просмотреть файл
@@ -199,7 +199,7 @@ rocprofiler_at_intercept_table_registration(rocprofiler_intercept_library_cb_t c
if(rocprofiler::registration::get_init_status() > 0)
return ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED;
LOG_IF(WARNING, libs == 0) << "invoking " << __FUNCTION__ << " with a value of zero is a no-op";
ROCP_WARNING_IF(libs == 0) << "invoking " << __FUNCTION__ << " with a value of zero is a no-op";
rocprofiler::intercept_table::update_intercepts(
callback, libs, data, rocprofiler::intercept_table::intercept_library_seq);
-1
Просмотреть файл
@@ -33,7 +33,6 @@
#include "lib/rocprofiler-sdk/internal_threading.hpp"
#include "lib/rocprofiler-sdk/registration.hpp"
#include <glog/logging.h>
#include <pthread.h>
#include <cstdint>
-8
Просмотреть файл
@@ -24,14 +24,6 @@
#include <string_view>
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(FATAL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_FATAL
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(NON_CI_LEVEL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(NON_CI_LEVEL)
#endif
namespace rocprofiler
{
namespace kernel_dispatch
+3 -9
Просмотреть файл
@@ -21,6 +21,7 @@
// THE SOFTWARE.
#include "lib/rocprofiler-sdk/kernel_dispatch/tracing.hpp"
#include "lib/common/logging.hpp"
#include "lib/rocprofiler-sdk/agent.hpp"
#include "lib/rocprofiler-sdk/buffer.hpp"
#include "lib/rocprofiler-sdk/context/context.hpp"
@@ -35,17 +36,10 @@
#include <string_view>
#if defined(ROCPROFILER_CI)
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(FATAL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) ROCP_FATAL
#else
# define ROCP_CI_LOG_IF(NON_CI_LEVEL, ...) LOG_IF(NON_CI_LEVEL, __VA_ARGS__)
# define ROCP_CI_LOG(NON_CI_LEVEL, ...) LOG(NON_CI_LEVEL)
#endif
#define ROCP_HSA_TABLE_CALL(SEVERITY, EXPR) \
auto ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) = (EXPR); \
LOG_IF(SEVERITY, ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) != HSA_STATUS_SUCCESS) \
ROCP_##SEVERITY##_IF(ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) != \
HSA_STATUS_SUCCESS) \
<< #EXPR << " returned non-zero status code " \
<< ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) << " :: " \
<< ::rocprofiler::hsa::get_hsa_status_string( \
+3 -4
Просмотреть файл
@@ -35,7 +35,6 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/marker.h>
#include <glog/logging.h>
#include <rocprofiler-sdk-roctx/roctx.h>
#include <atomic>
@@ -143,7 +142,7 @@ roctx_api_impl<TableIdx, OpIdx>::functor(Args... args)
constexpr auto external_corr_id_domain_idx =
roctx_domain_info<TableIdx>::external_correlation_id_domain_idx;
LOG_IF(INFO, registration::get_fini_status() != 0) << "Executing " << info_type::name;
ROCP_INFO_IF(registration::get_fini_status() != 0) << "Executing " << info_type::name;
auto thr_id = common::get_tid();
auto callback_contexts = tracing::callback_context_data_vec_t{};
@@ -166,7 +165,7 @@ roctx_api_impl<TableIdx, OpIdx>::functor(Args... args)
return;
}
LOG_IF(FATAL, external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
ROCP_FATAL_IF(external_corr_ids.size() < (callback_contexts.size() + buffered_contexts.size()))
<< "missing external correlation ids";
auto ref_count = 2;
@@ -388,7 +387,7 @@ copy_table(Tp* _orig, uint64_t _tbl_instance, std::integral_constant<size_t, OpI
auto& _copy_table = _info.get_table(*get_table<TableIdx>());
auto& _copy_func = _info.get_table_func(_copy_table);
LOG_IF(FATAL, _copy_func && _tbl_instance == 0)
ROCP_FATAL_IF(_copy_func && _tbl_instance == 0)
<< _info.name << " has non-null function pointer " << _copy_func
<< " despite this being the first instance of the library being copies";
+3 -1
Просмотреть файл
@@ -22,6 +22,8 @@
#pragma once
#include "lib/common/logging.hpp"
#define KFD_EVENT_PARSE_EVENTS(X, HANDLER) \
do \
{ \
@@ -35,7 +37,7 @@
assert(char_count > 0); \
std::string_view event_str{cursor, char_count}; \
\
LOG(INFO) << fmt::format("KFD event: [{}]", event_str); \
ROCP_INFO << fmt::format("KFD event: [{}]", event_str); \
HANDLER(event_str); \
\
cursor = pos + 1; \
+23 -24
Просмотреть файл
@@ -38,7 +38,6 @@
#include <rocprofiler-sdk/hsa/table_id.h>
#include <fmt/core.h>
#include <glog/logging.h>
#include <hsa/amd_hsa_signal.h>
#include <hsa/hsa.h>
@@ -169,7 +168,7 @@ to_string(EnumT val,
template <size_t>
page_migration_record_t parse_uvm_event(std::string_view)
{
LOG_IF(FATAL, false) << uvm_event_info<ROCPROFILER_UVM_EVENT_NONE>::format_str;
ROCP_FATAL_IF(false) << uvm_event_info<ROCPROFILER_UVM_EVENT_NONE>::format_str;
return {};
}
@@ -194,7 +193,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_PAGE_FAULT_START>(std::string_view str)
e.read_fault = (fault == 'R');
e.address = page_to_bytes(e.address);
LOG(INFO) << fmt::format("Page fault start [ ts: {} pid: {} addr: 0x{:X} node: {} ] \n",
ROCP_INFO << fmt::format("Page fault start [ ts: {} pid: {} addr: 0x{:X} node: {} ] \n",
rec.start_timestamp,
rec.pid,
e.address,
@@ -230,7 +229,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_PAGE_FAULT_END>(std::string_view str)
// throw std::runtime_error("Invalid SVM memory migrate type");
e.address = page_to_bytes(e.address);
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"Page fault end [ ts: {} pid: {} addr: 0x{:X} node: {} migrated: {} ] \n",
rec.end_timestamp,
rec.pid,
@@ -268,7 +267,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_MIGRATE_START>(std::string_view str)
e.start_addr = page_to_bytes(e.start_addr);
e.end_addr = page_to_bytes(e.end_addr) - 1;
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"Page migrate start [ ts: {} pid: {} addr s: 0x{:X} addr "
"e: 0x{:X} size: {}B from node: {} to node: {} prefetch node: {} preferred node: {} "
"trigger: {} ] \n",
@@ -311,7 +310,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_MIGRATE_END>(std::string_view str)
e.start_addr = page_to_bytes(e.start_addr);
e.end_addr = page_to_bytes(e.end_addr) - 1;
LOG(INFO) << fmt::format("Page migrate end [ ts: {} pid: {} addr s: 0x{:X} addr e: "
ROCP_INFO << fmt::format("Page migrate end [ ts: {} pid: {} addr s: 0x{:X} addr e: "
"0x{:X} from node: {} to node: {} trigger: {} ] \n",
rec.end_timestamp,
rec.pid,
@@ -343,7 +342,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_QUEUE_EVICTION>(std::string_view str)
rec.queue_suspend.trigger = static_cast<qsuspend_trigger_t>(trigger);
LOG(INFO) << fmt::format("Queue evict [ ts: {} pid: {} node: {} trigger: {} ] \n",
ROCP_INFO << fmt::format("Queue evict [ ts: {} pid: {} node: {} trigger: {} ] \n",
rec.start_timestamp,
rec.pid,
e.node_id,
@@ -372,7 +371,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_QUEUE_RESTORE>(std::string_view str)
else
e.rescheduled = false;
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"Queue restore [ ts: {} pid: {} node: {} ] \n", rec.end_timestamp, rec.pid, e.node_id);
return rec;
@@ -403,7 +402,7 @@ parse_uvm_event<ROCPROFILER_UVM_EVENT_UNMAP_FROM_GPU>(std::string_view str)
e.start_addr = page_to_bytes(e.start_addr);
e.end_addr = page_to_bytes(e.end_addr);
LOG(INFO) << fmt::format("Unmap from GPU [ ts: {} pid: {} start addr: 0x{:X} end addr: 0x{:X} "
ROCP_INFO << fmt::format("Unmap from GPU [ ts: {} pid: {} start addr: 0x{:X} end addr: 0x{:X} "
"node: {} trigger {} ] \n",
rec.start_timestamp,
rec.pid,
@@ -793,7 +792,7 @@ struct kfd_device_fd
kfd_device_fd()
{
fd = ::open(KFD_DEVICE_PATH, O_RDWR | O_CLOEXEC);
LOG_IF(FATAL, fd == -1) << "Error opening KFD handle @ " << KFD_DEVICE_PATH;
ROCP_FATAL_IF(fd == -1) << "Error opening KFD handle @ " << KFD_DEVICE_PATH;
}
~kfd_device_fd()
@@ -810,9 +809,9 @@ get_version()
kfd_device_fd kfd_fd{};
if(ioctl(kfd_fd.fd, args) != -1)
LOG(INFO) << fmt::format("KFD v{}.{}", args.major_version, args.minor_version);
ROCP_INFO << fmt::format("KFD v{}.{}", args.major_version, args.minor_version);
else
LOG(ERROR) << fmt::format("Could not determine KFD version");
ROCP_ERROR << fmt::format("Could not determine KFD version");
return args;
}();
@@ -844,7 +843,7 @@ struct poll_kfd_t
const auto kfd_flags =
kfd_bitmask(rprof_ev, std::make_index_sequence<ROCPROFILER_PAGE_MIGRATION_LAST>{});
LOG(INFO) << fmt::format("Setting KFD flags to [0b{:b}] \n", kfd_flags);
ROCP_INFO << fmt::format("Setting KFD flags to [0b{:b}] \n", kfd_flags);
// Create fd for notifying thread when we want to wake it up, and an eventfd for any events
// to this thread
@@ -877,7 +876,7 @@ struct poll_kfd_t
{
auto gpu_event_fd = get_node_fd(agent->gpu_id);
file_handles.emplace_back(pollfd{gpu_event_fd, POLLIN, 0});
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"GPU node {} with fd {} added\n", agent->gpu_id, gpu_event_fd);
}
}
@@ -887,7 +886,7 @@ struct poll_kfd_t
{
auto& fd = file_handles[i];
auto write_size = write(fd.fd, &kfd_flags, sizeof(kfd_flags));
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"Writing {} to GPU fd {} ({} bytes)\n", kfd_flags, fd.fd, write_size);
CHECK(write_size == sizeof(kfd_flags));
}
@@ -922,7 +921,7 @@ struct poll_kfd_t
args.gpuid = gpu_node_id;
if(auto ret = ioctl(kfd_fd.fd, args); ret == -1)
LOG(ERROR) << fmt::format(
ROCP_ERROR << fmt::format(
"Could not get GPU node {} file descriptor (exit code: {})", gpu_node_id, ret);
return args.anon_fd;
}
@@ -950,7 +949,7 @@ get_config()
kfd::poll_kfd_t::~poll_kfd_t()
{
LOG(INFO) << fmt::format("Terminating poll_kfd\n");
ROCP_INFO << fmt::format("Terminating poll_kfd\n");
if(!active) return;
// wake thread up
@@ -962,7 +961,7 @@ kfd::poll_kfd_t::~poll_kfd_t()
} while(bytes_written == -1 && (errno == EINTR || errno == EAGAIN));
if(bg_thread.joinable()) bg_thread.join();
LOG(INFO) << fmt::format("Background thread terminated\n");
ROCP_INFO << fmt::format("Background thread terminated\n");
for(const auto& f : file_handles)
close(f.fd);
@@ -982,7 +981,7 @@ poll_events(small_vector<pollfd> file_handles, bool non_blocking)
// 0 -> return immediately even if no events
// -1 -> wait indefinitely
LOG(INFO) << fmt::format("{} polling = {}, polling with timeout = {}",
ROCP_INFO << fmt::format("{} polling = {}, polling with timeout = {}",
non_blocking ? "Non-blocking" : "Blocking",
non_blocking,
timeout_val);
@@ -991,7 +990,7 @@ poll_events(small_vector<pollfd> file_handles, bool non_blocking)
for(auto& fd : file_handles)
{
LOG(INFO) << fmt::format(
ROCP_INFO << fmt::format(
"Handle = {}, events = {}, revents = {}\n", fd.fd, fd.events, fd.revents);
}
@@ -1004,7 +1003,7 @@ poll_events(small_vector<pollfd> file_handles, bool non_blocking)
if((exitfd.revents & POLLIN) != 0)
{
LOG(INFO) << "Terminating background thread\n";
ROCP_INFO << "Terminating background thread\n";
return;
}
@@ -1019,11 +1018,11 @@ poll_events(small_vector<pollfd> file_handles, bool non_blocking)
{
size_t status_size = read(fd.fd, scratch_buffer.data(), scratch_buffer.size());
// LOG(INFO) << fmt::format(
// ROCP_INFO << fmt::format(
// "status_size: {} size {}\n", status_size, scratch_buffer.size());
std::string_view event_strings{scratch_buffer.data(), status_size};
// LOG(INFO) << fmt::format("Raw KFD string [({})]\n",
// ROCP_INFO << fmt::format("Raw KFD string [({})]\n",
// event_strings.data());
KFD_EVENT_PARSE_EVENTS(event_strings, handle_reporting);
}
@@ -1092,7 +1091,7 @@ init(const small_vector<size_t>& event_ids, bool non_blocking)
else
{
// Add a buffer record with this info
LOG(ERROR) << fmt::format(
ROCP_ERROR << fmt::format(
"KFD does not support SVM event reporting in v{}.{} (requires v1.11)",
ver.major_version,
ver.minor_version);
+4 -5
Просмотреть файл
@@ -22,6 +22,9 @@
#pragma once
#include "lib/common/logging.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/parser/translation.hpp"
#include <rocprofiler-sdk/fwd.h>
#include <cstdint>
@@ -30,10 +33,6 @@
#include <unordered_map>
#include <vector>
#include <glog/logging.h>
#include "lib/rocprofiler-sdk/pc_sampling/parser/translation.hpp"
template <>
struct std::hash<device_handle>
{
@@ -264,7 +263,7 @@ _parse_buffer(generic_sample_t* buffer,
break;
}
default:
LOG(WARNING) << "Index " << index
ROCP_WARNING << "Index " << index
<< " - Invalid sample type: " << buffer[index].type << "\n";
return PCSAMPLE_STATUS_INVALID_SAMPLE;
}
-2
Просмотреть файл
@@ -32,8 +32,6 @@
#include "lib/rocprofiler-sdk/counters/metrics.hpp"
#include "lib/rocprofiler-sdk/hsa/agent_cache.hpp"
#include <glog/logging.h>
extern "C" {
/**
* @brief Create Profile Configuration.
+18 -19
Просмотреть файл
@@ -47,7 +47,6 @@
#include <rocprofiler-sdk/version.h>
#include <fmt/format.h>
#include <glog/logging.h>
#include <dlfcn.h>
#include <link.h>
@@ -205,7 +204,7 @@ find_clients()
if(get_forced_configure() && is_unique_configure_func(get_forced_configure()))
{
ROCP_ERROR << "adding forced configure";
ROCP_INFO << "adding forced configure";
emplace_client("(forced)", nullptr, get_forced_configure());
}
@@ -248,7 +247,7 @@ find_clients()
if(!handle)
{
LOG(WARNING) << "[env] " << itr
ROCP_WARNING << "[env] " << itr
<< " is not already loaded, doing a local lazy dlopen...";
handle = dlopen(itr.c_str(), RTLD_LOCAL | RTLD_LAZY);
}
@@ -272,7 +271,7 @@ find_clients()
{
auto _sym = rocprofiler_configure_dlsym(handle);
// FATAL bc they explicitly said this was a tool library
LOG_IF(FATAL, !_sym) << "rocprofiler tool library " << itr
ROCP_FATAL_IF(!_sym) << "rocprofiler tool library " << itr
<< " did not contain rocprofiler_configure symbol";
if(is_unique_configure_func(_sym)) emplace_client(itr, handle, _sym);
}
@@ -300,7 +299,7 @@ find_clients()
ROCP_INFO << "searching " << itr << " for rocprofiler_configure";
void* handle = dlopen(itr.c_str(), RTLD_LAZY | RTLD_NOLOAD);
LOG_IF(ERROR, handle == nullptr) << "error dlopening " << itr;
ROCP_ERROR_IF(handle == nullptr) << "error dlopening " << itr;
auto* _sym = rocprofiler_configure_dlsym(handle);
@@ -334,7 +333,7 @@ find_clients()
}
}
ROCP_ERROR << __FUNCTION__ << " found " << data.size() << " clients";
ROCP_INFO << __FUNCTION__ << " found " << data.size() << " clients";
return data;
}
@@ -363,7 +362,7 @@ invoke_client_configures()
auto _lk = scoped_lock_t{get_registration_mutex()};
ROCP_ERROR << __FUNCTION__;
ROCP_INFO << __FUNCTION__;
if(!get_clients()) return false;
@@ -425,7 +424,7 @@ invoke_client_initializers()
auto _lk = scoped_lock_t{get_registration_mutex()};
ROCP_ERROR << __FUNCTION__;
ROCP_INFO << __FUNCTION__;
if(!get_clients()) return false;
@@ -467,7 +466,7 @@ invoke_client_finalizers()
void
invoke_client_finalizer(rocprofiler_client_id_t client_id)
{
ROCP_ERROR << __FUNCTION__ << "(client_id=" << client_id.handle << ")";
ROCP_INFO << __FUNCTION__ << "(client_id=" << client_id.handle << ")";
auto _lk = scoped_lock_t{get_registration_mutex()};
@@ -500,7 +499,7 @@ invoke_client_finalizer(rocprofiler_client_id_t client_id)
void
init_logging()
{
common::init_logging("ROCPROFILER_LOG_LEVEL");
common::init_logging("ROCPROFILER");
}
// ensure that logging is always initialized when library is loaded
@@ -666,22 +665,22 @@ rocprofiler_set_api_table(const char* name,
// implementation has a call once
rocprofiler::registration::init_logging();
ROCP_ERROR << __FUNCTION__ << "(\"" << name << "\", " << lib_version << ", " << lib_instance
<< ", ..., " << num_tables << ")";
ROCP_INFO << __FUNCTION__ << "(\"" << name << "\", " << lib_version << ", " << lib_instance
<< ", ..., " << num_tables << ")";
static auto _once = std::once_flag{};
std::call_once(_once, rocprofiler::registration::initialize);
// pass to roctx init
LOG_IF(ERROR, num_tables == 0) << "rocprofiler expected " << name
ROCP_ERROR_IF(num_tables == 0) << "rocprofiler expected " << name
<< " library to pass at least one table, not " << num_tables;
LOG_IF(ERROR, tables == nullptr) << "rocprofiler expected pointer to array of tables from "
ROCP_ERROR_IF(tables == nullptr) << "rocprofiler expected pointer to array of tables from "
<< name << " library, not a nullptr";
if(std::string_view{name} == "hip")
{
// pass to hip init
LOG_IF(ERROR, num_tables > 1) << "rocprofiler expected HIP library to pass 1 API table for "
ROCP_ERROR_IF(num_tables > 1) << "rocprofiler expected HIP library to pass 1 API table for "
<< name << ", not " << num_tables;
auto* hip_runtime_api_table = static_cast<HipDispatchTable*>(*tables);
@@ -703,7 +702,7 @@ rocprofiler_set_api_table(const char* name,
else if(std::string_view{name} == "hip_compiler")
{
// pass to hip init
LOG_IF(ERROR, num_tables > 1) << "rocprofiler expected HIP library to pass 1 API table for "
ROCP_ERROR_IF(num_tables > 1) << "rocprofiler expected HIP library to pass 1 API table for "
<< name << ", not " << num_tables;
auto* hip_compiler_api_table = static_cast<HipCompilerDispatchTable*>(*tables);
@@ -730,7 +729,7 @@ rocprofiler_set_api_table(const char* name,
setenv("HSA_TOOLS_ROCPROFILER_V1_TOOLS", "0", 0);
// pass to hsa init
LOG_IF(ERROR, num_tables > 1)
ROCP_ERROR_IF(num_tables > 1)
<< "rocprofiler expected HSA library to pass 1 API table, not " << num_tables;
auto* hsa_api_table = static_cast<HsaApiTable*>(*tables);
@@ -766,9 +765,9 @@ rocprofiler_set_api_table(const char* name,
else if(std::string_view{name} == "roctx")
{
// pass to roctx init
LOG_IF(FATAL, num_tables < 3)
ROCP_FATAL_IF(num_tables < 3)
<< "rocprofiler expected ROCTX library to pass 3 API tables, not " << num_tables;
LOG_IF(ERROR, num_tables > 3)
ROCP_ERROR_IF(num_tables > 3)
<< "rocprofiler expected ROCTX library to pass 3 API tables, not " << num_tables;
auto* roctx_core = static_cast<roctxCoreApiTable_t*>(tables[0]);
-1
Просмотреть файл
@@ -24,7 +24,6 @@
#include "lib/common/filesystem.hpp"
#include "lib/common/utility.hpp"
#include <glog/logging.h>
#include <fstream>
#include <grp.h>
-1
Просмотреть файл
@@ -28,7 +28,6 @@
#include <rocprofiler-sdk/rocprofiler.h>
#include <fmt/format.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <sstream>
+3 -3
Просмотреть файл
@@ -46,7 +46,7 @@
auto _status = (fn); \
if(_status != HSA_STATUS_SUCCESS) \
{ \
LOG(ERROR) << "HSA Err: " << _status << '\n'; \
ROCP_ERROR << "HSA Err: " << _status << '\n'; \
throw std::runtime_error(message); \
} \
}
@@ -105,7 +105,7 @@ pre_kernel_call(ThreadTracer& tracer,
return moved;
} catch(std::out_of_range& e)
{
LOG(WARNING) << "Attempt to initialize ATT without allocated resources!\n";
ROCP_WARNING << "Attempt to initialize ATT without allocated resources!\n";
return nullptr;
}
}
@@ -127,7 +127,7 @@ thread_trace_callback(uint32_t shader, void* buffer, uint64_t size, void* callba
cpu_data.data(), buffer, size);
if(status != HSA_STATUS_SUCCESS)
{
LOG(WARNING) << "Failed to copy hsa memory!";
ROCP_WARNING << "Failed to copy hsa memory!";
return HSA_STATUS_SUCCESS;
}
+1 -7
Просмотреть файл
@@ -26,13 +26,7 @@ add_test(
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
if(ROCPROFILER_MEMCHECK STREQUAL "LeakSanitizer")
set(LOG_LEVEL "warning") # info produces memory leak
else()
set(LOG_LEVEL "info")
endif()
set(cc-env-pmc1 "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set(cc-env-pmc1 "${PRELOAD_ENV}")
set_tests_properties(
rocprofv3-test-counter-collection-pmc1-execute
+1 -7
Просмотреть файл
@@ -26,13 +26,7 @@ add_test(
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
if(ROCPROFILER_MEMCHECK STREQUAL "LeakSanitizer")
set(LOG_LEVEL "warning") # info produces memory leak
else()
set(LOG_LEVEL "info")
endif()
set(cc-env-pmc2 "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set(cc-env-pmc2 "${PRELOAD_ENV}")
set_tests_properties(
rocprofv3-test-counter-collection-pmc2-execute
+1 -7
Просмотреть файл
@@ -27,13 +27,7 @@ add_test(NAME rocprofv3-test-list-metrics-std-out-execute
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
if(ROCPROFILER_MEMCHECK STREQUAL "LeakSanitizer")
set(LOG_LEVEL "warning") # info produces memory leak
else()
set(LOG_LEVEL "info")
endif()
set(cc-env-list-metrics "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set(cc-env-list-metrics "${PRELOAD_ENV}")
set_tests_properties(
rocprofv3-test-list-metrics-execute
+1 -8
Просмотреть файл
@@ -11,14 +11,7 @@ project(
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
if(ROCPROFILER_MEMCHECK STREQUAL "LeakSanitizer")
set(LOG_LEVEL "warning") # info produces memory leak
else()
set(LOG_LEVEL "info")
endif()
set(tracing-env "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}"
"ROCPROFILER_LOG_LEVEL=${LOG_LEVEL}")
set(tracing-env "${PRELOAD_ENV}")
foreach(FILENAME validate.py conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
+2 -1
Просмотреть файл
@@ -31,7 +31,8 @@ else()
set(LOG_LEVEL "info")
endif()
set(cc-tracing-env "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set(cc-tracing-env "${PRELOAD_ENV}" "ROCPROFILER_LOG_LEVEL=${LOG_LEVEL}"
"ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set_tests_properties(
rocprofv3-test-tracing-plus-cc-execute
+2 -1
Просмотреть файл
@@ -26,7 +26,8 @@ else()
set(LOG_LEVEL "info")
endif()
set(tracing-env "${PRELOAD_ENV}" "ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set(tracing-env "${PRELOAD_ENV}" "ROCPROFILER_LOG_LEVEL=${LOG_LEVEL}"
"ROCPROF_LOG_LEVEL=${LOG_LEVEL}")
set_tests_properties(
rocprofv3-test-trace-execute