diff --git a/projects/rocprofiler-systems/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp b/projects/rocprofiler-systems/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp index 06f20f445f..783f862593 100644 --- a/projects/rocprofiler-systems/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp +++ b/projects/rocprofiler-systems/source/lib/rocprof-sys/library/components/pthread_create_gotcha.cpp @@ -44,8 +44,10 @@ #include #include +#include #include #include +#include #include namespace rocprofsys @@ -540,11 +542,47 @@ pthread_create_gotcha::get_native_handles() return _v; } +namespace +{ +constexpr const char* rocm_internal_libraries[] = { "libhsa-runtime64", + "librocprofiler-sdk", "libamdhip64" }; + +bool +is_rocm_internal_thread(void* func_ptr) +{ + if(!func_ptr) return false; + + Dl_info info; + if(dladdr(func_ptr, &info) == 0 || info.dli_fname == nullptr) + { + ROCPROFSYS_VERBOSE(4, "dladdr failed or returned no filename for func_ptr=%p\n", + func_ptr); + return false; + } + + std::string_view lib_name{ info.dli_fname }; + + for(const auto* lib : rocm_internal_libraries) + { + if(lib_name.find(lib) != std::string_view::npos) return true; + } + + return false; +} +} // namespace + // pthread_create int pthread_create_gotcha::operator()(pthread_t* thread, const pthread_attr_t* attr, void* (*func)(void*), void* arg) const { + // Bypass wrapper for internal ROCm threads to avoid interfering with their event + // loops + if(is_rocm_internal_thread(reinterpret_cast(func))) + { + return (*m_wrappee)(thread, attr, func, arg); + } + auto _tid = utility::get_thread_index(); auto _thr_state = get_thread_state(); auto _glob_state = get_state(); diff --git a/projects/rocprofiler-systems/tests/rocpd-validation-rules/jpeg-decode/validation-rules.json b/projects/rocprofiler-systems/tests/rocpd-validation-rules/jpeg-decode/validation-rules.json index 0d339d5ab4..82ca822ca2 100644 --- a/projects/rocprofiler-systems/tests/rocpd-validation-rules/jpeg-decode/validation-rules.json +++ b/projects/rocprofiler-systems/tests/rocpd-validation-rules/jpeg-decode/validation-rules.json @@ -63,7 +63,7 @@ ] }, { - "min_rows": 3, + "min_rows": 2, "name": "threads", "required_columns": [ "tid", diff --git a/projects/rocprofiler-systems/tests/rocpd-validation-rules/roctx/validation-rules.json b/projects/rocprofiler-systems/tests/rocpd-validation-rules/roctx/validation-rules.json index ed9d13d580..9bdfaecd72 100644 --- a/projects/rocprofiler-systems/tests/rocpd-validation-rules/roctx/validation-rules.json +++ b/projects/rocprofiler-systems/tests/rocpd-validation-rules/roctx/validation-rules.json @@ -84,7 +84,7 @@ ] }, { - "min_rows": 3, + "min_rows": 2, "name": "threads", "required_columns": [ "tid", diff --git a/projects/rocprofiler-systems/tests/rocpd-validation-rules/transpose/validation-rules.json b/projects/rocprofiler-systems/tests/rocpd-validation-rules/transpose/validation-rules.json index 281957a281..1c24f8a107 100644 --- a/projects/rocprofiler-systems/tests/rocpd-validation-rules/transpose/validation-rules.json +++ b/projects/rocprofiler-systems/tests/rocpd-validation-rules/transpose/validation-rules.json @@ -84,7 +84,7 @@ ] }, { - "min_rows": 3, + "min_rows": 2, "name": "threads", "required_columns": [ "tid",