diff --git a/.gitmodules b/.gitmodules
index 31f9a62215..66ae561ad0 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -98,3 +98,7 @@
[submodule "projects/rocprofiler-systems/external/filesystem"]
path = projects/rocprofiler-systems/external/filesystem
url = https://github.com/gulrak/filesystem.git
+[submodule "projects/rocprofiler-systems/external/spdlog"]
+ path = projects/rocprofiler-systems/external/spdlog
+ url = https://github.com/gabime/spdlog.git
+ tag = v1.16.0
diff --git a/projects/rocprofiler-systems/CHANGELOG.md b/projects/rocprofiler-systems/CHANGELOG.md
index a8396c66ff..5ee94ad78d 100644
--- a/projects/rocprofiler-systems/CHANGELOG.md
+++ b/projects/rocprofiler-systems/CHANGELOG.md
@@ -9,6 +9,9 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.
### Added
- Documentation for `--trace-legacy` / `-L` CLI flag for direct tracing mode.
+- Added dependency to `spdlog` library.
+- Added environment variable `ROCPROFSYS_LOG_LEVEL` which control level of logging.
+ - Available log levels: `critical`, `error`, `warning`, `info`(default), `debug`, `trace` and `off`.
### Changed
@@ -18,6 +21,7 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.
- `--trace` / `-T` CLI flag enables tracing with cached mode by default.
- `--trace-legacy` / `-L` CLI flag enables legacy direct mode for tracing.
- Changed thread storage allocation from a hard-coded 4096-element array to a compile-time computed size derived from the ROCPROFSYS_MAX_THREADS configuration flag.
+- Changed logging module to use `spdlog` library.
### Resolved issues
@@ -30,6 +34,7 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.
### Deprecated
- `ROCPROFSYS_USE_PERFETTO` environment variable (use `ROCPROFSYS_TRACE`).
+- `ROCPROFSYS_VERBOSE` and `ROCPROFSYS_DEBUG` environment variables (use `ROCPROFSYS_LOG_LEVEL`).
## ROCm Systems Profiler 1.3.0 for ROCm 7.2.0
diff --git a/projects/rocprofiler-systems/CMakeLists.txt b/projects/rocprofiler-systems/CMakeLists.txt
index ba806effc8..217435ee53 100644
--- a/projects/rocprofiler-systems/CMakeLists.txt
+++ b/projects/rocprofiler-systems/CMakeLists.txt
@@ -236,6 +236,11 @@ rocprofiler_systems_add_option(ROCPROFSYS_BUILD_CODECOV "Build for code coverage
rocprofiler_systems_add_option(ROCPROFSYS_INSTALL_PERFETTO_TOOLS
"Install perfetto tools (i.e. traced, perfetto, etc.)" OFF
)
+
+rocprofiler_systems_add_option(ROCPROFSYS_BUILD_SPDLOG
+ "Enable building spdlog library internally" ON
+)
+
rocprofiler_systems_add_option(ROCPROFSYS_BUILD_SQLITE3
"Enable building sqlite3 library internally" ON
)
diff --git a/projects/rocprofiler-systems/cmake/Packages.cmake b/projects/rocprofiler-systems/cmake/Packages.cmake
index 2ca2d98cd2..e1fca7bdb2 100644
--- a/projects/rocprofiler-systems/cmake/Packages.cmake
+++ b/projects/rocprofiler-systems/cmake/Packages.cmake
@@ -62,6 +62,9 @@ rocprofiler_systems_add_interface_library(rocprofiler-systems-sqlite3
rocprofiler_systems_add_interface_library(rocprofiler-systems-json
"Use nlohmann/json for json data handling"
)
+rocprofiler_systems_add_interface_library(rocprofiler-systems-spdlog
+ "Provides spdlog library"
+)
rocprofiler_systems_add_interface_library(rocprofiler-systems-timemory
"Provides timemory libraries"
)
@@ -675,6 +678,14 @@ include(Perfetto)
include(SQLite3)
+# ----------------------------------------------------------------------------------------#
+#
+# Spdlog
+#
+# ----------------------------------------------------------------------------------------#
+
+include(Spdlog)
+
# ----------------------------------------------------------------------------------------#
#
# NlohmannJson
diff --git a/projects/rocprofiler-systems/cmake/Spdlog.cmake b/projects/rocprofiler-systems/cmake/Spdlog.cmake
new file mode 100644
index 0000000000..428fc3d085
--- /dev/null
+++ b/projects/rocprofiler-systems/cmake/Spdlog.cmake
@@ -0,0 +1,38 @@
+include_guard(GLOBAL)
+
+if(ROCPROFSYS_BUILD_SPDLOG)
+ message(STATUS "Building spdlog from source!")
+
+ include(FetchContent)
+
+ rocprofiler_systems_checkout_git_submodule(
+ RELATIVE_PATH external/spdlog
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ REPO_URL https://github.com/gabime/spdlog.git
+ TEST_FILE CMakeLists.txt
+ REPO_BRANCH "v1.16.0"
+ )
+
+ FetchContent_Declare(spdlog SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/spdlog)
+
+ set(SPDLOG_BUILD_SHARED OFF CACHE BOOL "" FORCE)
+ set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
+ set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+ set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
+ set(SPDLOG_FMT_EXTERNAL OFF CACHE BOOL "" FORCE)
+
+ # Spdlog workaround for building static library
+ set(_ROCPROFSYS_BUILD_SHARED_LIBS_BACKUP ${BUILD_SHARED_LIBS})
+ set(BUILD_SHARED_LIBS OFF)
+
+ FetchContent_MakeAvailable(spdlog)
+
+ set(BUILD_SHARED_LIBS ${_ROCPROFSYS_BUILD_SHARED_LIBS_BACKUP})
+ unset(_ROCPROFSYS_BUILD_SHARED_LIBS_BACKUP)
+
+ target_link_libraries(rocprofiler-systems-spdlog INTERFACE spdlog::spdlog)
+else()
+ message(STATUS "Using system spdlog library")
+ find_package(spdlog REQUIRED)
+ target_link_libraries(rocprofiler-systems-spdlog INTERFACE spdlog::spdlog)
+endif()
diff --git a/projects/rocprofiler-systems/docs/install/install.rst b/projects/rocprofiler-systems/docs/install/install.rst
index 2051cb7d70..c11b2a1799 100644
--- a/projects/rocprofiler-systems/docs/install/install.rst
+++ b/projects/rocprofiler-systems/docs/install/install.rst
@@ -100,6 +100,7 @@ Required third-party packages
* `libunwind `_ for call-stack sampling
* `SQLite `_ for database output
+* `spdlog `_ for logging
Any of the third-party packages required by Dyninst, along with Dyninst itself, can be built and installed
during the ROCm Systems Profiler build. The following list indicates the package, the version,
@@ -112,6 +113,7 @@ while Dyninst requires TBB), and the CMake option to build the package alongside
"Dyninst", "13.0", "ROCm Systems Profiler", "``ROCPROFSYS_BUILD_DYNINST`` (default: OFF)"
"Libunwind", "", "ROCm Systems Profiler", "``ROCPROFSYS_BUILD_LIBUNWIND`` (default: ON)"
"Nlohmann/JSON", "", "ROCm Systems Profiler", "``ROCPROFSYS_BUILD_NLOHMANN_JSON`` (default: ON)"
+ "spdlog", "", "ROCm Systems Profiler", "``ROCPROFSYS_BUILD_SPDLOG`` (default: ON)"
"SQLite", "", "ROCm Systems Profiler", "``ROCPROFSYS_BUILD_SQLITE`` (default: OFF)"
"TBB", "2018.6", "Dyninst", "``ROCPROFSYS_BUILD_TBB`` (default: OFF)"
"ElfUtils", "0.178", "Dyninst", "``ROCPROFSYS_BUILD_ELFUTILS`` (default: OFF)"
diff --git a/projects/rocprofiler-systems/external/spdlog b/projects/rocprofiler-systems/external/spdlog
new file mode 160000
index 0000000000..486b55554f
--- /dev/null
+++ b/projects/rocprofiler-systems/external/spdlog
@@ -0,0 +1 @@
+Subproject commit 486b55554f11c9cccc913e11a87085b2a91f706f
diff --git a/projects/rocprofiler-systems/source/bin/rocprof-sys-avail/component_categories.hpp b/projects/rocprofiler-systems/source/bin/rocprof-sys-avail/component_categories.hpp
index 2f825c3797..f67c6ca4cd 100644
--- a/projects/rocprofiler-systems/source/bin/rocprof-sys-avail/component_categories.hpp
+++ b/projects/rocprofiler-systems/source/bin/rocprof-sys-avail/component_categories.hpp
@@ -51,7 +51,7 @@ struct component_categories
};
(void) _cleanup; // unused but set if sizeof...(Tp) == 0
- TIMEMORY_FOLD_EXPRESSION(_v.emplace(TIMEMORY_JOIN(
+ ROCPROFSYS_FOLD_EXPRESSION(_v.emplace(TIMEMORY_JOIN(
"::", "component", _cleanup(rocprofsys::utility::demangle(), "tim::"))));
}
@@ -68,7 +68,7 @@ struct component_categories
template
void operator()(std::set& _v, std::index_sequence) const
{
- TIMEMORY_FOLD_EXPRESSION(component_categories>{}(_v));
+ ROCPROFSYS_FOLD_EXPRESSION(component_categories>{}(_v));
}
void operator()(std::set& _v) const
diff --git a/projects/rocprofiler-systems/source/bin/rocprof-sys-causal/impl.cpp b/projects/rocprofiler-systems/source/bin/rocprof-sys-causal/impl.cpp
index 16490dbbbd..fa7f611dac 100644
--- a/projects/rocprofiler-systems/source/bin/rocprof-sys-causal/impl.cpp
+++ b/projects/rocprofiler-systems/source/bin/rocprof-sys-causal/impl.cpp
@@ -400,6 +400,15 @@ parse_args(int argc, char** argv, std::vector& _env,
std::min(_cols - parser.get_help_width() - 8, 120));
parser.start_group("DEBUG OPTIONS", "");
+
+ parser.add_argument({ "--log-level" }, "Log level")
+ .max_count(1)
+ .dtype("string")
+ .choices({ "trace", "debug", "info", "warn", "error", "critical", "off" })
+ .action([&](parser_t& p) {
+ update_env(_env, "ROCPROFSYS_LOG_LEVEL", p.get("log-level"));
+ });
+
parser.add_argument({ "--monochrome" }, "Disable colorized output")
.max_count(1)
.dtype("bool")
@@ -410,17 +419,26 @@ parse_args(int argc, char** argv, std::vector& _env,
update_env(_env, "ROCPROFSYS_MONOCHROME", (_monochrome) ? "1" : "0");
update_env(_env, "MONOCHROME", (_monochrome) ? "1" : "0");
});
- parser.add_argument({ "--debug" }, "Debug output")
+ parser.add_argument({ "--debug" }, "[DEPRECATED Use --log-level=debug] Debug output")
.max_count(1)
.action([&](parser_t& p) {
update_env(_env, "ROCPROFSYS_DEBUG", p.get("debug"));
+ update_env(_env, "ROCPROFSYS_LOG_LEVEL", "debug");
});
- parser.add_argument({ "-v", "--verbose" }, "Verbose output")
+ parser
+ .add_argument({ "-v", "--verbose" },
+ "[DEPRECATED Use --log-level=trace] Verbose output")
.count(1)
.action([&](parser_t& p) {
auto _v = p.get("verbose");
verbose = _v;
update_env(_env, "ROCPROFSYS_VERBOSE", _v);
+
+ constexpr std::array log_levels = { "off", "info", "debug",
+ "debug", "trace" };
+
+ auto index = std::clamp(_v + 1, 0, static_cast(log_levels.size() - 1));
+ update_env(_env, "ROCPROFSYS_LOG_LEVEL", log_levels[index]);
});
std::string _config_file = {};
diff --git a/projects/rocprofiler-systems/source/bin/rocprof-sys-sample/impl.cpp b/projects/rocprofiler-systems/source/bin/rocprof-sys-sample/impl.cpp
index 9491315aeb..6a4b27edb4 100644
--- a/projects/rocprofiler-systems/source/bin/rocprof-sys-sample/impl.cpp
+++ b/projects/rocprofiler-systems/source/bin/rocprof-sys-sample/impl.cpp
@@ -294,21 +294,47 @@ parse_args(int argc, char** argv, std::vector& _env)
update_mode::REPLACE, ":", updated_envs,
original_envs);
});
- parser.add_argument({ "--debug" }, "Debug output")
+
+ parser.add_argument({ "--log-level" }, "Log level")
+ .max_count(1)
+ .dtype("string")
+ .choices({ "trace", "debug", "info", "warn", "error", "critical", "off" })
+ .action([&](parser_t& p) {
+ rocprofsys::common::update_env(
+ _env, "ROCPROFSYS_LOG_LEVEL", p.get("log-level"),
+ update_mode::REPLACE, ":", updated_envs, original_envs);
+ });
+
+ parser.add_argument({ "--debug" }, "[DEPRECATED Use --log-level=debug] Debug output")
.max_count(1)
.action([&](parser_t& p) {
rocprofsys::common::update_env(_env, "ROCPROFSYS_DEBUG", p.get("debug"),
update_mode::REPLACE, ":", updated_envs,
original_envs);
+
+ rocprofsys::common::update_env(_env, "ROCPROFSYS_LOG_LEVEL", "debug",
+ update_mode::REPLACE, ":", updated_envs,
+ original_envs);
});
- parser.add_argument({ "-v", "--verbose" }, "Verbose output")
+ parser
+ .add_argument({ "-v", "--verbose" },
+ "[DEPRECATED Use --log-level=trace] Verbose output")
.count(1)
.action([&](parser_t& p) {
auto _v = p.get("verbose");
verbose = _v;
+
rocprofsys::common::update_env(_env, "ROCPROFSYS_VERBOSE", _v,
update_mode::REPLACE, ":", updated_envs,
original_envs);
+
+ constexpr std::array log_levels = { "off", "info", "debug",
+ "debug", "trace" };
+
+ auto index = std::clamp(_v + 1, 0, static_cast(log_levels.size() - 1));
+ rocprofsys::common::update_env(_env, "ROCPROFSYS_LOG_LEVEL",
+ log_levels[index], update_mode::REPLACE, ":",
+ updated_envs, original_envs);
});
parser.start_group("GENERAL OPTIONS",
diff --git a/projects/rocprofiler-systems/source/lib/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/CMakeLists.txt
index d0f17dfe41..35cfbc91c8 100644
--- a/projects/rocprofiler-systems/source/lib/CMakeLists.txt
+++ b/projects/rocprofiler-systems/source/lib/CMakeLists.txt
@@ -42,6 +42,7 @@ target_link_libraries(
$
$
$
+ $
$
$
$
@@ -64,6 +65,7 @@ target_link_libraries(
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(binary)
+add_subdirectory(logger)
# ------------------------------------------------------------------------------#
#
diff --git a/projects/rocprofiler-systems/source/lib/binary/analysis.cpp b/projects/rocprofiler-systems/source/lib/binary/analysis.cpp
index 56e967df65..d579a32397 100644
--- a/projects/rocprofiler-systems/source/lib/binary/analysis.cpp
+++ b/projects/rocprofiler-systems/source/lib/binary/analysis.cpp
@@ -36,7 +36,6 @@
#include "core/binary/fwd.hpp"
#include "core/common.hpp"
#include "core/config.hpp"
-#include "core/debug.hpp"
#include "core/locking.hpp"
#include "core/state.hpp"
#include "core/utility.hpp"
@@ -53,6 +52,8 @@
#include
#include
+#include "logger/debug.hpp"
+
#include
#include
#include
@@ -75,8 +76,7 @@ parse_line_info(const std::string& _name, bool _process_dwarf, bool _process_bfd
auto& _bfd = _info.bfd;
_bfd = std::make_shared(_name);
- ROCPROFSYS_BASIC_VERBOSE(0, "[binary] Reading line info for '%s'...\n",
- _name.c_str());
+ LOG_INFO("[binary] Reading line info for '{}'...", _name);
if(_bfd && _bfd->is_good())
{
@@ -125,8 +125,8 @@ parse_line_info(const std::string& _name, bool _process_dwarf, bool _process_bfd
_info.sort();
}
- ROCPROFSYS_BASIC_VERBOSE(1, "[binary] Reading line info for '%s'... %zu entries\n",
- _bfd->name.c_str(), _info.symbols.size());
+ LOG_DEBUG("[binary] Reading line info for '{}'... {} entries", _bfd->name,
+ _info.symbols.size());
return _info;
}
@@ -222,7 +222,7 @@ lookup_ipaddr_entry(uintptr_t _addr, unw_context_t* _context_p,
{
static auto _exclude_range = []() {
auto _maps = ::tim::procfs::maps::iterate_program_headers();
- auto _exclude_range_v = std::set{};
+ auto _exclude_range_v = std::set{};
auto _insert_exclude_range = [&_maps,
&_exclude_range_v](const std::string& _v) {
auto _base_v = std::string_view{ filepath::basename(_v) };
@@ -233,7 +233,7 @@ lookup_ipaddr_entry(uintptr_t _addr, unw_context_t* _context_p,
_real_v == _v)
{
_exclude_range_v.emplace(
- address_range_t{ mitr.load_address, mitr.last_address });
+ address_range{ mitr.load_address, mitr.last_address });
}
}
};
diff --git a/projects/rocprofiler-systems/source/lib/binary/link_map.cpp b/projects/rocprofiler-systems/source/lib/binary/link_map.cpp
index 10ff020d87..eb7823b4bd 100644
--- a/projects/rocprofiler-systems/source/lib/binary/link_map.cpp
+++ b/projects/rocprofiler-systems/source/lib/binary/link_map.cpp
@@ -23,11 +23,12 @@
#include "link_map.hpp"
#include "core/common.hpp"
#include "core/config.hpp"
-#include "core/debug.hpp"
#include "core/timemory.hpp"
#include
+#include "logger/debug.hpp"
+
#include
#include
#include
@@ -138,14 +139,12 @@ get_link_map(const char* _lib, const std::string& _exclude_linked_by,
auto _name = (!_lib) ? config::get_exe_realpath() : std::string{ _lib };
for(const auto& itr : _fini_chain)
{
- ROCPROFSYS_BASIC_VERBOSE(2, "[linkmap][%s]: %s\n", filepath::basename(_name),
- itr.real().c_str());
+ LOG_DEBUG("[linkmap][{}]: {}", filepath::basename(_name), itr.real());
}
for(const auto& itr : _excl_chain)
{
- ROCPROFSYS_BASIC_VERBOSE(3, "[linkmap][%s]: %s\n", _exclude_linked_by.c_str(),
- link_file{ itr }.real().c_str());
+ LOG_DEBUG("[linkmap][{}]: {}", _exclude_linked_by, link_file{ itr }.real());
}
return _fini_chain;
diff --git a/projects/rocprofiler-systems/source/lib/binary/symbol.cpp b/projects/rocprofiler-systems/source/lib/binary/symbol.cpp
index 0cb41900be..4e283cfaa2 100644
--- a/projects/rocprofiler-systems/source/lib/binary/symbol.cpp
+++ b/projects/rocprofiler-systems/source/lib/binary/symbol.cpp
@@ -21,7 +21,6 @@
// SOFTWARE.
#include "core/config.hpp"
-#include "core/debug.hpp"
#if !defined(TIMEMORY_USE_BFD)
# error "BFD support not enabled"
diff --git a/projects/rocprofiler-systems/source/lib/core/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/core/CMakeLists.txt
index 824b3d9931..febf44876e 100644
--- a/projects/rocprofiler-systems/source/lib/core/CMakeLists.txt
+++ b/projects/rocprofiler-systems/source/lib/core/CMakeLists.txt
@@ -9,7 +9,6 @@ set(core_sources
${CMAKE_CURRENT_LIST_DIR}/config.cpp
${CMAKE_CURRENT_LIST_DIR}/constraint.cpp
${CMAKE_CURRENT_LIST_DIR}/cpu.cpp
- ${CMAKE_CURRENT_LIST_DIR}/debug.cpp
${CMAKE_CURRENT_LIST_DIR}/dynamic_library.cpp
${CMAKE_CURRENT_LIST_DIR}/exception.cpp
${CMAKE_CURRENT_LIST_DIR}/gpu.cpp
@@ -37,8 +36,6 @@ set(core_headers
${CMAKE_CURRENT_LIST_DIR}/config.hpp
${CMAKE_CURRENT_LIST_DIR}/constraint.hpp
${CMAKE_CURRENT_LIST_DIR}/cpu.hpp
- ${CMAKE_CURRENT_LIST_DIR}/debug.hpp
- ${CMAKE_CURRENT_LIST_DIR}/defines.hpp
${CMAKE_CURRENT_LIST_DIR}/demangler.hpp
${CMAKE_CURRENT_LIST_DIR}/dynamic_library.hpp
${CMAKE_CURRENT_LIST_DIR}/exception.hpp
@@ -50,7 +47,6 @@ set(core_headers
${CMAKE_CURRENT_LIST_DIR}/node_info.hpp
${CMAKE_CURRENT_LIST_DIR}/perf.hpp
${CMAKE_CURRENT_LIST_DIR}/perfetto.hpp
- ${CMAKE_CURRENT_LIST_DIR}/redirect.hpp
${CMAKE_CURRENT_LIST_DIR}/rocprofiler-sdk.hpp
${CMAKE_CURRENT_LIST_DIR}/state.hpp
${CMAKE_CURRENT_LIST_DIR}/timemory.hpp
diff --git a/projects/rocprofiler-systems/source/lib/core/agent_manager.cpp b/projects/rocprofiler-systems/source/lib/core/agent_manager.cpp
index 0957ab7713..a2ff0d8a5f 100644
--- a/projects/rocprofiler-systems/source/lib/core/agent_manager.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/agent_manager.cpp
@@ -21,7 +21,9 @@
// SOFTWARE.
#include "agent_manager.hpp"
-#include "debug.hpp"
+
+#include "logger/debug.hpp"
+
#include
#include
@@ -42,11 +44,10 @@ agent_manager::agent_manager(std::vector> agents)
void
agent_manager::insert_agent(agent& _agent)
{
- ROCPROFSYS_VERBOSE(
- 3, "Inserting agent with device handle: %lu, and agent id: %ld, device type: %s",
- _agent.device_id,
- (_agent.type == agent_type::GPU ? _gpu_agents_cnt : _cpu_agents_cnt),
- (_agent.type == agent_type::GPU ? "GPU" : "CPU"));
+ LOG_TRACE("Inserting agent with device handle: {}, and agent id: {}, device type: {}",
+ _agent.device_id,
+ (_agent.type == agent_type::GPU ? _gpu_agents_cnt : _cpu_agents_cnt),
+ (_agent.type == agent_type::GPU ? "GPU" : "CPU"));
_agent.device_type_index =
(_agent.type == agent_type::GPU ? _gpu_agents_cnt++ : _cpu_agents_cnt++);
@@ -56,18 +57,17 @@ agent_manager::insert_agent(agent& _agent)
const agent&
agent_manager::get_agent_by_type_index(size_t type_index, agent_type type) const
{
- ROCPROFSYS_VERBOSE(3, "Getting agent for type: %s, with type index: %ld\n",
- (type == agent_type::GPU) ? "GPU" : "CPU", type_index);
+ LOG_TRACE("Getting agent for type: {}, with type index: {}",
+ (type == agent_type::GPU ? "GPU" : "CPU"), type_index);
auto _agent =
std::find_if(_agents.begin(), _agents.end(), [&](const auto& agent_ptr) {
return agent_ptr->type == type && agent_ptr->device_type_index == type_index;
});
if(_agent == _agents.end())
{
- std::ostringstream oss;
- oss << "Agent not found for type index: " << type_index
- << ", type: " << (type == agent_type::GPU ? "GPU" : "CPU");
- throw std::out_of_range(oss.str());
+ throw std::out_of_range(
+ fmt::format("Agent not found for type index: {}, type: {}", type_index,
+ (type == agent_type::GPU ? "GPU" : "CPU")));
}
return **_agent;
}
@@ -75,18 +75,17 @@ agent_manager::get_agent_by_type_index(size_t type_index, agent_type type) const
const agent&
agent_manager::get_agent_by_id(size_t device_id, agent_type type) const
{
- ROCPROFSYS_VERBOSE(3, "Getting agent for device id: %ld, type %s\n", device_id,
- (type == agent_type::GPU) ? "GPU" : "CPU");
+ LOG_TRACE("Getting agent for device id: {}, type {}", device_id,
+ (type == agent_type::GPU ? "GPU" : "CPU"));
auto _agent =
std::find_if(_agents.begin(), _agents.end(), [&](const auto& agent_ptr) {
return agent_ptr->type == type && agent_ptr->device_id == device_id;
});
if(_agent == _agents.end())
{
- std::ostringstream oss;
- oss << "Agent not found for device id: " << device_id
- << ", type: " << (type == agent_type::GPU ? "GPU" : "CPU");
- throw std::out_of_range(oss.str());
+ throw std::out_of_range(fmt::format("Agent not found for device id: {}, type: {}",
+ device_id,
+ (type == agent_type::GPU ? "GPU" : "CPU")));
}
return **_agent;
}
@@ -94,18 +93,17 @@ agent_manager::get_agent_by_id(size_t device_id, agent_type type) const
const agent&
agent_manager::get_agent_by_handle(uint64_t device_handle, agent_type type) const
{
- ROCPROFSYS_VERBOSE(3, "Getting agent for device handle: %ld, type %s\n",
- device_handle, (type == agent_type::GPU ? "GPU" : "CPU"));
+ LOG_TRACE("Getting agent for device handle: {}, type {}", device_handle,
+ (type == agent_type::GPU ? "GPU" : "CPU"));
auto _agent =
std::find_if(_agents.begin(), _agents.end(), [&](const auto& agent_ptr) {
return agent_ptr->type == type && agent_ptr->handle == device_handle;
});
if(_agent == _agents.end())
{
- std::ostringstream oss;
- oss << "Agent not found for device handle: " << device_handle
- << ", type: " << (type == agent_type::GPU ? "GPU" : "CPU");
- throw std::out_of_range(oss.str());
+ throw std::out_of_range(
+ fmt::format("Agent not found for device handle: {}, type: {}", device_handle,
+ (type == agent_type::GPU ? "GPU" : "CPU")));
}
return **_agent;
}
@@ -113,16 +111,15 @@ agent_manager::get_agent_by_handle(uint64_t device_handle, agent_type type) cons
const agent&
agent_manager::get_agent_by_handle(size_t device_handle) const
{
- ROCPROFSYS_VERBOSE(3, "Getting agent for device handle: %ld\n", device_handle);
+ LOG_TRACE("Getting agent for device handle: {}", device_handle);
auto _agent =
std::find_if(_agents.begin(), _agents.end(), [&](const auto& agent_ptr) {
return agent_ptr->handle == device_handle;
});
if(_agent == _agents.end())
{
- std::ostringstream oss;
- oss << "Agent not found for device handle: " << device_handle;
- throw std::out_of_range(oss.str());
+ throw std::out_of_range(
+ fmt::format("Agent not found for device handle: {}", device_handle));
}
return **_agent;
}
@@ -130,8 +127,8 @@ agent_manager::get_agent_by_handle(size_t device_handle) const
std::vector>
agent_manager::get_agents_by_type(agent_type type) const
{
- ROCPROFSYS_VERBOSE(3, "Getting agent for device type: %s\n",
- type == agent_type::GPU ? "GPU" : "CPU");
+ LOG_TRACE("Getting agent for device type: {}",
+ (type == agent_type::GPU ? "GPU" : "CPU"));
std::vector> agents;
std::copy_if(std::begin(_agents), std::end(_agents), std::back_inserter(agents),
diff --git a/projects/rocprofiler-systems/source/lib/core/amd_smi.cpp b/projects/rocprofiler-systems/source/lib/core/amd_smi.cpp
index 05935f5372..afa594c1e9 100644
--- a/projects/rocprofiler-systems/source/lib/core/amd_smi.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/amd_smi.cpp
@@ -23,10 +23,11 @@
#include "core/amd_smi.hpp"
#include "core/common.hpp"
#include "core/config.hpp"
-#include "core/debug.hpp"
#include "core/gpu.hpp"
#include "timemory.hpp"
+#include "logger/debug.hpp"
+
#if defined(ROCPROFSYS_USE_ROCM) && ROCPROFSYS_USE_ROCM > 0
namespace rocprofsys
{
@@ -54,8 +55,8 @@ get_setting_name(std::string _v)
__VA_ARGS__ }); \
if(!_ret.second) \
{ \
- ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \
- get_setting_name(ENV_NAME).c_str(), ENV_NAME); \
+ LOG_WARNING("Duplicate setting: {} / {}", get_setting_name(ENV_NAME), \
+ ENV_NAME); \
} \
return _config->find(ENV_NAME)->second; \
}()
@@ -68,10 +69,10 @@ config_settings(const std::shared_ptr& _config)
std::string default_metrics = "busy, temp, power, mem_usage";
// No distinction between busy and activity shown in description
- std::string jpeg_activity_support = "";
- std::string vcn_activity_support = "";
- std::string xgmi_support = "";
- std::string pcie_support = "";
+ std::string jpeg_activity_support{};
+ std::string vcn_activity_support{};
+ std::string xgmi_support{};
+ std::string pcie_support{};
size_t device_count = gpu::get_processor_count();
for(size_t i = 0; i < device_count; i++)
diff --git a/projects/rocprofiler-systems/source/lib/core/argparse.cpp b/projects/rocprofiler-systems/source/lib/core/argparse.cpp
index e7ec3d50e4..c4230ff807 100644
--- a/projects/rocprofiler-systems/source/lib/core/argparse.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/argparse.cpp
@@ -32,6 +32,8 @@
#include
#include
+#include "logger/debug.hpp"
+
namespace rocprofsys
{
namespace argparse
@@ -216,6 +218,20 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
_parser.start_group("DEBUG OPTIONS", "");
+ if(_data.environ_filter("log_level", _data))
+ {
+ _parser.add_argument({ "--log-level" }, "Log level")
+ .max_count(1)
+ .dtype("string")
+ .choices({ "trace", "debug", "info", "warn", "error", "critical", "off" })
+ .action([&](parser_t& p) {
+ update_env(_data, "ROCPROFSYS_LOG_LEVEL",
+ p.get("log-level"));
+ });
+
+ _data.processed_environs.emplace("log_level");
+ }
+
if(_data.environ_filter("monochrome", _data))
{
_parser.add_argument({ "--monochrome" }, "Disable colorized output")
@@ -234,24 +250,35 @@ add_core_arguments(parser_t& _parser, parser_data& _data)
if(_data.environ_filter("debug", _data))
{
- _parser.add_argument({ "--debug" }, "Debug output")
+ _parser
+ .add_argument({ "--debug" },
+ "[DEPRECATED Use --log-level=debug] Debug output")
.max_count(1)
- .action([&](parser_t& p) {
- update_env(_data, "ROCPROFSYS_DEBUG", p.get("debug"));
- });
+ .action(
+ [&](parser_t&) { update_env(_data, "ROCPROFSYS_LOG_LEVEL", "debug"); });
_data.processed_environs.emplace("debug");
}
if(_data.environ_filter("verbose", _data))
{
- _parser.add_argument({ "-v", "--verbose" }, "Verbose output")
+ _parser
+ .add_argument({ "-v", "--verbose" },
+ "[DEPRECATED Use --log-level=trace] Verbose output")
.count(1)
.dtype("integral")
.action([&](parser_t& p) {
auto _v = p.get("verbose");
_data.verbose = _v;
update_env(_data, "ROCPROFSYS_VERBOSE", _v);
+
+ constexpr std::array log_levels = { "off", "info",
+ "debug", "debug",
+ "trace" };
+
+ auto index =
+ std::clamp(_v + 1, 0, static_cast(log_levels.size() - 1));
+ update_env(_data, "ROCPROFSYS_LOG_LEVEL", log_levels[index]);
});
_data.processed_environs.emplace("verbose");
@@ -1172,8 +1199,7 @@ add_group_arguments(parser_t& _parser, const std::string& _group_name, parser_da
}
else
{
- TIMEMORY_PRINTF_WARNING(stderr, "Warning! Option %s (%s) is not enabled\n",
- _name.c_str(), itr->get_env_name().c_str());
+ LOG_WARNING("Option {} ({}) is not enabled", _name, itr->get_env_name());
_parser.add_argument({ _opt_name }, itr->get_description())
.action([&](parser_t& p) {
using namespace timemory::join;
diff --git a/projects/rocprofiler-systems/source/lib/core/binary/address_range.cpp b/projects/rocprofiler-systems/source/lib/core/binary/address_range.cpp
index a968b826df..711a73463a 100644
--- a/projects/rocprofiler-systems/source/lib/core/binary/address_range.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/binary/address_range.cpp
@@ -21,7 +21,8 @@
// SOFTWARE.
#include "binary/address_range.hpp"
-#include "debug.hpp"
+
+#include "logger/debug.hpp"
namespace rocprofsys
{
@@ -36,9 +37,11 @@ address_range::address_range(uintptr_t _low, uintptr_t _high)
: low{ _low }
, high{ _high }
{
- TIMEMORY_REQUIRE(high >= low)
- << "Error! address_range high must be >= low. low=" << as_hex(low)
- << ", high=" << as_hex(high) << "\n";
+ if(high < low)
+ {
+ throw std::invalid_argument(fmt::format(
+ "address_range high must be >= low. low={:X}, high={:X}", low, high));
+ }
}
bool
@@ -58,6 +61,19 @@ address_range::as_string(int _depth) const
return _ss.str();
}
+std::string
+address_range::as_hex() const
+{
+ const auto c_width = 16;
+ const auto _as_hex_util = [](auto _v, size_t _width) {
+ return fmt::format("0x{:0{}x}", _v, _width);
+ };
+
+ return (is_range()) ? fmt::format("{}-{}", _as_hex_util(low, c_width),
+ _as_hex_util(high, c_width))
+ : _as_hex_util(low, c_width);
+}
+
uintptr_t
address_range::size() const
{
@@ -171,8 +187,10 @@ address_range&
address_range::operator+=(address_range _v)
{
if(!contiguous_with(_v))
- throw exception(
- "attempting to add two address ranges that are not contiguous");
+ {
+ throw std::invalid_argument(
+ "Error! attempting to add two address ranges that are not contiguous");
+ }
low = std::min(low, _v.low);
high = std::max(high, _v.high);
diff --git a/projects/rocprofiler-systems/source/lib/core/binary/address_range.hpp b/projects/rocprofiler-systems/source/lib/core/binary/address_range.hpp
index ae915003cd..6a2cd7dfd3 100644
--- a/projects/rocprofiler-systems/source/lib/core/binary/address_range.hpp
+++ b/projects/rocprofiler-systems/source/lib/core/binary/address_range.hpp
@@ -69,6 +69,8 @@ struct address_range
uintptr_t size() const;
explicit operator bool() const { return is_valid(); }
+ std::string as_hex() const;
+
template
void serialize(ArchiveT& ar, const unsigned)
{
diff --git a/projects/rocprofiler-systems/source/lib/core/categories.cpp b/projects/rocprofiler-systems/source/lib/core/categories.cpp
index 22f7a2eea6..2ce653b578 100644
--- a/projects/rocprofiler-systems/source/lib/core/categories.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/categories.cpp
@@ -24,10 +24,11 @@
#include "core/common.hpp"
#include "core/config.hpp"
#include "core/constraint.hpp"
-#include "core/debug.hpp"
#include "core/timemory.hpp"
#include "core/utility.hpp"
+#include "logger/debug.hpp"
+
#include
#include
@@ -44,8 +45,7 @@ configure_categories(bool _enable, const std::set& _categories)
auto _name = trait::name::value;
if(_categories.count(_name) > 0)
{
- ROCPROFSYS_VERBOSE_F(3, "%s category: %s\n", (_enable) ? "Enabling" : "Disabling",
- _name);
+ LOG_DEBUG("{} category: {}", _enable ? "Enabling" : "Disabling", _name);
trait::runtime_enabled::set(_enable);
}
}
@@ -61,7 +61,7 @@ configure_categories(bool _enable, const std::set& _categories,
void
configure_categories(bool _enable, const std::set& _categories)
{
- ROCPROFSYS_VERBOSE_F(1, "%s categories...\n", (_enable) ? "Enabling" : "Disabling");
+ LOG_DEBUG("{} categories...", (_enable) ? "Enabling" : "Disabling");
configure_categories(
_enable, _categories,
diff --git a/projects/rocprofiler-systems/source/lib/core/config.cpp b/projects/rocprofiler-systems/source/lib/core/config.cpp
index ffbb4dd46e..192875063e 100644
--- a/projects/rocprofiler-systems/source/lib/core/config.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/config.cpp
@@ -25,7 +25,6 @@
#include "common/defines.h"
#include "common/static_object.hpp"
#include "constraint.hpp"
-#include "debug.hpp"
#include "defines.hpp"
#include "gpu.hpp"
#include "mproc.hpp"
@@ -56,6 +55,8 @@
#include
#include
+#include "logger/debug.hpp"
+
#include
#include
#include
@@ -143,8 +144,8 @@ using utility::parse_numeric_range;
__VA_ARGS__ }); \
if(!_ret.second) \
{ \
- ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \
- get_setting_name(ENV_NAME).c_str(), ENV_NAME); \
+ LOG_WARNING("Duplicate setting: {} / {}", get_setting_name(ENV_NAME), \
+ ENV_NAME); \
} \
return _config->find(ENV_NAME)->second; \
}()
@@ -157,8 +158,8 @@ using utility::parse_numeric_range;
std::set{ "custom", "rocprofsys", __VA_ARGS__ }); \
if(!_ret.second) \
{ \
- ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \
- get_setting_name(ENV_NAME).c_str(), ENV_NAME); \
+ LOG_WARNING("Duplicate setting: {} / {}", get_setting_name(ENV_NAME), \
+ ENV_NAME); \
} \
return _config->find(ENV_NAME)->second; \
}()
@@ -174,8 +175,8 @@ using utility::parse_numeric_range;
std::vector{ CMD_LINE }); \
if(!_ret.second) \
{ \
- ROCPROFSYS_PRINT("Warning! Duplicate setting: %s / %s\n", \
- get_setting_name(ENV_NAME).c_str(), ENV_NAME); \
+ LOG_WARNING("Duplicate setting: {} / {}", get_setting_name(ENV_NAME), \
+ ENV_NAME); \
} \
return _config->find(ENV_NAME)->second; \
}()
@@ -191,7 +192,7 @@ auto cfg_fini_callbacks = std::vector>{};
void
finalize()
{
- ROCPROFSYS_DEBUG("[rocprofsys_finalize] Disabling signal handling...\n");
+ LOG_DEBUG("[rocprofsys_finalize] Disabling signal handling...");
tim::signals::disable_signal_detection();
_settings_are_configured() = false;
for(const auto& itr : cfg_fini_callbacks)
@@ -216,9 +217,11 @@ configure_settings(bool _init)
if(is_ci_value && get_state() < State::Init)
{
timemory_print_demangled_backtrace<64>();
- ROCPROFSYS_THROW("config::configure_settings() called before "
- "rocprofsys_init_library. state = %s",
- std::to_string(get_state()).c_str());
+
+ auto message = fmt::format("config::configure_settings() called before "
+ "rocprofsys_init_library. state = {}",
+ static_cast(get_state()));
+ throw std::runtime_error(message);
}
tim::manager::add_metadata("ROCPROFSYS_VERSION", ROCPROFSYS_VERSION_STRING);
@@ -256,6 +259,15 @@ configure_settings(bool _init)
auto _system_backend =
tim::get_env("ROCPROFSYS_PERFETTO_BACKEND_SYSTEM", false, false);
+ ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_LOG_LEVEL",
+ "Rocprofiler-systems log level", "info", "debugging",
+ "advanced");
+
+ ROCPROFSYS_CONFIG_SETTING(std::string, "ROCPROFSYS_LOG_FILE",
+ "Filename for the Rocprofiler-systems log file. Leave "
+ "empty to not write to a file.",
+ "rocprof-sys-log.txt", "debugging", "advanced");
+
auto _rocprofsys_debug = _config->get("ROCPROFSYS_DEBUG");
if(_rocprofsys_debug) tim::set_env("TIMEMORY_DEBUG_SETTINGS", "1", 0);
@@ -876,6 +888,7 @@ configure_settings(bool _init)
_add_rocprofsys_category(_config->find("ROCPROFSYS_CONFIG_FILE"));
_add_rocprofsys_category(_config->find("ROCPROFSYS_DEBUG"));
_add_rocprofsys_category(_config->find("ROCPROFSYS_VERBOSE"));
+ _add_rocprofsys_category(_config->find("ROCPROFSYS_LOG_LEVEL"));
_add_rocprofsys_category(_config->find("ROCPROFSYS_TIME_OUTPUT"));
_add_rocprofsys_category(_config->find("ROCPROFSYS_OUTPUT_PREFIX"));
_add_rocprofsys_category(_config->find("ROCPROFSYS_OUTPUT_PATH"));
@@ -892,7 +905,8 @@ configure_settings(bool _init)
{
if(_config->get("ROCPROFSYS_CI"))
{
- ROCPROFSYS_THROW("Error! Setting '%s' not found!", _name.c_str());
+ throw std::runtime_error(
+ fmt::format("Error! Setting '{}' not found!", _name));
}
}
};
@@ -905,6 +919,7 @@ configure_settings(bool _init)
_add_advanced_category("ROCPROFSYS_TEXT_OUTPUT");
_add_advanced_category("ROCPROFSYS_DIFF_OUTPUT");
_add_advanced_category("ROCPROFSYS_DEBUG");
+ _add_advanced_category("ROCPROFSYS_LOG_LEVEL");
_add_advanced_category("ROCPROFSYS_ENABLE_SIGNAL_HANDLER");
_add_advanced_category("ROCPROFSYS_FLAT_PROFILE");
_add_advanced_category("ROCPROFSYS_INPUT_EXTENSIONS");
@@ -952,14 +967,11 @@ configure_settings(bool _init)
if(_paranoid > 2 && !_has_cap_sys_admin)
{
- ROCPROFSYS_BASIC_VERBOSE(
- 0,
- "/proc/sys/kernel/perf_event_paranoid has a value of %i. "
- "Disabling PAPI (requires a value <= 2)...\n",
- _paranoid);
- ROCPROFSYS_BASIC_VERBOSE(
- 0, "In order to enable PAPI support, run 'echo N | sudo tee "
- "/proc/sys/kernel/perf_event_paranoid' where N is <= 2\n");
+ LOG_WARNING("/proc/sys/kernel/perf_event_paranoid has a value of {}. "
+ "Disabling PAPI (requires a value <= 2)",
+ _paranoid);
+ LOG_WARNING("In order to enable PAPI support, run 'echo N | sudo tee "
+ "/proc/sys/kernel/perf_event_paranoid' where N is <= 2");
trait::runtime_enabled::set(false);
trait::runtime_enabled>::set(false);
trait::runtime_enabled::set(false);
@@ -1019,7 +1031,7 @@ configure_settings(bool _init)
{
if(_config->get_suppress_config()) continue;
- ROCPROFSYS_BASIC_VERBOSE(1, "Reading config file %s\n", itr.c_str());
+ LOG_DEBUG("Reading config file {}", itr);
if(_config->read(itr) && _main_proc &&
((_config->get("ROCPROFSYS_CI") && settings::verbose() >= 0) ||
settings::verbose() >= 1 || settings::debug()))
@@ -1035,8 +1047,7 @@ configure_settings(bool _init)
}
if(!_iss.str().empty())
{
- ROCPROFSYS_BASIC_VERBOSE(1, "config file '%s':\n%s\n", fitr.c_str(),
- _iss.str().c_str());
+ LOG_DEBUG("config file '{}': {}", fitr, _iss.str());
}
}
}
@@ -1106,7 +1117,7 @@ configure_settings(bool _init)
configure_signal_handler(_config);
configure_disabled_settings(_config);
- ROCPROFSYS_BASIC_VERBOSE(2, "configuration complete\n");
+ LOG_DEBUG("Configuration complete");
if(auto opt = get_setting_value("ROCPROFSYS_VERBOSE"); opt) verbose_value = *opt;
if(auto opt = get_setting_value("ROCPROFSYS_DEBUG"); opt) debug_value = *opt;
@@ -1121,18 +1132,17 @@ configure_mode_settings(const std::shared_ptr& _config)
auto _set = [](const std::string& _name, bool _v) {
if(!set_setting_value(_name, _v))
{
- ROCPROFSYS_BASIC_VERBOSE(
- 4, "[configure_mode_settings] No configuration setting named '%s'...\n",
- _name.data());
+ LOG_DEBUG("[configure_mode_settings] No configuration setting named '{}'...",
+ _name);
}
else
{
bool _changed = get_setting_value(_name).value_or(!_v) != _v;
- ROCPROFSYS_BASIC_VERBOSE(
- 1 && _changed,
- "[configure_mode_settings] Overriding %s to %s in %s mode...\n",
- _name.c_str(), JOIN("", std::boolalpha, _v).c_str(),
- std::to_string(get_mode()).c_str());
+ if(_changed)
+ {
+ LOG_WARNING("[configure_mode_settings] Overriding {} to {} in {} mode...",
+ _name, _v, static_cast(get_mode()));
+ }
}
};
@@ -1169,8 +1179,7 @@ configure_mode_settings(const std::shared_ptr& _config)
if(gpu::device_count() == 0)
{
#if ROCPROFSYS_ROCM_VERSION > 0
- ROCPROFSYS_BASIC_VERBOSE(
- 1, "No ROCm devices were found: disabling rocm and amd_smi...\n");
+ LOG_WARNING("No ROCm devices were found: disabling rocm and amd_smi...");
#endif
_set("ROCPROFSYS_USE_ROCM", false);
_set("ROCPROFSYS_USE_AMD_SMI", false);
@@ -1188,10 +1197,9 @@ configure_mode_settings(const std::shared_ptr& _config)
{
_force = 1;
_message =
- JOIN("", " (forced. Previous value: '", _current_kokkosp_lib, "')");
+ fmt::format(" (forced. Previous value: '{}')", _current_kokkosp_lib);
}
- ROCPROFSYS_BASIC_VERBOSE_F(1, "Setting KOKKOS_TOOLS_LIBS=%s%s\n",
- "librocprof-sys.so", _message.c_str());
+ LOG_WARNING("Setting KOKKOS_TOOLS_LIBS={}{}", "librocprof-sys.so", _message);
tim::set_env("KOKKOS_TOOLS_LIBS", "librocprof-sys.so", _force);
}
}
@@ -1236,8 +1244,8 @@ rocprofsys_exit_action(int nsig)
{
tim::signals::block_signals(get_sampling_signals(),
tim::signals::sigmask_scope::process);
- ROCPROFSYS_BASIC_PRINT("Finalizing after signal %i :: %s\n", nsig,
- signal_settings::str(static_cast(nsig)).c_str());
+ LOG_DEBUG("Finalizing after signal {} :: {}", nsig,
+ signal_settings::str(static_cast(nsig)));
auto _handler = get_signal_handler().load();
if(_handler) (*_handler)();
kill(process::get_id(), nsig);
@@ -1246,16 +1254,7 @@ rocprofsys_exit_action(int nsig)
void
rocprofsys_trampoline_handler(int _v)
{
- if(get_verbose_env() >= 1)
- {
- ::rocprofsys::debug::flush();
- ::rocprofsys::debug::lock _debug_lk{};
- ROCPROFSYS_FPRINTF_STDERR_COLOR(warning);
- fprintf(::rocprofsys::debug::get_file(),
- "signal %i ignored (ROCPROFSYS_IGNORE_DYNINST_TRAMPOLINE=ON)\n", _v);
- ::rocprofsys::debug::flush();
- timemory_print_demangled_backtrace<64>();
- }
+ LOG_DEBUG("signal {} ignored (ROCPROFSYS_IGNORE_DYNINST_TRAMPOLINE=ON)", _v);
}
} // namespace
@@ -1357,8 +1356,8 @@ get_sampling_signals(int64_t)
if(get_use_sampling() && !get_use_sampling_cputime() &&
!get_use_sampling_realtime() && !get_use_sampling_overflow())
{
- ROCPROFSYS_VERBOSE_F(1, "sampling enabled by cputime/realtime/overflow not "
- "specified. defaulting to cputime...\n");
+ LOG_WARNING("Sampling enabled by cputime/realtime/overflow is not "
+ "specified. Defaulting to cputime...");
set_setting_value("ROCPROFSYS_SAMPLING_CPUTIME", true);
}
@@ -1380,14 +1379,12 @@ configure_disabled_settings(const std::shared_ptr& _config)
auto _disabled = _config->disable_category(_category);
_config->enable(_opt);
for(auto&& itr : _disabled)
- ROCPROFSYS_BASIC_VERBOSE(3, "[%s=OFF] disabled option :: '%s'\n",
- _opt.c_str(), itr.c_str());
+ LOG_DEBUG("[{}=OFF] disabled option :: '{}'", _opt, itr);
return false;
}
auto _enabled = _config->enable_category(_category);
for(auto&& itr : _enabled)
- ROCPROFSYS_BASIC_VERBOSE(3, "[%s=ON] enabled option :: '%s'\n",
- _opt.c_str(), itr.c_str());
+ LOG_DEBUG("[{}=ON] enabled option :: '{}'", _opt, itr);
return true;
};
@@ -1493,8 +1490,11 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int
if(_old_setting == _config->end()) return;
- ROCPROFSYS_CI_THROW(_new_setting == _config->end(),
- "New configuration setting not found: '%s'", _new.c_str());
+ if(get_is_continuous_integration() && _new_setting == _config->end())
+ {
+ throw std::runtime_error(
+ fmt::format("New configuration setting not found: '{}'", _new));
+ }
if(_old_setting->second->get_environ_updated() ||
_old_setting->second->get_config_updated())
@@ -1503,13 +1503,13 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int
std::array _v = {};
_v.fill('=');
_v.back() = '\0';
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "#%s#\n", _v.data());
+ LOG_WARNING("#{}#", _v.data());
};
_separator();
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n");
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "# DEPRECATION NOTICE:\n");
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "# %s is deprecated!\n", _old.c_str());
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "# Use %s instead!\n", _new.c_str());
+ LOG_WARNING("#");
+ LOG_WARNING("# DEPRECATION NOTICE:");
+ LOG_WARNING("# {} is deprecated!", _old);
+ LOG_WARNING("# Use {} instead!", _new);
if(!_new_setting->second->get_environ_updated() &&
!_new_setting->second->get_config_updated())
@@ -1522,15 +1522,13 @@ handle_deprecated_setting(const std::string& _old, const std::string& _new, int
{
std::string _cause =
(_old_setting->second->get_environ_updated()) ? "environ" : "config";
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n");
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "# %s :: '%s' -> '%s'\n", _new.c_str(),
- _before.c_str(), _after.c_str());
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "# via %s (%s)\n", _old.c_str(),
- _cause.c_str());
+ LOG_WARNING("#");
+ LOG_WARNING("# {} :: '{}' -> '{}'", _new, _before, _after);
+ LOG_WARNING("# via {} ({})", _old, _cause);
}
}
- ROCPROFSYS_BASIC_VERBOSE(_verbose, "#\n");
+ LOG_WARNING("#");
_separator();
}
}
@@ -1579,7 +1577,8 @@ print_banner(std::ostream& _os)
if(!_properties.empty())
_version_info << join::join(join::array_config{ ", ", " (", ")" }, _properties);
- tim::log::stream(_os, tim::log::color::info()) << _banner << _version_info.str();
+ _os << _banner << "\n";
+ _os << _version_info.str() << "\n";
_os << std::endl;
}
@@ -1588,7 +1587,7 @@ print_settings(
std::ostream& _ros,
std::function&)>&& _filter)
{
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT(true, "configuration:\n");
+ LOG_INFO("configuration:");
std::stringstream _os{};
@@ -1700,18 +1699,19 @@ print_settings(bool _include_env)
if(_include_env)
{
- std::cerr << tim::log::info;
- tim::print_env(std::cerr, [_is_rocprofsys_option](const std::string& _v) {
+ std::stringstream _ss1{};
+ tim::print_env(_ss1, [_is_rocprofsys_option](const std::string& _v) {
auto _is_omni_opt = _is_rocprofsys_option(_v, std::set{});
if(settings::verbose() >= 2 || settings::debug()) return _is_omni_opt;
return (_is_omni_opt && _v.find("ROCPROFSYS_SIGNAL_") != 0);
});
- std::cerr << tim::log::flush;
+
+ LOG_INFO("{}", _ss1.str());
}
- print_settings(std::cerr, _is_rocprofsys_option);
-
- fprintf(stderr, "\n");
+ std::stringstream _ss2{};
+ print_settings(_ss2, _is_rocprofsys_option);
+ LOG_INFO("{}", _ss2.str());
}
std::string&
@@ -1771,8 +1771,8 @@ get_mode()
for(const auto& itr : _v->second->get_choices())
_ss << ", " << itr;
auto _msg = (_ss.str().length() > 2) ? _ss.str().substr(2) : std::string{};
- ROCPROFSYS_THROW("[%s] invalid mode %s. Choices: %s\n", __FUNCTION__,
- _mode.c_str(), _msg.c_str());
+ throw std::runtime_error(
+ fmt::format("[{}] invalid mode {}. Choices: {}", __FUNCTION__, _mode, _msg));
}
return Mode::Trace;
}
@@ -1902,8 +1902,9 @@ get_use_sampling()
static auto _v = get_config()->find("ROCPROFSYS_USE_SAMPLING");
return static_cast&>(*_v->second).get();
#else
- ROCPROFSYS_THROW("Error! sampling was enabled but rocprof-sys was not built with "
- "libunwind support");
+ throw std::runtime_error(
+ "Error! sampling was enabled but rocprof-sys was not built with "
+ "libunwind support");
static bool _v = false;
return _v;
#endif
@@ -2110,15 +2111,20 @@ get_category_config()
}
else
{
- ROCPROFSYS_ABORT(
- "Error! Conflicting options ROCPROFSYS_ENABLE_CATEGORIES and "
- "ROCPROFSYS_DISABLE_CATEGORIES were both provided.");
+ LOG_CRITICAL("Error! Conflicting options ROCPROFSYS_ENABLE_CATEGORIES and "
+ "ROCPROFSYS_DISABLE_CATEGORIES were both provided.");
+ ::rocprofsys::set_state(::rocprofsys::State::Finalized);
+ std::abort();
}
- ROCPROFSYS_CI_THROW(_enabled.size() + _disabled.size() != _avail.size(),
- "Error! Internal error for categories: %zu (enabled) + %zu "
- "(disabled) != %zu (total)\n",
- _enabled.size(), _disabled.size(), _avail.size());
+ if(get_is_continuous_integration() &&
+ _enabled.size() + _disabled.size() != _avail.size())
+ {
+ throw std::runtime_error(
+ fmt::format("Error! Internal error for categories: {} (enabled) + {} "
+ "(disabled) != {} (total)\n",
+ _enabled.size(), _disabled.size(), _avail.size()));
+ }
return std::make_pair(_enabled, _disabled);
}();
@@ -2181,38 +2187,26 @@ get_perfetto_output_filename()
_val = _val.substr(0, _pos_ext);
}
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] Parsed: dir='%s', basename='%s', ext='%s'\n",
- _dir.c_str(), _val.c_str(), _ext.c_str());
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] settings::output_path()='%s'\n",
- settings::output_path().c_str());
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] settings::output_prefix()='%s'\n",
- settings::output_prefix().c_str());
+ LOG_DEBUG("Parsed: dir='{}', basename='{}', ext='{}'", _dir, _val, _ext);
+ LOG_DEBUG("settings::output_path()='{}'", settings::output_path());
+ LOG_DEBUG("settings::output_prefix()='{}'", settings::output_prefix());
auto _cfg = settings::compose_filename_config{ settings::use_output_suffix(),
settings::default_process_suffix(),
false, _dir };
_val = settings::compose_output_filename(_val, _ext, _cfg);
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] After compose_output_filename: '%s'\n",
- _val.c_str());
+ LOG_DEBUG("After compose_output_filename: '{}'", _val);
if(!_val.empty() && _val.at(0) != '/')
{
auto _result =
settings::format(JOIN('/', "%env{PWD}%", _val), get_config()->get_tag());
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] Path is relative, prepending PWD: '%s'\n",
- _result.c_str());
+ LOG_DEBUG("Path is relative, prepending PWD: '{}'", _result);
return _result;
}
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename] Path is absolute, returning: '%s'\n",
- _val.c_str());
+ LOG_DEBUG("Path is absolute, returning: '{}'", _val);
return _val;
}
@@ -2472,18 +2466,12 @@ get_perfetto_output_filename_with_suffix(std::string_view suffix)
static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_FILE");
auto _val = static_cast&>(*_v->second).get();
- ROCPROFSYS_BASIC_VERBOSE_F(2,
- "[get_perfetto_output_filename_with_suffix] Initial "
- "ROCPROFSYS_PERFETTO_FILE='%s', suffix='%s'\n",
- _val.c_str(), std::string{ suffix }.c_str());
+ LOG_DEBUG("Initial ROCPROFSYS_PERFETTO_FILE='{}', suffix='{}'", _val, suffix);
// If absolute path is provided, return it as-is
if(!_val.empty() && _val.at(0) == '/')
{
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2,
- "[get_perfetto_output_filename_with_suffix] Absolute path, returning: '%s'\n",
- _val.c_str());
+ LOG_DEBUG("Absolute path, returning: '{}'", _val);
return _val;
}
@@ -2509,14 +2497,9 @@ get_perfetto_output_filename_with_suffix(std::string_view suffix)
bool _explicitly_set =
(_v->second->get_environ_updated() || _v->second->get_config_updated());
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2,
- "[get_perfetto_output_filename_with_suffix] Parsed: dir='%s', basename='%s', "
- "ext='%s', explicitly_set=%s\n",
- _dir.c_str(), _val.c_str(), _ext.c_str(), _explicitly_set ? "true" : "false");
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2, "[get_perfetto_output_filename_with_suffix] settings::output_path()='%s'\n",
- settings::output_path().c_str());
+ LOG_DEBUG("Parsed: dir='{}', basename='{}', ext='{}', explicitly_set={}", _dir, _val,
+ _ext, _explicitly_set);
+ LOG_DEBUG("settings::output_path()='{}'", settings::output_path());
auto _cfg = settings::compose_filename_config{
!_explicitly_set && !suffix.empty(), // use_suffix only if not explicitly set
@@ -2527,26 +2510,17 @@ get_perfetto_output_filename_with_suffix(std::string_view suffix)
_val = settings::compose_output_filename(_val, _ext, _cfg);
- ROCPROFSYS_BASIC_VERBOSE_F(2,
- "[get_perfetto_output_filename_with_suffix] After "
- "compose_output_filename: '%s'\n",
- _val.c_str());
+ LOG_DEBUG("After compose_output_filename: '{}'", _val);
if(!_val.empty() && _val.at(0) != '/')
{
auto _result =
settings::format(JOIN('/', "%env{PWD}%", _val), get_config()->get_tag());
- ROCPROFSYS_BASIC_VERBOSE_F(2,
- "[get_perfetto_output_filename_with_suffix] Path is "
- "relative, prepending PWD: '%s'\n",
- _result.c_str());
+ LOG_DEBUG("Path is relative, prepending PWD: '{}'", _result);
return _result;
}
- ROCPROFSYS_BASIC_VERBOSE_F(
- 2,
- "[get_perfetto_output_filename_with_suffix] Path is absolute, returning: '%s'\n",
- _val.c_str());
+ LOG_DEBUG("Path is absolute, returning: '{}'", _val);
return _val;
}
@@ -2599,7 +2573,7 @@ tmp_file::touch() const
bool
tmp_file::open(int _mode, int _perms)
{
- ROCPROFSYS_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str());
+ LOG_DEBUG("Opening temporary file '{}'...", filename);
touch();
m_pid = getpid();
@@ -2611,7 +2585,7 @@ tmp_file::open(int _mode, int _perms)
bool
tmp_file::open(std::ios::openmode _mode)
{
- ROCPROFSYS_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str());
+ LOG_DEBUG("Opening temporary file '{}'...", filename);
touch();
@@ -2624,7 +2598,7 @@ tmp_file::open(std::ios::openmode _mode)
bool
tmp_file::fopen(const char* _mode)
{
- ROCPROFSYS_BASIC_VERBOSE(2, "Opening temporary file '%s'...\n", filename.c_str());
+ LOG_DEBUG("Opening temporary file '{}'...", filename);
touch();
@@ -2715,8 +2689,7 @@ tmp_file::remove()
close();
if(filepath::exists(filename))
{
- ROCPROFSYS_BASIC_VERBOSE(2, "Removing temporary file '%s'...\n",
- filename.c_str());
+ LOG_DEBUG("Removing temporary file '{}'...", filename);
auto _ret = ::remove(filename.c_str());
return (_ret == 0);
}
@@ -2764,9 +2737,10 @@ get_tmp_file(std::string _basename, std::string _ext)
if(_fname.empty() || _fname.front() != '/')
{
- ROCPROFSYS_THROW("Error! temporary file '%s' (based on '%s.%s') is either empty "
- "or is not an absolute path",
- _fname.c_str(), _basename.c_str(), _ext.c_str());
+ throw std::runtime_error(
+ fmt::format("Error! temporary file '{}' (based on '{}.'{}) is either empty "
+ "or is not an absolute path",
+ _fname, _basename, _ext));
}
auto itr = _existing_files.find(_fname);
if(itr != _existing_files.end()) return itr->second;
@@ -2792,11 +2766,10 @@ get_causal_backend()
} catch(std::runtime_error& _e)
{
auto _mode = static_cast&>(*_v->second).get();
- ROCPROFSYS_THROW(
- "[%s] invalid causal backend %s. Choices: %s\n", __FUNCTION__, _mode.c_str(),
+ throw std::runtime_error(fmt::format(
+ "[{}] invalid causal backend {}. Choices: {}", __FUNCTION__, _mode,
timemory::join::join(timemory::join::array_config{ ", ", "", "" },
- _v->second->get_choices())
- .c_str());
+ _v->second->get_choices())));
}
return CausalBackend::Auto;
}
@@ -2824,11 +2797,10 @@ get_causal_mode()
} catch(std::runtime_error& _e)
{
auto _mode = static_cast&>(*_v->second).get();
- ROCPROFSYS_THROW(
- "[%s] invalid causal mode %s. Choices: %s\n", __FUNCTION__, _mode.c_str(),
+ throw std::runtime_error(fmt::format(
+ "[{}] invalid causal mode {}. Choices: {}", __FUNCTION__, _mode,
timemory::join::join(timemory::join::array_config{ ", ", "", "" },
- _v->second->get_choices())
- .c_str());
+ _v->second->get_choices())));
}
return CausalMode::Function;
}();
diff --git a/projects/rocprofiler-systems/source/lib/core/constraint.cpp b/projects/rocprofiler-systems/source/lib/core/constraint.cpp
index f28c2f004b..1f8cd5eb2b 100644
--- a/projects/rocprofiler-systems/source/lib/core/constraint.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/constraint.cpp
@@ -22,13 +22,14 @@
#include "constraint.hpp"
#include "config.hpp"
-#include "debug.hpp"
#include "state.hpp"
#include "utility.hpp"
#include
#include
+#include "logger/debug.hpp"
+
#include
#include
#include
@@ -101,9 +102,10 @@ find_clock_identifier(const Tp& _v)
}
}
- ROCPROFSYS_THROW("Unknown clock id %s: %s. Valid choices: %s\n", _descript,
- timemory::join::join("", _v).c_str(),
- timemory::join::join("", accepted_clock_ids).c_str());
+ throw std::runtime_error(
+ fmt::format("Unknown clock id {}: {}. Valid choices: {}", _descript,
+ timemory::join::join("", _v).c_str(),
+ timemory::join::join("", accepted_clock_ids).c_str()));
}
void
@@ -267,12 +269,10 @@ spec::operator()(const stages& _stages) const
return _ret;
};
- ROCPROFSYS_VERBOSE(2,
- "Executing constraint spec %lu of %lu :: delay: %6.3f, "
- "duration: %6.3f, clock: %s\n",
- i, _spec.repeat, _spec.delay, _spec.duration,
- _spec.clock_id.as_string().c_str());
-
+ LOG_DEBUG("Executing constraint spec {} of {} :: delay: {:.3f}, "
+ "duration: {:.3f}, clock: {}",
+ i, _spec.repeat, _spec.delay, _spec.duration,
+ _spec.clock_id.as_string());
if(_stages.init(_spec) && _wait(_stages.wait, _spec.delay) &&
_stages.start(_spec) && _wait(_stages.collect, _spec.duration) &&
_stages.stop(_spec))
diff --git a/projects/rocprofiler-systems/source/lib/core/containers/aligned_static_vector.hpp b/projects/rocprofiler-systems/source/lib/core/containers/aligned_static_vector.hpp
index da9e203129..1d6bdec08b 100644
--- a/projects/rocprofiler-systems/source/lib/core/containers/aligned_static_vector.hpp
+++ b/projects/rocprofiler-systems/source/lib/core/containers/aligned_static_vector.hpp
@@ -24,7 +24,6 @@
#include "core/common.hpp"
#include "core/containers/operators.hpp"
-#include "core/debug.hpp"
#include "core/exception.hpp"
#include
diff --git a/projects/rocprofiler-systems/source/lib/core/containers/static_vector.hpp b/projects/rocprofiler-systems/source/lib/core/containers/static_vector.hpp
index 304bbc0f02..7b457d9642 100644
--- a/projects/rocprofiler-systems/source/lib/core/containers/static_vector.hpp
+++ b/projects/rocprofiler-systems/source/lib/core/containers/static_vector.hpp
@@ -24,7 +24,6 @@
#include "core/common.hpp"
#include "core/containers/c_array.hpp"
-#include "core/debug.hpp"
#include "core/exception.hpp"
#include
diff --git a/projects/rocprofiler-systems/source/lib/core/debug.cpp b/projects/rocprofiler-systems/source/lib/core/debug.cpp
deleted file mode 100644
index a380c90170..0000000000
--- a/projects/rocprofiler-systems/source/lib/core/debug.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-// MIT License
-//
-// Copyright (c) 2022-2025 Advanced Micro Devices, Inc. All Rights Reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#include "debug.hpp"
-#include "binary/address_range.hpp"
-#include "locking.hpp"
-#include "state.hpp"
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-namespace rocprofsys
-{
-namespace debug
-{
-namespace
-{
-struct source_location_history
-{
- std::array data = {};
- size_t size = 0;
-};
-
-const std::string&
-get_file_name()
-{
- static auto _fname = tim::get_env("ROCPROFSYS_LOG_FILE", "");
- return _fname;
-}
-
-std::atomic&
-get_file_pointer()
-{
- static auto _v = std::atomic{ []() {
- const auto& _fname = get_file_name();
- if(!_fname.empty()) tim::log::monochrome() = true;
- return (_fname.empty())
- ? stderr
- : filepath::fopen(
- settings::format(_fname, filepath::basename(filepath::realpath(
- "/proc/self/exe", nullptr, false))),
- "w");
- }() };
- return _v;
-}
-
-auto&
-get_source_location_history()
-{
- static thread_local auto _v = source_location_history{};
- return _v;
-}
-
-auto _protect_lock = std::atomic{ false };
-auto _protect_unlock = std::atomic{ false };
-} // namespace
-
-void
-set_source_location(source_location&& _v)
-{
- auto& _hist = get_source_location_history();
- auto _idx = _hist.size++;
- _hist.data.at(_idx % _hist.data.size()) = _v;
-}
-
-lock::lock()
-: m_lk{ tim::type_mutex(),
- std::defer_lock }
-{
- if(!m_lk.owns_lock() && !_protect_lock)
- {
- _protect_lock.store(true);
- push_thread_state(ThreadState::Internal);
- m_lk.lock();
- _protect_lock.store(false);
- }
-}
-
-lock::~lock()
-{
- if(m_lk.owns_lock() && !_protect_unlock)
- {
- _protect_unlock.store(true);
- m_lk.unlock();
- pop_thread_state();
- _protect_unlock.store(false);
- }
-}
-
-FILE*
-get_file()
-{
- return get_file_pointer();
-}
-
-void
-close_file()
-{
- if(get_file() != stderr)
- {
- auto* _file = get_file_pointer().load();
- get_file_pointer().store(stderr);
- fclose(_file);
- // Write the trace into a file.
- if(get_verbose() >= 0)
- operation::file_output_message{}(
- get_file_name(), std::string{ "debug" });
- }
-}
-
-int64_t
-get_tid()
-{
- static thread_local auto _v = threading::get_id();
- return _v;
-}
-} // namespace debug
-
-template
-std::string
-as_hex(Tp _v, size_t _width)
-{
- std::stringstream _ss;
- _ss.fill('0');
- _ss << "0x" << std::hex << std::setw(_width) << _v;
- return _ss.str();
-}
-
-template <>
-std::string
-as_hex(address_range_t _v, size_t _width)
-{
- return (_v.is_range()) ? JOIN('-', as_hex(_v.low, _width), as_hex(_v.high, _width))
- : as_hex(_v.low, _width);
-}
-
-template std::string as_hex(int32_t, size_t);
-template std::string as_hex(uint32_t, size_t);
-template std::string as_hex(int64_t, size_t);
-template std::string as_hex(uint64_t, size_t);
-template std::string
-as_hex(void*, size_t);
-} // namespace rocprofsys
diff --git a/projects/rocprofiler-systems/source/lib/core/debug.hpp b/projects/rocprofiler-systems/source/lib/core/debug.hpp
deleted file mode 100644
index fe265767ad..0000000000
--- a/projects/rocprofiler-systems/source/lib/core/debug.hpp
+++ /dev/null
@@ -1,717 +0,0 @@
-// MIT License
-//
-// Copyright (c) 2022-2025 Advanced Micro Devices, Inc. All Rights Reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#pragma once
-
-#include "defines.hpp"
-#include "exception.hpp"
-#include "locking.hpp"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-namespace rocprofsys
-{
-inline namespace config
-{
-bool
-get_debug() ROCPROFSYS_HOT;
-
-int
-get_verbose() ROCPROFSYS_HOT;
-
-bool
-get_debug_env() ROCPROFSYS_HOT;
-
-int
-get_verbose_env() ROCPROFSYS_HOT;
-
-bool
-get_is_continuous_integration() ROCPROFSYS_HOT;
-
-bool
-get_debug_tid() ROCPROFSYS_HOT;
-
-bool
-get_debug_pid() ROCPROFSYS_HOT;
-} // namespace config
-
-namespace debug
-{
-struct source_location
-{
- std::string_view function = {};
- std::string_view file = {};
- int line = 0;
-};
-//
-void
-set_source_location(source_location&&);
-//
-FILE*
-get_file();
-//
-void
-close_file();
-//
-int64_t
-get_tid();
-//
-inline void
-flush()
-{
- fprintf(stdout, "%s", ::tim::log::color::end());
- fflush(stdout);
- std::cout << ::tim::log::color::end() << std::flush;
- fprintf(::rocprofsys::debug::get_file(), "%s", ::tim::log::color::end());
- fflush(::rocprofsys::debug::get_file());
- std::cerr << ::tim::log::color::end() << std::flush;
-}
-//
-struct lock
-{
- lock();
- ~lock();
-
-private:
- locking::atomic_lock m_lk;
-};
-//
-template
-bool
-is_bracket(Arg&& _arg, Args&&...)
-{
- if constexpr(::tim::concepts::is_string_type::value)
- return (::std::string_view{ _arg }.empty()) ? false : _arg[0] == '[';
- else
- return false;
-}
-//
-namespace
-{
-template
-auto
-get_chars(T&& _c, std::index_sequence)
-{
- return std::array{ std::forward(_c)[Idx]...,
- '\0' };
-}
-} // namespace
-} // namespace debug
-
-namespace binary
-{
-struct address_range;
-}
-
-using address_range_t = binary::address_range;
-
-template
-std::string
-as_hex(Tp, size_t _wdith = 16);
-
-template <>
-std::string as_hex(address_range_t, size_t);
-
-extern template std::string as_hex(int32_t, size_t);
-extern template std::string as_hex(uint32_t, size_t);
-extern template std::string as_hex(int64_t, size_t);
-extern template std::string as_hex(uint64_t, size_t);
-extern template std::string
-as_hex(void*, size_t);
-} // namespace rocprofsys
-
-#if !defined(ROCPROFSYS_DEBUG_BUFFER_LEN)
-# define ROCPROFSYS_DEBUG_BUFFER_LEN 1024
-#endif
-
-#if !defined(ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER)
-# if defined(ROCPROFSYS_USE_MPI)
-# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER static_cast(::tim::dmp::rank())
-# elif defined(ROCPROFSYS_USE_MPI_HEADERS)
-# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER \
- (::tim::dmp::is_initialized()) ? static_cast(::tim::dmp::rank()) \
- : static_cast(::tim::process::get_id())
-# else
-# define ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER \
- static_cast(::tim::process::get_id())
-# endif
-#endif
-
-#if !defined(ROCPROFSYS_DEBUG_THREAD_IDENTIFIER)
-# define ROCPROFSYS_DEBUG_THREAD_IDENTIFIER ::rocprofsys::debug::get_tid()
-#endif
-
-#if !defined(ROCPROFSYS_SOURCE_LOCATION)
-# define ROCPROFSYS_SOURCE_LOCATION \
- ::rocprofsys::debug::source_location { __PRETTY_FUNCTION__, __FILE__, __LINE__ }
-#endif
-
-#if !defined(ROCPROFSYS_RECORD_SOURCE_LOCATION)
-# define ROCPROFSYS_RECORD_SOURCE_LOCATION \
- ::rocprofsys::debug::set_source_location(ROCPROFSYS_SOURCE_LOCATION)
-#endif
-
-#if defined(__clang__) || (__GNUC__ < 9)
-# define ROCPROFSYS_FUNCTION \
- std::string{ __FUNCTION__ } \
- .substr(0, std::string_view{ __FUNCTION__ }.find("_hidden")) \
- .c_str()
-# define ROCPROFSYS_PRETTY_FUNCTION \
- std::string{ __PRETTY_FUNCTION__ } \
- .substr(0, std::string_view{ __PRETTY_FUNCTION__ }.find("_hidden")) \
- .c_str()
-#else
-# define ROCPROFSYS_FUNCTION \
- ::rocprofsys::debug::get_chars( \
- std::string_view{ __FUNCTION__ }, \
- std::make_index_sequence{}) \
- .data()
-# define ROCPROFSYS_PRETTY_FUNCTION \
- ::rocprofsys::debug::get_chars( \
- std::string_view{ __PRETTY_FUNCTION__ }, \
- std::make_index_sequence{}) \
- .data()
-#endif
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR) \
- fprintf(::rocprofsys::debug::get_file(), "%s", ::tim::log::color::COLOR())
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_PRINT_COLOR(COLOR, COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_PRINT_COLOR_F(COLOR, COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(COLOR); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_PRINT_COLOR(COLOR, ...) \
- ROCPROFSYS_CONDITIONAL_PRINT_COLOR(COLOR, true, __VA_ARGS__)
-
-#define ROCPROFSYS_PRINT_COLOR_F(COLOR, ...) \
- ROCPROFSYS_CONDITIONAL_PRINT_COLOR_F(COLOR, true, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_PRINT(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_PRINT(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_PRINT_F(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(info); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_WARN(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_WARN(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_WARN_F(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_WARN_F(COND, ...) \
- if(ROCPROFSYS_UNLIKELY((COND) && ::rocprofsys::config::get_debug_tid() && \
- ::rocprofsys::config::get_debug_pid())) \
- { \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::debug::lock _debug_lk{}; \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(warning); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- }
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_THROW_E(COND, TYPE, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- char _msg_buffer[ROCPROFSYS_DEBUG_BUFFER_LEN]; \
- bool _print_backtrace = ::rocprofsys::get_debug() || \
- ::rocprofsys::get_verbose() >= 2 || \
- ::rocprofsys::get_is_continuous_integration(); \
- snprintf(_msg_buffer, ROCPROFSYS_DEBUG_BUFFER_LEN, \
- "[rocprof-sys][%i][%li][%s]%s", ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \
- ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- auto len = strlen(_msg_buffer); \
- snprintf(_msg_buffer + len, ROCPROFSYS_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \
- if(!_print_backtrace) \
- throw ::rocprofsys::exception( \
- ::tim::log::string(::tim::log::color::fatal(), _msg_buffer), false); \
- else \
- throw ::rocprofsys::exception( \
- ::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_THROW_E(COND, TYPE, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- char _msg_buffer[ROCPROFSYS_DEBUG_BUFFER_LEN]; \
- snprintf(_msg_buffer, ROCPROFSYS_DEBUG_BUFFER_LEN, "[rocprof-sys][%i][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- auto len = strlen(_msg_buffer); \
- snprintf(_msg_buffer + len, ROCPROFSYS_DEBUG_BUFFER_LEN - len, __VA_ARGS__); \
- throw ::rocprofsys::exception( \
- ::tim::log::string(::tim::log::color::fatal(), _msg_buffer)); \
- }
-
-#define ROCPROFSYS_CI_THROW_E(COND, TYPE, ...) \
- ROCPROFSYS_CONDITIONAL_THROW_E( \
- ::rocprofsys::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__)
-
-#define ROCPROFSYS_CI_BASIC_THROW_E(COND, TYPE, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_THROW_E( \
- ::rocprofsys::get_is_continuous_integration() && (COND), TYPE, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_THROW(COND, ...) \
- ROCPROFSYS_CONDITIONAL_THROW_E((COND), std::runtime_error, __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_THROW(COND, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__)
-
-#define ROCPROFSYS_CI_THROW(COND, ...) \
- ROCPROFSYS_CI_THROW_E((COND), std::runtime_error, __VA_ARGS__)
-
-#define ROCPROFSYS_CI_BASIC_THROW(COND, ...) \
- ROCPROFSYS_CI_BASIC_THROW_E((COND), std::runtime_error, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_FAILURE(COND, METHOD, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- ::rocprofsys::debug::flush(); \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::set_state(::rocprofsys::State::Finalized); \
- timemory_print_demangled_backtrace<64>(); \
- METHOD; \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_FAILURE(COND, METHOD, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- ::rocprofsys::debug::flush(); \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::set_state(::rocprofsys::State::Finalized); \
- timemory_print_demangled_backtrace<64>(); \
- METHOD; \
- }
-
-#define ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, METHOD, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- ::rocprofsys::debug::flush(); \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%li][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_DEBUG_THREAD_IDENTIFIER, \
- ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::set_state(::rocprofsys::State::Finalized); \
- timemory_print_demangled_backtrace<64>(); \
- METHOD; \
- }
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F(COND, METHOD, ...) \
- if(ROCPROFSYS_UNLIKELY((COND))) \
- { \
- ::rocprofsys::debug::flush(); \
- ROCPROFSYS_FPRINTF_STDERR_COLOR(fatal); \
- fprintf(::rocprofsys::debug::get_file(), "[rocprof-sys][%i][%s]%s", \
- ROCPROFSYS_DEBUG_PROCESS_IDENTIFIER, ROCPROFSYS_FUNCTION, \
- ::rocprofsys::debug::is_bracket(__VA_ARGS__) ? "" : " "); \
- fprintf(::rocprofsys::debug::get_file(), __VA_ARGS__); \
- ::rocprofsys::debug::flush(); \
- ::rocprofsys::set_state(::rocprofsys::State::Finalized); \
- timemory_print_demangled_backtrace<64>(); \
- METHOD; \
- }
-
-#define ROCPROFSYS_CI_FAILURE(COND, METHOD, ...) \
- ROCPROFSYS_CONDITIONAL_FAILURE( \
- ::rocprofsys::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__)
-
-#define ROCPROFSYS_CI_BASIC_FAILURE(COND, METHOD, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAILURE( \
- ::rocprofsys::get_is_continuous_integration() && (COND), METHOD, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_FAIL(COND, ...) \
- ROCPROFSYS_CONDITIONAL_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_FAIL(COND, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAILURE( \
- COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_FAIL_F(COND, ...) \
- ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_FAIL_F(COND, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F( \
- COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__)
-
-#define ROCPROFSYS_CI_FAIL(COND, ...) \
- ROCPROFSYS_CI_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), __VA_ARGS__)
-
-#define ROCPROFSYS_CI_BASIC_FAIL(COND, ...) \
- ROCPROFSYS_CI_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::exit(EXIT_FAILURE)), \
- __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_CONDITIONAL_ABORT(COND, ...) \
- ROCPROFSYS_CONDITIONAL_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_ABORT(COND, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_ABORT_F(COND, ...) \
- ROCPROFSYS_CONDITIONAL_FAILURE_F(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__)
-
-#define ROCPROFSYS_CONDITIONAL_BASIC_ABORT_F(COND, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAILURE_F(COND, ROCPROFSYS_ESC(::std::abort()), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_CI_ABORT(COND, ...) \
- ROCPROFSYS_CI_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__)
-
-#define ROCPROFSYS_CI_BASIC_ABORT(COND, ...) \
- ROCPROFSYS_CI_BASIC_FAILURE(COND, ROCPROFSYS_ESC(::std::abort()), __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Debug macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_DEBUG(...) \
- ROCPROFSYS_CONDITIONAL_PRINT(::rocprofsys::get_debug(), __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_DEBUG(...) \
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT(::rocprofsys::get_debug_env(), __VA_ARGS__)
-
-#define ROCPROFSYS_DEBUG_F(...) \
- ROCPROFSYS_CONDITIONAL_PRINT_F(::rocprofsys::get_debug(), __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_DEBUG_F(...) \
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(::rocprofsys::get_debug_env(), __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Verbose macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_VERBOSE(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_PRINT(::rocprofsys::get_debug() || \
- (::rocprofsys::get_verbose() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_VERBOSE(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT(::rocprofsys::get_debug_env() || \
- (::rocprofsys::get_verbose_env() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_VERBOSE_F(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_PRINT_F(::rocprofsys::get_debug() || \
- (::rocprofsys::get_verbose() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_VERBOSE_F(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(::rocprofsys::get_debug_env() || \
- (::rocprofsys::get_verbose_env() >= LEVEL), \
- __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Warning macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_WARNING(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_WARN(::rocprofsys::get_debug() || \
- (::rocprofsys::get_verbose() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_WARNING(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_WARN(::rocprofsys::get_debug_env() || \
- (::rocprofsys::get_verbose_env() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_WARNING_F(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_WARN_F(::rocprofsys::get_debug() || \
- (::rocprofsys::get_verbose() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_WARNING_F(LEVEL, ...) \
- ROCPROFSYS_CONDITIONAL_BASIC_WARN_F(::rocprofsys::get_debug_env() || \
- (::rocprofsys::get_verbose_env() >= LEVEL), \
- __VA_ARGS__)
-
-#define ROCPROFSYS_WARNING_IF(COND, ...) ROCPROFSYS_CONDITIONAL_WARN((COND), __VA_ARGS__)
-
-#define ROCPROFSYS_WARNING_IF_F(COND, ...) \
- ROCPROFSYS_CONDITIONAL_WARN_F((COND), __VA_ARGS__)
-
-#define ROCPROFSYS_WARNING_OR_CI_THROW(LEVEL, ...) \
- { \
- if(ROCPROFSYS_UNLIKELY(::rocprofsys::get_is_continuous_integration())) \
- { \
- ROCPROFSYS_CI_THROW(true, __VA_ARGS__); \
- } \
- else \
- { \
- ROCPROFSYS_CONDITIONAL_WARN(::rocprofsys::get_debug() || \
- (::rocprofsys::get_verbose() >= LEVEL), \
- __VA_ARGS__) \
- } \
- }
-
-#define ROCPROFSYS_REQUIRE(...) TIMEMORY_REQUIRE(__VA_ARGS__)
-#define ROCPROFSYS_PREFER(COND) \
- ((ROCPROFSYS_LIKELY(COND)) \
- ? ::tim::log::base() \
- : ((::rocprofsys::get_is_continuous_integration()) ? TIMEMORY_FATAL \
- : TIMEMORY_WARNING))
-
-//--------------------------------------------------------------------------------------//
-//
-// Basic print macros (basic means it will not provide PID/RANK or TID) and will not
-// initialize the settings.
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_BASIC_PRINT(...) ROCPROFSYS_CONDITIONAL_BASIC_PRINT(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_PRINT_F(...) \
- ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(true, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Print macros. Will provide PID/RANK and TID (will initialize settings)
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_PRINT(...) ROCPROFSYS_CONDITIONAL_PRINT(true, __VA_ARGS__)
-
-#define ROCPROFSYS_PRINT_F(...) ROCPROFSYS_CONDITIONAL_PRINT_F(true, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Throw macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_THROW(...) ROCPROFSYS_CONDITIONAL_THROW(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_THROW(...) ROCPROFSYS_CONDITIONAL_BASIC_THROW(true, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Fail macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_FAIL(...) ROCPROFSYS_CONDITIONAL_FAIL(true, __VA_ARGS__)
-
-#define ROCPROFSYS_FAIL_F(...) ROCPROFSYS_CONDITIONAL_FAIL_F(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_FAIL(...) ROCPROFSYS_CONDITIONAL_BASIC_FAIL(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_FAIL_F(...) \
- ROCPROFSYS_CONDITIONAL_BASIC_FAIL_F(true, __VA_ARGS__)
-
-//--------------------------------------------------------------------------------------//
-//
-// Abort macros
-//
-//--------------------------------------------------------------------------------------//
-
-#define ROCPROFSYS_ABORT(...) ROCPROFSYS_CONDITIONAL_ABORT(true, __VA_ARGS__)
-
-#define ROCPROFSYS_ABORT_F(...) ROCPROFSYS_CONDITIONAL_ABORT_F(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_ABORT(...) ROCPROFSYS_CONDITIONAL_BASIC_ABORT(true, __VA_ARGS__)
-
-#define ROCPROFSYS_BASIC_ABORT_F(...) \
- ROCPROFSYS_CONDITIONAL_BASIC_ABORT_F(true, __VA_ARGS__)
-
-#include
-
-namespace std
-{
-inline std::string
-to_string(bool _v)
-{
- return (_v) ? "true" : "false";
-}
-} // namespace std
diff --git a/projects/rocprofiler-systems/source/lib/core/dynamic_library.cpp b/projects/rocprofiler-systems/source/lib/core/dynamic_library.cpp
index d672cb62c0..29393b9ac7 100644
--- a/projects/rocprofiler-systems/source/lib/core/dynamic_library.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/dynamic_library.cpp
@@ -22,14 +22,14 @@
#include "dynamic_library.hpp"
#include "common.hpp"
-#include "debug.hpp"
-#include "defines.hpp"
#include
#include
#include
#include
+#include "logger/debug.hpp"
+
#include
#include
@@ -100,19 +100,15 @@ dynamic_library::dynamic_library(std::string _env, std::string _fname, int _flag
}
else if(_env_val.find('/') == 0)
{
- ROCPROFSYS_VERBOSE_F(
- 1,
- "Ignoring environment variable %s=\"%s\" because the "
- "filepath does not exist. Using \"%s\" instead...\n",
- envname.c_str(), _env_val.c_str(), filename.c_str())
+ LOG_WARNING("Ignoring environment variable {}=\"{}\" because the "
+ "filepath does not exist. Using \"{}\" instead...",
+ envname, _env_val, filename);
}
else if(_env_val.find('/') != 0 && filename.find('/') == 0)
{
- ROCPROFSYS_VERBOSE_F(
- 1,
- "Ignoring environment variable %s=\"%s\" because the "
- "filepath is relative. Using absolute path \"%s\" instead...\n",
- envname.c_str(), _env_val.c_str(), filename.c_str())
+ LOG_WARNING("Ignoring environment variable {}=\"{}\" because the "
+ "filepath is relative. Using absolute path \"{}\" instead...",
+ envname, _env_val, filename);
}
}
}
@@ -130,8 +126,8 @@ dynamic_library::open()
handle = dlopen(filename.c_str(), flags);
if(!handle)
{
- ROCPROFSYS_VERBOSE(2, "[dynamic_library] Error opening %s=\"%s\" :: %s.\n",
- envname.c_str(), filename.c_str(), dlerror());
+ LOG_WARNING("[dynamic_library] Error opening {}=\"{}\" :: {}.", envname,
+ filename, dlerror());
}
dlerror(); // Clear any existing error
}
diff --git a/projects/rocprofiler-systems/source/lib/core/dynamic_library.hpp b/projects/rocprofiler-systems/source/lib/core/dynamic_library.hpp
index 355db48835..e6152f476e 100644
--- a/projects/rocprofiler-systems/source/lib/core/dynamic_library.hpp
+++ b/projects/rocprofiler-systems/source/lib/core/dynamic_library.hpp
@@ -22,7 +22,7 @@
#pragma once
-#include "defines.hpp"
+#include "logger/debug.hpp"
#include
#include
@@ -77,8 +77,7 @@ dynamic_library::invoke(std::string_view _name, RetT (*&_func)(Args...), Args...
}
else
{
- fprintf(stderr, "[rocprof-sys][pid=%i]> %s :: %s\n", getpid(), _name.data(),
- dlerror());
+ LOG_WARNING("[rocprof-sys][pid={}]> {} :: {}", getpid(), _name, dlerror());
}
}
return RetT{};
diff --git a/projects/rocprofiler-systems/source/lib/core/gpu.cpp b/projects/rocprofiler-systems/source/lib/core/gpu.cpp
index 57c37f2dbf..fdfd70348d 100644
--- a/projects/rocprofiler-systems/source/lib/core/gpu.cpp
+++ b/projects/rocprofiler-systems/source/lib/core/gpu.cpp
@@ -35,7 +35,6 @@
# define ROCPROFSYS_USE_ROCM 0
#endif
-#include "debug.hpp"
#include "defines.hpp"
#include "gpu.hpp"
@@ -53,6 +52,8 @@
# include
#endif
+#include "logger/debug.hpp"
+
namespace rocprofsys
{
namespace gpu
@@ -70,12 +71,14 @@ check_amdsmi_error(amdsmi_status_t _code, const char* _file, int _line)
const char* _msg = nullptr;
auto _err = amdsmi_status_code_to_string(_code, &_msg);
if(_err != AMDSMI_STATUS_SUCCESS)
- ROCPROFSYS_THROW(
+ {
+ throw std::runtime_error(fmt::format(
"amdsmi_status_code_to_string failed. No error message available. "
- "Error code %i originated at %s:%i\n",
- static_cast(_code), _file, _line);
- ROCPROFSYS_THROW("[%s:%i] Error code %i :: %s", _file, _line, static_cast(_code),
- _msg);
+ "Error code {} originated at {}:{}",
+ static_cast(_code), _file, _line));
+ }
+ throw std::runtime_error(fmt::format("[{}:{}] Error code {} :: {}", _file, _line,
+ static_cast(_code), _msg));
}
// Ensures initialization happens only once
@@ -114,8 +117,7 @@ amdsmi_init()
prevent_amdsmi_library_unload();
} catch(std::exception& _e)
{
- ROCPROFSYS_BASIC_VERBOSE(1, "Exception thrown initializing amd-smi: %s\n",
- _e.what());
+ LOG_ERROR("Exception thrown initializing amd-smi: {}", _e.what());
_amdsmi_is_initialized() = false; // Mark as not initialized
return false;
}
@@ -165,9 +167,8 @@ query_rocm_agents()
sizeof(rocprofiler_agent_v0_t), nullptr);
} catch(std::exception& _e)
{
- ROCPROFSYS_BASIC_VERBOSE(
- 1, "Exception thrown getting the rocm agents: %s. _dev_cnt=%ld\n", _e.what(),
- _dev_cnt);
+ LOG_ERROR("Exception thrown getting the rocm agents: {}. _dev_cnt={}", _e.what(),
+ _dev_cnt);
}
_dev_cnt = get_agent_manager_instance().get_gpu_agents_count();
#endif
@@ -230,8 +231,7 @@ add_device_metadata(ArchiveT& ar)
sizeof(rocprofiler_agent_v0_t), &_agents_vec);
} catch(std::exception& _e)
{
- ROCPROFSYS_BASIC_VERBOSE(1, "Exception thrown getting the rocm agents: %s.\n",
- _e.what());
+ LOG_ERROR("Exception thrown getting the rocm agents: {}", _e.what());
}
ar(make_nvp("rocm_agents", _agents_vec));
@@ -251,7 +251,7 @@ add_device_metadata()
add_device_metadata(ar);
} catch(std::runtime_error& _e)
{
- ROCPROFSYS_VERBOSE(2, "%s\n", _e.what());
+ LOG_ERROR("Exception thrown adding device metadata: {}", _e.what());
}
});
}
@@ -309,8 +309,7 @@ get_processor_handles()
ret = amdsmi_get_processor_type(processor, &processor_type);
if(processor_type != AMDSMI_PROCESSOR_TYPE_AMD_GPU)
{
- ROCPROFSYS_THROW("Not AMD_GPU device type!");
- return;
+ throw std::runtime_error("Not AMD_GPU device type!");
}
processors::processors_list.push_back(processor);
diff --git a/projects/rocprofiler-systems/source/lib/core/mpi.hpp b/projects/rocprofiler-systems/source/lib/core/mpi.hpp
index ad7864938f..84bad4a224 100644
--- a/projects/rocprofiler-systems/source/lib/core/mpi.hpp
+++ b/projects/rocprofiler-systems/source/lib/core/mpi.hpp
@@ -27,12 +27,13 @@
#pragma once
-#include "debug.hpp"
#include
#include
#include
+#include "logger/debug.hpp"
+
#include
#include