Unified setup_environ b/t libomni and libomni-dl (#86)
- omnitrace::common::setup_environ provides a standardized exporting of relevant env variables
[ROCm/rocprofiler-systems commit: a2dcc7381b]
Este commit está contenido en:
cometido por
GitHub
padre
9e4977baa8
commit
39adaaef98
@@ -43,6 +43,7 @@ function(ROCM_VERSION_PARSE_VERSION_FILES)
|
||||
|
||||
# the list of variables set by module. when one of these changes, we need to unset the
|
||||
# cache variables after it
|
||||
set(_ALL_VARIABLES)
|
||||
foreach(
|
||||
_V
|
||||
EPOCH
|
||||
|
||||
@@ -170,6 +170,9 @@ if(OMNITRACE_USE_HIP
|
||||
GREATER 3)
|
||||
set(roctracer_kfdwrapper_LIBRARY)
|
||||
endif()
|
||||
if(NOT roctracer_kfdwrapper_LIBRARY)
|
||||
set(roctracer_kfdwrapper_LIBRARY)
|
||||
endif()
|
||||
omnitrace_add_feature(OMNITRACE_ROCM_VERSION "ROCm version used by omnitrace")
|
||||
else()
|
||||
set(OMNITRACE_HIP_VERSION "0.0.0")
|
||||
|
||||
@@ -8,17 +8,25 @@ add_library(omnitrace-common-library INTERFACE)
|
||||
add_library(omnitrace::common-library ALIAS omnitrace-common-library)
|
||||
add_library(omnitrace::omnitrace-common-library ALIAS omnitrace-common-library)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/defines.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/defines.h @ONLY)
|
||||
|
||||
target_sources(
|
||||
omnitrace-common-library
|
||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/defines.h
|
||||
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/defines.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/delimit.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/environment.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/invoke.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/join.hpp)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/join.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/setup.hpp)
|
||||
|
||||
get_filename_component(COMMON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" DIRECTORY)
|
||||
get_filename_component(COMMON_SOURCE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" DIRECTORY)
|
||||
get_filename_component(COMMON_BINARY_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}" DIRECTORY)
|
||||
|
||||
target_include_directories(
|
||||
omnitrace-common-library
|
||||
INTERFACE $<BUILD_INTERFACE:${COMMON_SOURCE_INCLUDE_DIR}>
|
||||
INTERFACE $<BUILD_INTERFACE:${COMMON_BINARY_INCLUDE_DIR}>)
|
||||
|
||||
target_include_directories(omnitrace-common-library
|
||||
INTERFACE $<BUILD_INTERFACE:${COMMON_INCLUDE_DIR}>)
|
||||
target_compile_definitions(omnitrace-common-library
|
||||
INTERFACE $<BUILD_INTERFACE:OMNITRACE_INTERNAL_BUILD=1>)
|
||||
|
||||
+23
@@ -22,6 +22,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
#define OMNITRACE_VERSION_STRING "@FULL_VERSION_STRING@"
|
||||
#define OMNITRACE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define OMNITRACE_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define OMNITRACE_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define OMNITRACE_GIT_DESCRIBE "@OMNITRACE_GIT_DESCRIBE@"
|
||||
#define OMNITRACE_GIT_REVISION "@OMNITRACE_GIT_REVISION@"
|
||||
|
||||
#define OMNITRACE_DEFAULT_ROCM_PATH "@ROCmVersion_DIR@"
|
||||
#define OMNITRACE_HIP_VERSION_STRING "@OMNITRACE_HIP_VERSION@"
|
||||
#define OMNITRACE_HIP_VERSION_MAJOR @OMNITRACE_HIP_VERSION_MAJOR@
|
||||
#define OMNITRACE_HIP_VERSION_MINOR @OMNITRACE_HIP_VERSION_MINOR@
|
||||
#define OMNITRACE_HIP_VERSION_PATCH @OMNITRACE_HIP_VERSION_PATCH@
|
||||
// clang-format on
|
||||
|
||||
#define OMNITRACE_VERSION \
|
||||
((10000 * OMNITRACE_VERSION_MAJOR) + (100 * OMNITRACE_VERSION_MINOR) + \
|
||||
OMNITRACE_VERSION_PATCH)
|
||||
|
||||
#define OMNITRACE_HIP_VERSION \
|
||||
((10000 * OMNITRACE_HIP_VERSION_MAJOR) + (100 * OMNITRACE_HIP_VERSION_MINOR) + \
|
||||
OMNITRACE_HIP_VERSION_PATCH)
|
||||
|
||||
#define OMNITRACE_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
|
||||
#define OMNITRACE_VISIBILITY(MODE) OMNITRACE_ATTRIBUTE(visibility(MODE))
|
||||
#define OMNITRACE_PUBLIC_API OMNITRACE_VISIBILITY("default")
|
||||
@@ -34,28 +34,34 @@ inline namespace common
|
||||
namespace
|
||||
{
|
||||
inline std::string
|
||||
get_env(const char* env_id, const char* _default)
|
||||
get_env(std::string_view env_id, std::string_view _default)
|
||||
{
|
||||
if(strlen(env_id) == 0) return _default;
|
||||
char* env_var = ::std::getenv(env_id);
|
||||
if(env_id.empty()) return std::string{ _default };
|
||||
char* env_var = ::std::getenv(env_id.data());
|
||||
if(env_var) return std::string{ env_var };
|
||||
return _default;
|
||||
return std::string{ _default };
|
||||
}
|
||||
|
||||
inline std::string
|
||||
get_env(std::string_view env_id, const char* _default)
|
||||
{
|
||||
return get_env(env_id, std::string_view{ _default });
|
||||
}
|
||||
|
||||
inline int
|
||||
get_env(const char* env_id, int _default)
|
||||
get_env(std::string_view env_id, int _default)
|
||||
{
|
||||
if(strlen(env_id) == 0) return _default;
|
||||
char* env_var = ::std::getenv(env_id);
|
||||
if(env_id.empty()) return _default;
|
||||
char* env_var = ::std::getenv(env_id.data());
|
||||
if(env_var) return std::stoi(env_var);
|
||||
return _default;
|
||||
}
|
||||
|
||||
inline bool
|
||||
get_env(const char* env_id, bool _default)
|
||||
get_env(std::string_view env_id, bool _default)
|
||||
{
|
||||
if(strlen(env_id) == 0) return _default;
|
||||
char* env_var = ::std::getenv(env_id);
|
||||
if(env_id.empty()) return _default;
|
||||
char* env_var = ::std::getenv(env_id.data());
|
||||
if(env_var)
|
||||
{
|
||||
if(std::string_view{ env_var }.find_first_not_of("0123456789") ==
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/defines.h"
|
||||
#include "common/delimit.hpp"
|
||||
#include "common/environment.hpp"
|
||||
#include "common/join.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !defined(OMNITRACE_SETUP_LOG_NAME)
|
||||
# if defined(OMNITRACE_COMMON_LIBRARY_NAME)
|
||||
# define OMNITRACE_SETUP_LOG_NAME "[" OMNITRACE_COMMON_LIBRARY_NAME "]"
|
||||
# else
|
||||
# define OMNITRACE_SETUP_LOG_NAME
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define OMNITRACE_SETUP_LOG(CONDITION, ...) \
|
||||
if(CONDITION) \
|
||||
{ \
|
||||
fflush(stderr); \
|
||||
fprintf(stderr, "[omnitrace]" OMNITRACE_SETUP_LOG_NAME "[%i] ", getpid()); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
}
|
||||
|
||||
namespace omnitrace
|
||||
{
|
||||
inline namespace common
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
inline std::string
|
||||
find_path(const std::string& _path, int _verbose, std::string _search_paths = {})
|
||||
{
|
||||
auto _exists = [](std::string_view _name) {
|
||||
struct stat _buffer;
|
||||
if(stat(_name.data(), &_buffer) == 0)
|
||||
return (S_ISREG(_buffer.st_mode) != 0 || S_ISLNK(_buffer.st_mode) != 0);
|
||||
return false;
|
||||
};
|
||||
|
||||
if(_exists(_path) && !_path.empty() && _path.at(0) == '/') return _path;
|
||||
|
||||
auto _default_search_paths =
|
||||
join(":", get_env("OMNITRACE_PATH", ""), get_env("PWD", ""), ".",
|
||||
get_env("LD_LIBRARY_PATH", ""), get_env("LIBRARY_PATH", ""));
|
||||
|
||||
if(_search_paths.empty()) _search_paths = _default_search_paths;
|
||||
|
||||
auto _paths = delimit(_search_paths, ":");
|
||||
|
||||
if(_paths.empty())
|
||||
{
|
||||
_search_paths = _default_search_paths;
|
||||
_paths = delimit(_search_paths, ":");
|
||||
}
|
||||
|
||||
int _verbose_lvl = 2;
|
||||
for(const auto& itr : _paths)
|
||||
{
|
||||
auto _f = join('/', itr, _path);
|
||||
OMNITRACE_SETUP_LOG(_verbose >= _verbose_lvl, "searching for '%s' in '%s' ...\n",
|
||||
_path.c_str(), itr.c_str());
|
||||
if(_exists(_f)) return _f;
|
||||
for(const auto* sitr : { "lib", "lib64", "../lib", "../lib64" })
|
||||
{
|
||||
_f = join('/', itr, sitr, _path);
|
||||
OMNITRACE_SETUP_LOG(_verbose >= _verbose_lvl,
|
||||
"searching for '%s' in '%s' ...\n", _path.c_str(),
|
||||
common::join('/', itr, sitr).c_str());
|
||||
if(_exists(_f)) return _f;
|
||||
}
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
|
||||
inline std::string
|
||||
dirname(const std::string& _fname)
|
||||
{
|
||||
if(_fname.find('/') != std::string::npos)
|
||||
return _fname.substr(0, _fname.find_last_of('/'));
|
||||
return std::string{};
|
||||
}
|
||||
} // namespace utility
|
||||
|
||||
void
|
||||
setup_environ(int _verbose, const std::string& _search_paths = {},
|
||||
std::string _omnilib = "libomnitrace.so",
|
||||
std::string _omnilib_dl = "libomnitrace-dl.so")
|
||||
{
|
||||
_omnilib = utility::find_path(_omnilib, _verbose, _search_paths);
|
||||
_omnilib_dl = utility::find_path(_omnilib_dl, _verbose, _search_paths);
|
||||
|
||||
// This environment variable forces the ROCR-Runtime to use polling to wait
|
||||
// for signals rather than interrupts. We set this variable to avoid issues with
|
||||
// rocm/roctracer hanging when interrupted by the sampler
|
||||
//
|
||||
// see:
|
||||
// https://github.com/ROCm-Developer-Tools/roctracer/issues/22#issuecomment-572814465
|
||||
setenv("HSA_ENABLE_INTERRUPT", "0", 0);
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0
|
||||
setenv("HSA_TOOLS_LIB", _omnilib.c_str(), 0);
|
||||
#endif
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0
|
||||
setenv("HSA_TOOLS_LIB", _omnilib.c_str(), 0);
|
||||
setenv("ROCP_TOOL_LIB", _omnilib.c_str(), 0);
|
||||
setenv("ROCPROFILER_LOG", "1", 0);
|
||||
setenv("ROCP_HSA_INTERCEPT", "1", 0);
|
||||
setenv("HSA_TOOLS_REPORT_LOAD_FAILURE", "1", 0);
|
||||
for(const auto* itr : { "OMNITRACE_ROCM_PATH", "ROCM_PATH" })
|
||||
{
|
||||
if(getenv(itr))
|
||||
{
|
||||
setenv("ROCP_METRICS",
|
||||
common::join('/', getenv(itr), "rocprofiler/lib/metrics.xml").c_str(),
|
||||
0);
|
||||
setenv("OMNITRACE_ROCPROFILER_LIBRARY",
|
||||
common::join('/', getenv(itr), "rocprofiler/lib/librocprofiler64.so")
|
||||
.c_str(),
|
||||
0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// default path
|
||||
setenv("ROCP_METRICS",
|
||||
common::join('/', OMNITRACE_DEFAULT_ROCM_PATH, "rocprofiler/lib/metrics.xml")
|
||||
.c_str(),
|
||||
0);
|
||||
#endif
|
||||
|
||||
#if defined(OMNITRACE_USE_OMPT) && OMNITRACE_USE_OMPT > 0
|
||||
std::string _omni_omp_libs = _omnilib_dl;
|
||||
const char* _omp_libs = getenv("OMP_TOOL_LIBRARIES");
|
||||
if(_omp_libs && std::string_view{ _omp_libs }.find(_omnilib_dl) == std::string::npos)
|
||||
_omni_omp_libs = common::join(':', _omp_libs, _omnilib_dl);
|
||||
OMNITRACE_SETUP_LOG(_verbose >= 1, "setting OMP_TOOL_LIBRARIES to '%s'\n",
|
||||
_omni_omp_libs.c_str());
|
||||
setenv("OMP_TOOL_LIBRARIES", _omni_omp_libs.c_str(), 1);
|
||||
#endif
|
||||
|
||||
(void) _omnilib;
|
||||
(void) _omnilib_dl;
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace omnitrace
|
||||
@@ -19,6 +19,7 @@ target_include_directories(
|
||||
omnitrace-dl-library
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../omnitrace-user>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../omnitrace>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
target_link_libraries(
|
||||
omnitrace-dl-library
|
||||
|
||||
@@ -27,10 +27,12 @@
|
||||
#define OMNITRACE_COMMON_LIBRARY_NAME "dl"
|
||||
|
||||
#include "dl.hpp"
|
||||
#include "common/defines.h"
|
||||
#include "common/delimit.hpp"
|
||||
#include "common/environment.hpp"
|
||||
#include "common/invoke.hpp"
|
||||
#include "common/join.hpp"
|
||||
#include "common/setup.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <gnu/libc-version.h>
|
||||
@@ -136,61 +138,26 @@ const char* _omnitrace_dl_dlopen_descr = "RTLD_LAZY | RTLD_LOCAL";
|
||||
/// This class contains function pointers for omnitrace's instrumentation functions
|
||||
struct OMNITRACE_HIDDEN_API indirect
|
||||
{
|
||||
OMNITRACE_INLINE indirect(const std::string& omnilib, const std::string& userlib,
|
||||
const std::string& dllib)
|
||||
: m_omnilib{ find_path(omnilib) }
|
||||
, m_dllib{ find_path(dllib) }
|
||||
, m_userlib{ find_path(userlib) }
|
||||
OMNITRACE_INLINE indirect(const std::string& _omnilib, const std::string& _userlib,
|
||||
const std::string& _dllib)
|
||||
: m_omnilib{ utility::find_path(_omnilib, _omnitrace_dl_verbose) }
|
||||
, m_dllib{ utility::find_path(_dllib, _omnitrace_dl_verbose) }
|
||||
, m_userlib{ utility::find_path(_userlib, _omnitrace_dl_verbose) }
|
||||
{
|
||||
if(_omnitrace_dl_verbose >= 1)
|
||||
{
|
||||
fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(),
|
||||
::basename(omnilib.c_str()), m_omnilib.c_str());
|
||||
::basename(_omnilib.c_str()), m_omnilib.c_str());
|
||||
fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(),
|
||||
::basename(dllib.c_str()), m_dllib.c_str());
|
||||
::basename(_dllib.c_str()), m_dllib.c_str());
|
||||
fprintf(stderr, "[omnitrace][dl][pid=%i] %s resolved to '%s'\n", getpid(),
|
||||
::basename(userlib.c_str()), m_userlib.c_str());
|
||||
::basename(_userlib.c_str()), m_userlib.c_str());
|
||||
}
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0
|
||||
auto _omni_hsa_lib = m_omnilib;
|
||||
setenv("HSA_TOOLS_LIB", _omni_hsa_lib.c_str(), 0);
|
||||
#endif
|
||||
auto _search_paths =
|
||||
common::join(':', utility::dirname(_omnilib), utility::dirname(_dllib));
|
||||
common::setup_environ(_omnitrace_dl_verbose, _search_paths, _omnilib, _dllib);
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0
|
||||
auto _rocm_path = get_env("ROCM_PATH", "/opt/rocm");
|
||||
auto _rocp_metrics = common::join('/', _rocm_path, "rocprofiler/lib/metrics.xml");
|
||||
setenv("HSA_TOOLS_LIB", m_omnilib.c_str(), 0);
|
||||
setenv("ROCP_TOOL_LIB", m_omnilib.c_str(), 0);
|
||||
setenv("ROCPROFILER_LOG", "1", 0);
|
||||
setenv("ROCP_HSA_INTERCEPT", "1", 0);
|
||||
setenv("ROCP_METRICS", _rocp_metrics.c_str(), 0);
|
||||
setenv("HSA_TOOLS_REPORT_LOAD_FAILURE", "1", 0);
|
||||
if(getenv("ROCM_PATH"))
|
||||
{
|
||||
setenv("OMNITRACE_ROCPROFILER_LIBRARY",
|
||||
common::join('/', getenv("ROCM_PATH"),
|
||||
"rocprofiler/lib/librocprofiler64.so")
|
||||
.c_str(),
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OMNITRACE_USE_OMPT > 0
|
||||
if(get_env("OMNITRACE_USE_OMPT", true))
|
||||
{
|
||||
std::string _omni_omp_libs = m_dllib;
|
||||
const char* _omp_libs = getenv("OMP_TOOL_LIBRARIES");
|
||||
if(_omp_libs) _omni_omp_libs = common::join(':', _omni_omp_libs, _omp_libs);
|
||||
if(_omnitrace_dl_verbose >= 1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"[omnitrace][dl][pid=%i] setting OMP_TOOL_LIBRARIES to '%s'\n",
|
||||
getpid(), _omni_omp_libs.c_str());
|
||||
}
|
||||
setenv("OMP_TOOL_LIBRARIES", _omni_omp_libs.c_str(), 1);
|
||||
}
|
||||
#endif
|
||||
m_omnihandle = open(m_omnilib);
|
||||
m_userhandle = open(m_userlib);
|
||||
init();
|
||||
@@ -325,34 +292,6 @@ struct OMNITRACE_HIDDEN_API indirect
|
||||
}
|
||||
}
|
||||
|
||||
static OMNITRACE_INLINE std::string find_path(const std::string& _path)
|
||||
{
|
||||
auto _paths_search =
|
||||
join(":", get_env("OMNITRACE_PATH", ""), get_env("LD_LIBRARY_PATH", ""),
|
||||
get_env("LIBRARY_PATH", ""));
|
||||
|
||||
auto _paths = delimit(_paths_search, ":");
|
||||
|
||||
auto file_exists = [](const std::string& name) {
|
||||
struct stat buffer;
|
||||
return (stat(name.c_str(), &buffer) == 0);
|
||||
};
|
||||
|
||||
int _verbose_lvl = 2;
|
||||
for(const auto& itr : _paths)
|
||||
{
|
||||
auto _f = join('/', itr, _path);
|
||||
if(_omnitrace_dl_verbose >= _verbose_lvl)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"[omnitrace][dl][pid=%i] searching for '%s' in '%s' ...\n",
|
||||
getpid(), _path.c_str(), itr.c_str());
|
||||
}
|
||||
if(file_exists(_f)) return _f;
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
|
||||
public:
|
||||
// omnitrace functions
|
||||
void (*omnitrace_init_library_f)(void) = nullptr;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "library.hpp"
|
||||
#include "common/setup.hpp"
|
||||
#include "library/api.hpp"
|
||||
#include "library/components/fork_gotcha.hpp"
|
||||
#include "library/components/functors.hpp"
|
||||
@@ -84,38 +85,16 @@ ensure_finalization(bool _static_init = false)
|
||||
else
|
||||
{
|
||||
OMNITRACE_BASIC_DEBUG_F("\n");
|
||||
// This environment variable forces the ROCR-Runtime to use polling to wait
|
||||
// for signals rather than interrupts. We set this variable to avoid issues with
|
||||
// rocm/roctracer hanging when interrupted by the sampler
|
||||
//
|
||||
// see:
|
||||
// https://github.com/ROCm-Developer-Tools/roctracer/issues/22#issuecomment-572814465
|
||||
tim::set_env("HSA_ENABLE_INTERRUPT", "0", 0);
|
||||
#if defined(OMNITRACE_USE_ROCTRACER) && OMNITRACE_USE_ROCTRACER > 0
|
||||
tim::set_env("HSA_TOOLS_LIB", "libomnitrace.so", 0);
|
||||
#endif
|
||||
#if defined(OMNITRACE_USE_ROCPROFILER) && OMNITRACE_USE_ROCPROFILER > 0
|
||||
auto _default_rocm_path =
|
||||
JOIN("", "/opt/rocm-", OMNITRACE_HIP_VERSION_MAJOR, '.',
|
||||
OMNITRACE_HIP_VERSION_MINOR, '.', OMNITRACE_HIP_VERSION_PATCH);
|
||||
auto _rocm_path = tim::get_env("OMNITRACE_ROCM_PATH",
|
||||
tim::get_env("ROCM_PATH", _default_rocm_path));
|
||||
auto _rocp_metrics = JOIN('/', _rocm_path, "rocprofiler/lib/metrics.xml");
|
||||
tim::set_env("HSA_TOOLS_LIB", "libomnitrace.so", 0);
|
||||
tim::set_env("ROCP_TOOL_LIB", "libomnitrace.so", 0);
|
||||
tim::set_env("ROCPROFILER_LOG", "1", 0);
|
||||
tim::set_env("ROCP_HSA_INTERCEPT", "1", 0);
|
||||
tim::set_env("ROCP_METRICS", _rocp_metrics, 0);
|
||||
tim::set_env("HSA_TOOLS_REPORT_LOAD_FAILURE", "1", 0);
|
||||
if(getenv("ROCM_PATH"))
|
||||
{
|
||||
tim::set_env("OMNITRACE_ROCPROFILER_LIBRARY",
|
||||
JOIN('/', tim::get_env<std::string>("ROCM_PATH"),
|
||||
"rocprofiler/lib/librocprofiler64.so"),
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
auto _verbose = get_verbose_env() + ((get_debug_env() || get_debug_init()) ? 16 : 0);
|
||||
auto _search_paths = JOIN(':', tim::get_env<std::string>("OMNITRACE_PATH", ""),
|
||||
tim::get_env<std::string>("PWD"), ".",
|
||||
tim::get_env<std::string>("LD_LIBRARY_PATH", ""),
|
||||
tim::get_env<std::string>("LIBRARY_PATH", ""),
|
||||
tim::get_env<std::string>("PATH", ""));
|
||||
common::setup_environ(_verbose, _search_paths);
|
||||
|
||||
return scope::destructor{ []() { omnitrace_finalize_hidden(); } };
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/defines.h"
|
||||
|
||||
// clang-format off
|
||||
#define OMNITRACE_VERSION_STRING "@FULL_VERSION_STRING@"
|
||||
#define OMNITRACE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define OMNITRACE_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define OMNITRACE_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define OMNITRACE_GIT_DESCRIBE "@OMNITRACE_GIT_DESCRIBE@"
|
||||
#define OMNITRACE_GIT_REVISION "@OMNITRACE_GIT_REVISION@"
|
||||
|
||||
#define OMNITRACE_HIP_VERSION_STRING "@OMNITRACE_HIP_VERSION@"
|
||||
#define OMNITRACE_HIP_VERSION_MAJOR @OMNITRACE_HIP_VERSION_MAJOR@
|
||||
#define OMNITRACE_HIP_VERSION_MINOR @OMNITRACE_HIP_VERSION_MINOR@
|
||||
#define OMNITRACE_HIP_VERSION_PATCH @OMNITRACE_HIP_VERSION_PATCH@
|
||||
|
||||
#if defined(OMNITRACE_USE_ROCTRACER)
|
||||
# define OMNITRACE_ROCTRACER_LIBKFDWRAPPER "@roctracer_kfdwrapper_LIBRARY@"
|
||||
#else
|
||||
@@ -42,14 +32,6 @@
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define OMNITRACE_VERSION \
|
||||
((10000 * OMNITRACE_VERSION_MAJOR) + (100 * OMNITRACE_VERSION_MINOR) + \
|
||||
OMNITRACE_VERSION_PATCH)
|
||||
|
||||
#define OMNITRACE_HIP_VERSION \
|
||||
((10000 * OMNITRACE_HIP_VERSION_MAJOR) + (100 * OMNITRACE_HIP_VERSION_MINOR) + \
|
||||
OMNITRACE_HIP_VERSION_PATCH)
|
||||
|
||||
#define TIMEMORY_USER_COMPONENT_ENUM \
|
||||
OMNITRACE_COMPONENT_idx, OMNITRACE_USER_REGION_idx, OMNITRACE_ROCTRACER_idx, \
|
||||
OMNITRACE_ROCPROFILER_idx, OMNITRACE_SAMPLING_WALL_CLOCK_idx, \
|
||||
@@ -68,5 +50,3 @@
|
||||
#define OMNITRACE_SAMPLING_GPU_TEMP OMNITRACE_SAMPLING_GPU_TEMP_idx
|
||||
#define OMNITRACE_SAMPLING_GPU_BUSY OMNITRACE_SAMPLING_GPU_BUSY_idx
|
||||
#define OMNITRACE_SAMPLING_GPU_MEMORY_USAGE OMNITRACE_SAMPLING_GPU_MEMORY_USAGE_idx
|
||||
|
||||
#include "common/defines.h"
|
||||
|
||||
Referencia en una nueva incidencia
Block a user