CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
108 lines
3.8 KiB
C++
108 lines
3.8 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include "common/environment.hpp"
|
|
#include "common/path.hpp"
|
|
#include <spdlog/fmt/fmt.h>
|
|
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <dlfcn.h>
|
|
#include <link.h>
|
|
#include <linux/limits.h>
|
|
#include <string>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
#if !defined(ROCPROFSYS_SETUP_LOG_NAME)
|
|
# if defined(ROCPROFSYS_COMMON_LIBRARY_NAME)
|
|
# define ROCPROFSYS_SETUP_LOG_NAME "[" ROCPROFSYS_COMMON_LIBRARY_NAME "]"
|
|
# else
|
|
# define ROCPROFSYS_SETUP_LOG_NAME
|
|
# endif
|
|
#endif
|
|
|
|
#if !defined(ROCPROFSYS_SETUP_LOG_START)
|
|
# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_START)
|
|
# define ROCPROFSYS_SETUP_LOG_START ROCPROFSYS_COMMON_LIBRARY_LOG_START
|
|
# elif defined(TIMEMORY_LOG_COLORS_AVAILABLE)
|
|
# define ROCPROFSYS_SETUP_LOG_START \
|
|
fprintf(stderr, "%s", ::tim::log::color::info());
|
|
# else
|
|
# define ROCPROFSYS_SETUP_LOG_START
|
|
# endif
|
|
#endif
|
|
|
|
#if !defined(ROCPROFSYS_SETUP_LOG_END)
|
|
# if defined(ROCPROFSYS_COMMON_LIBRARY_LOG_END)
|
|
# define ROCPROFSYS_SETUP_LOG_END ROCPROFSYS_COMMON_LIBRARY_LOG_END
|
|
# elif defined(TIMEMORY_LOG_COLORS_AVAILABLE)
|
|
# define ROCPROFSYS_SETUP_LOG_END fprintf(stderr, "%s", ::tim::log::color::end());
|
|
# else
|
|
# define ROCPROFSYS_SETUP_LOG_END
|
|
# endif
|
|
#endif
|
|
|
|
#define ROCPROFSYS_SETUP_LOG(CONDITION, ...) \
|
|
if(CONDITION) \
|
|
{ \
|
|
fflush(stderr); \
|
|
ROCPROFSYS_SETUP_LOG_START \
|
|
fprintf(stderr, "[rocprof-sys]" ROCPROFSYS_SETUP_LOG_NAME "[%i] ", getpid()); \
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
ROCPROFSYS_SETUP_LOG_END \
|
|
fflush(stderr); \
|
|
}
|
|
|
|
namespace rocprofsys
|
|
{
|
|
inline namespace common
|
|
{
|
|
inline std::vector<env_config<>>
|
|
get_environ(int _verbose, std::string _search_paths = {},
|
|
std::string _omnilib = "librocprof-sys.so",
|
|
std::string _omnilib_dl = "librocprof-sys-dl.so")
|
|
{
|
|
auto _data = std::vector<env_config<>>{};
|
|
auto _omnilib_path = path::get_origin(_omnilib);
|
|
auto _omnilib_dl_path = path::get_origin(_omnilib_dl);
|
|
|
|
if(!_omnilib_path.empty())
|
|
{
|
|
_omnilib = fmt::format("{}/{}", _omnilib_path, ::basename(_omnilib.c_str()));
|
|
_search_paths = fmt::format("{}:{}", _omnilib_path, _search_paths);
|
|
}
|
|
|
|
if(!_omnilib_dl_path.empty())
|
|
{
|
|
_omnilib_dl =
|
|
fmt::format("{}/{}", _omnilib_dl_path, ::basename(_omnilib_dl.c_str()));
|
|
_search_paths = fmt::format("{}:{}", _omnilib_dl_path, _search_paths);
|
|
}
|
|
|
|
if(_search_paths.find_first_not_of(':') == std::string::npos)
|
|
{
|
|
_search_paths = get_default_lib_search_paths();
|
|
}
|
|
|
|
_omnilib = common::path::find_path(_omnilib, _verbose, _search_paths);
|
|
_omnilib_dl = common::path::find_path(_omnilib_dl, _verbose, _search_paths);
|
|
|
|
return _data;
|
|
}
|
|
|
|
inline void
|
|
setup_environ(int _verbose, const std::string& _search_paths = {},
|
|
std::string _omnilib = "librocprof-sys.so",
|
|
std::string _omnilib_dl = "librocprof-sys-dl.so")
|
|
{
|
|
auto _data =
|
|
get_environ(_verbose, _search_paths, std::move(_omnilib), std::move(_omnilib_dl));
|
|
for(const auto& itr : _data)
|
|
itr();
|
|
}
|
|
} // namespace common
|
|
} // namespace rocprofsys
|