From 45e62ada3d09f8b8d3a54d39c2de08f6ff20b171 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Tue, 29 Jul 2025 20:23:16 -0500 Subject: [PATCH] Profiler - Add metrics location Signed-off-by: Galantsev, Dmitrii [ROCm/rdc commit: 0a19a7ffc1b589ee9ce56e53a34654656b381920] --- .../rdc_modules/rdc_rocp/RdcTelemetryLib.cc | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/rdc/rdc_libs/rdc_modules/rdc_rocp/RdcTelemetryLib.cc b/projects/rdc/rdc_libs/rdc_modules/rdc_rocp/RdcTelemetryLib.cc index 664637d894..d61436d59f 100644 --- a/projects/rdc/rdc_libs/rdc_modules/rdc_rocp/RdcTelemetryLib.cc +++ b/projects/rdc/rdc_libs/rdc_modules/rdc_rocp/RdcTelemetryLib.cc @@ -20,11 +20,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #include #include #include +#include #include #include #include @@ -64,6 +66,22 @@ rdc_status_t rdc_module_init(uint64_t /*flags*/) { // before the tests are. Utilize an env var instead. return RDC_ST_DISABLED_MODULE; } + + Dl_info dl_info = {}; + RDC_LOG(RDC_DEBUG, "Checking if rocprofiler is available"); + if (dladdr(reinterpret_cast(rdc_module_init), &dl_info) != 0) { + const std::filesystem::path rdc_path(dl_info.dli_fname); + const auto profiler_metrics_path = + rdc_path.parent_path().parent_path().parent_path() / "share/rocprofiler-sdk"; + const auto rocprofiler_exists = std::filesystem::exists(profiler_metrics_path); + if (!rocprofiler_exists) { + RDC_LOG(RDC_ERROR, "rocprofiler metrics are not available at " << profiler_metrics_path); + return RDC_ST_FAIL_LOAD_MODULE; + } + RDC_LOG(RDC_DEBUG, "rocprofiler metrics are available at " << profiler_metrics_path); + setenv("ROCPROFILER_METRICS_PATH", profiler_metrics_path.c_str(), 0); + } + rocp_p = std::make_unique(); return RDC_ST_OK; } @@ -98,7 +116,7 @@ rdc_status_t rdc_telemetry_fields_value_get(rdc_gpu_field_t* fields, const uint3 // Bulk fetch fields std::vector bulk_results; - struct timeval tv {}; + struct timeval tv{}; gettimeofday(&tv, nullptr); const uint64_t curTime = static_cast(tv.tv_sec) * 1000 + tv.tv_usec / 1000;