From 41be6ae55aa40f33cb2ab7b508c2340e254cf347 Mon Sep 17 00:00:00 2001 From: gobhardw Date: Tue, 13 Jun 2023 00:52:33 +0530 Subject: [PATCH] Fixing Logging for profiler v2 Change-Id: I7e52236c828f441e78631c5125692959eac7260b [ROCm/rocprofiler commit: bbc7bc1adaaccc9598d48d2ae2c13982ddc57ca9] --- projects/rocprofiler/README.md | 5 +++++ projects/rocprofiler/src/utils/logger.h | 6 +++--- .../tests-v2/featuretests/profiler/profiler_gtest.cpp | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/projects/rocprofiler/README.md b/projects/rocprofiler/README.md index 76895463c8..530aae1fe5 100644 --- a/projects/rocprofiler/README.md +++ b/projects/rocprofiler/README.md @@ -303,7 +303,12 @@ The user has two options for building: ```bash cd build && cmake --build . -- -j check ``` +## Logging +To enable error messages logging to '/tmp/rocprofiler_log.txt': + ```bash + $ export ROCPROFILER_LOG=1 + ``` ## Documentation We make use of doxygen to automatically generate API documentation. Generated document can be found in the following path: diff --git a/projects/rocprofiler/src/utils/logger.h b/projects/rocprofiler/src/utils/logger.h index b2d548831a..0bfe35d921 100644 --- a/projects/rocprofiler/src/utils/logger.h +++ b/projects/rocprofiler/src/utils/logger.h @@ -66,7 +66,7 @@ class Logger { static void endl() { Instance().ResetStreaming(false); } const std::string& LastMessage() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return message_[GetTid()]; } @@ -94,7 +94,7 @@ class Logger { } void ResetStreaming(const bool messaging) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (messaging) { message_[GetTid()] = ""; } else if (streaming_) { @@ -106,7 +106,7 @@ class Logger { } void Put(const std::string& m) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (messaging_) { message_[GetTid()] += m; } diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp index b229825d23..818e1e9b41 100644 --- a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp @@ -35,7 +35,7 @@ THE SOFTWARE. #include "src/utils/helper.h" #include "utils/test_utils.h" #include "utils/csv_parser.h" - +#include "src/utils/logger.h" std::string running_path; std::string lib_path; @@ -47,6 +47,7 @@ std::string profiler_api_lib_path = ""; static void init_test_path() { if (is_installed_path()) { + INFO_LOGGING("operating from /opt/rocm"); running_path = "share/rocprofiler/tests/runFeatureTests"; lib_path = "lib/rocprofiler/librocprofiler_tool.so"; golden_trace_path = "share/rocprofiler/tests/featuretests/profiler/apps/goldentraces/"; @@ -55,6 +56,7 @@ static void init_test_path() { binary_path = "bin/rocprofv2"; profiler_api_lib_path = "/lib"; } else { + INFO_LOGGING("operating from ./build/"); running_path = "tests-v2/featuretests/profiler/runFeatureTests"; lib_path = "librocprofiler_tool.so"; golden_trace_path = "tests-v2/featuretests/profiler/apps/goldentraces/";