Skip to content

Commit

Permalink
Fix rocprofiler usage in ROCm >= 5.5.x (#288)
Browse files Browse the repository at this point in the history
Fix rocprofiler usage in ROCm >= 5.5.x

- starting with ROCm 5.5.0, rocprofiler throws exception if OnLoad + dlopen librocprofiler
- CI skipped for this PR since CI does not support GPU usage (tested locally)
  • Loading branch information
jrmadsen committed Jun 16, 2023
1 parent de9f0e4 commit 2235368
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/lib/omnitrace/library/rocm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <atomic>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <mutex>
#include <tuple>

Expand Down Expand Up @@ -110,6 +111,8 @@ extern "C"
{
using ::rocprofiler::util::HsaRsrcFactory;

if(!config::get_use_rocprofiler() || config::get_rocm_events().empty()) return;

OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n");

rocm::lock_t _lk{ rocm::rocm_mutex, std::defer_lock };
Expand Down Expand Up @@ -153,6 +156,10 @@ extern "C"
tim::consume_parameters(table, runtime_version, failed_tool_count,
failed_tool_names);

static bool _once = false;
if(_once) return true;
_once = true;

OMNITRACE_BASIC_VERBOSE_F(2 || rocm::on_load_trace, "Loading...\n");
OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false);

Expand Down Expand Up @@ -194,6 +201,7 @@ extern "C"
(config::settings_are_configured() && config::get_rocm_events().empty());
if(_force_rocprofiler_init || (get_use_rocprofiler() && !_is_empty))
{
#if OMNITRACE_HIP_VERSION < 50500
auto _rocprof =
dynamic_library{ "OMNITRACE_ROCPROFILER_LIBRARY",
find_library_path("librocprofiler64.so",
Expand All @@ -219,6 +227,7 @@ extern "C"
"Warning! Invoking rocprofiler's OnLoad "
"failed! OMNITRACE_ROCPROFILER_LIBRARY=%s\n",
_rocprof.filename.c_str());
#endif
}
else
{
Expand Down

0 comments on commit 2235368

Please sign in to comment.