[Rocprof-Sys] Resolve crash when profiling TensorFlow GPU application (#2381)
* fix: resolve crash when profiling TensorFlow GPU application * incorporate review comments * updated min_rows from 3 to 2 for threads table validation as internal threads are not profiled and are now correctly bypassed
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1f8e8e3fbf
Коммит
447025011a
+38
@@ -44,8 +44,10 @@
|
||||
#include <timemory/utility/types.hpp>
|
||||
|
||||
#include <csignal>
|
||||
#include <dlfcn.h>
|
||||
#include <ostream>
|
||||
#include <pthread.h>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
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<void*>(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();
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"min_rows": 3,
|
||||
"min_rows": 2,
|
||||
"name": "threads",
|
||||
"required_columns": [
|
||||
"tid",
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"min_rows": 3,
|
||||
"min_rows": 2,
|
||||
"name": "threads",
|
||||
"required_columns": [
|
||||
"tid",
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"min_rows": 3,
|
||||
"min_rows": 2,
|
||||
"name": "threads",
|
||||
"required_columns": [
|
||||
"tid",
|
||||
|
||||
Ссылка в новой задаче
Block a user