[rocprofiler-sdk] rename librocprofv3-attach.so (#1342)
* attach: rename librocprofv3-attach - Renames library to librocprofiler-sdk-rocattach - ROCAttach library will be formalized and documented in future commit * Address review comments - Rename rocprofv3-attach.py to rocprof-attach.py - Use common filesystem.hpp in rocattach * Fix component name typo * Doc fixup --------- Co-authored-by: JeniferC99 <150404595+JeniferC99@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -59,7 +59,7 @@ class rocprofiler_sdk_profiler(RocProfCompute_Base):
|
||||
)
|
||||
rocm_dir = Path(args.rocprofiler_sdk_library_path).parent.parent
|
||||
rocprofiler_attach_tool_path = str(
|
||||
rocm_dir / "lib" / "rocprofiler-sdk" / "librocprofv3-attach.so"
|
||||
rocm_dir / "lib" / "librocprofiler-sdk-rocattach.so"
|
||||
)
|
||||
ld_preload = [
|
||||
rocprofiler_sdk_tool_path,
|
||||
|
||||
@@ -58,7 +58,8 @@ list(REMOVE_ITEM ROCPROFILER_PACKAGING_COMPONENTS "Development" "Unspecified")
|
||||
list(LENGTH ROCPROFILER_PACKAGING_COMPONENTS NUM_ROCPROFILER_PACKAGING_COMPONENTS)
|
||||
|
||||
# the packages we will generate
|
||||
set(ROCPROFILER_COMPONENT_GROUPS "core" "docs" "tests" "roctx" "rocpd" "benchmark")
|
||||
set(ROCPROFILER_COMPONENT_GROUPS "core" "docs" "tests" "roctx" "rocpd" "benchmark"
|
||||
"rocattach")
|
||||
|
||||
set(COMPONENT_GROUP_core_COMPONENTS "core" "development" "samples" "tools" "Development"
|
||||
"Unspecified")
|
||||
@@ -67,6 +68,7 @@ set(COMPONENT_GROUP_tests_COMPONENTS "tests")
|
||||
set(COMPONENT_GROUP_roctx_COMPONENTS "roctx")
|
||||
set(COMPONENT_GROUP_rocpd_COMPONENTS "rocpd")
|
||||
set(COMPONENT_GROUP_benchmark_COMPONENTS "benchmark")
|
||||
set(COMPONENT_GROUP_rocattach_COMPONENTS "rocattach")
|
||||
|
||||
# variables for each component group. Note: eventually we will probably want to separate
|
||||
# the core to just be the runtime libraries, development to be the headers and cmake
|
||||
@@ -78,17 +80,22 @@ set(COMPONENT_NAME_tests "rocprofiler-sdk-tests")
|
||||
set(COMPONENT_NAME_roctx "rocprofiler-sdk-roctx")
|
||||
set(COMPONENT_NAME_rocpd "rocprofiler-sdk-rocpd")
|
||||
set(COMPONENT_NAME_benchmark "rocprofiler-sdk-benchmark")
|
||||
set(COMPONENT_NAME_rocattach "rocprofiler-sdk-rocattach")
|
||||
|
||||
set(COMPONENT_DEP_core "rocprofiler-sdk-roctx (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-rocpd (>= ${PROJECT_VERSION})")
|
||||
set(COMPONENT_DEP_core
|
||||
"rocprofiler-sdk-roctx (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-rocpd (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-rocattach (>= ${PROJECT_VERSION})")
|
||||
set(COMPONENT_DEP_docs "")
|
||||
set(COMPONENT_DEP_tests
|
||||
"rocprofiler-sdk (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-roctx (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-rocpd (>= ${PROJECT_VERSION})")
|
||||
"rocprofiler-sdk-rocpd (>= ${PROJECT_VERSION})"
|
||||
"rocprofiler-sdk-rocattach (>= ${PROJECT_VERSION})")
|
||||
set(COMPONENT_DEP_roctx "rocprofiler-register")
|
||||
set(COMPONENT_DEP_rocpd "")
|
||||
set(COMPONENT_DEP_benchmark "rocprofiler-sdk (>= ${PROJECT_VERSION})")
|
||||
set(COMPONENT_DEP_rocattach "")
|
||||
|
||||
set(COMPONENT_DESC_core "rocprofiler-sdk libraries, headers, samples, and tools")
|
||||
set(COMPONENT_DESC_docs "rocprofiler-sdk documentation")
|
||||
@@ -96,8 +103,9 @@ set(COMPONENT_DESC_tests "rocprofiler-sdk tests")
|
||||
set(COMPONENT_DESC_roctx "ROCm Tools Extension library and headers")
|
||||
set(COMPONENT_DESC_rocpd "ROCm Profiling Data library and headers")
|
||||
set(COMPONENT_DESC_benchmark "rocprofiler-sdk benchmark")
|
||||
set(COMPONENT_DESC_rocattach "ROCm Profiler Attachment library and headers")
|
||||
|
||||
set(EXPECTED_PACKAGING_COMPONENTS 7)
|
||||
set(EXPECTED_PACKAGING_COMPONENTS 8)
|
||||
if(ROCPROFILER_BUILD_DOCS)
|
||||
math(EXPR EXPECTED_PACKAGING_COMPONENTS "${EXPECTED_PACKAGING_COMPONENTS} + 1")
|
||||
endif()
|
||||
|
||||
@@ -24,11 +24,11 @@ install(
|
||||
WORLD_EXECUTE
|
||||
COMPONENT tools)
|
||||
|
||||
configure_file(rocprofv3-attach.py
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprofv3-attach COPYONLY)
|
||||
configure_file(rocprof-attach.py
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprof-attach COPYONLY)
|
||||
|
||||
install(
|
||||
FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprofv3-attach
|
||||
FILES ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprof-attach
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ
|
||||
WORLD_EXECUTE
|
||||
|
||||
+4
-4
@@ -28,9 +28,9 @@ import signal
|
||||
import sys
|
||||
import time
|
||||
|
||||
ROCPROFV3_ATTACH_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
ROCM_DIR = os.path.dirname(ROCPROFV3_ATTACH_DIR)
|
||||
ROCPROF_ATTACH_TOOL_LIBRARY = f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-attach.so"
|
||||
ROCPROF_ATTACH_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
ROCM_DIR = os.path.dirname(ROCPROF_ATTACH_DIR)
|
||||
ROCPROF_ATTACH_TOOL_LIBRARY = f"{ROCM_DIR}/lib/rocprofiler-sdk-rocattach.so"
|
||||
|
||||
|
||||
def main(
|
||||
@@ -41,7 +41,7 @@ def main(
|
||||
duration=os.environ.get("ROCPROF_ATTACH_DURATION", None),
|
||||
):
|
||||
if pid is None:
|
||||
raise RuntimeError("rocprofv3_attach called with no PID specified")
|
||||
raise RuntimeError("rocprof_attach called with no PID specified")
|
||||
|
||||
print(f"Attaching to PID {pid} using library {attach_library}")
|
||||
|
||||
@@ -1148,7 +1148,7 @@ def run(app_args, args, **kwargs):
|
||||
ROCPROF_LIST_AVAIL_TOOL_LIBRARY = (
|
||||
f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-list-avail.so"
|
||||
)
|
||||
ROCPROF_ATTACH_TOOL_LIBRARY = f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-attach.so"
|
||||
ROCPROF_ATTACH_TOOL_LIBRARY = f"{ROCM_DIR}/lib/librocprofiler-sdk-rocattach.so"
|
||||
|
||||
ROCPROF_TOOL_LIBRARY = resolve_library_path(ROCPROF_TOOL_LIBRARY, args)
|
||||
ROCPROF_SDK_LIBRARY = resolve_library_path(ROCPROF_SDK_LIBRARY, args)
|
||||
@@ -1517,7 +1517,7 @@ def run(app_args, args, **kwargs):
|
||||
update_env("ROCPROF_ATTACH_PID", args.pid)
|
||||
if args.attach_duration_msec is not None:
|
||||
update_env("ROCPROF_ATTACH_DURATION", f"{args.attach_duration_msec}")
|
||||
path = os.path.join(f"{ROCM_DIR}", "bin/rocprofv3-attach")
|
||||
path = os.path.join(f"{ROCM_DIR}", "bin/rocprof-attach")
|
||||
if app_args:
|
||||
exit_code = subprocess.check_call([sys.executable, path], env=app_env)
|
||||
else:
|
||||
|
||||
@@ -16,7 +16,7 @@ This document provides the technical details needed to implement a process attac
|
||||
Python Functions
|
||||
===================================
|
||||
|
||||
The python file ``rocprofv3-attach.py`` defines a main function that can be used for attachment:
|
||||
The python file ``rocprof-attach`` defines a main function that can be used for attachment:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -30,7 +30,7 @@ The python file ``rocprofv3-attach.py`` defines a main function that can be used
|
||||
|
||||
**Function Details**
|
||||
|
||||
The main function performs the entire attachment process, including attaching and detaching, and provides the ability to use custom tools. It also has simple control flow intended for direct calling from python. For more complex control, it is recommended to instead use the explicit attach and detach functions provided by the ``librocprofv3-attach.so`` binary.
|
||||
The main function performs the entire attachment process, including attaching and detaching, and provides the ability to use custom tools. It also has simple control flow intended for direct calling from python. For more complex control, it is recommended to instead use the explicit attach and detach functions provided by the ``librocprofiler-sdk-rocattach.so`` binary.
|
||||
|
||||
**Parameters**
|
||||
|
||||
@@ -38,7 +38,7 @@ The main function performs the entire attachment process, including attaching an
|
||||
- Defaults to environment variable ROCPROF_ATTACH_PID
|
||||
- **attach_library**: Optional - Colon delimited list of tool libraries to use
|
||||
- Defaults to environment variable ROCPROF_ATTACH_TOOL_LIBRARY
|
||||
- If unspecified, defaults to the absolute path of librocprofv3-attach.so
|
||||
- If unspecified, defaults to the absolute path of librocprofiler-sdk-rocattach.so
|
||||
- **duration**: Optional - Length of time in milliseconds to profile for
|
||||
- Defaults to environment variable ROCPROF_ATTACH_DURATION
|
||||
- If unspecified, attachment will run until Enter is pressed or SIGINT (Ctrl+C) is received
|
||||
@@ -46,7 +46,7 @@ The main function performs the entire attachment process, including attaching an
|
||||
C Functions
|
||||
===================================
|
||||
|
||||
The C library ``librocprofv3-attach.so`` defines an attach and detach function that can be used for attachment:
|
||||
The C library ``librocprofiler-sdk-rocattach.so`` defines an attach and detach function that can be used for attachment:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@@ -151,9 +151,9 @@ Basic Attachment Tool Implementation
|
||||
public:
|
||||
bool initialize() {
|
||||
// Load the rocprofiler-attach library/binary
|
||||
attach_lib_handle = dlopen("librocprofv3-attach.so", RTLD_NOW);
|
||||
attach_lib_handle = dlopen("librocprofiler-sdk-rocattach.so", RTLD_NOW);
|
||||
if (!attach_lib_handle) {
|
||||
std::cerr << "Failed to load librocprofv3-attach: " << dlerror() << std::endl;
|
||||
std::cerr << "Failed to load librocprofiler-sdk-rocattach: " << dlerror() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,12 @@ add_subdirectory(rocprofiler-sdk-roctx)
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "rocpd")
|
||||
add_subdirectory(rocprofiler-sdk-rocpd)
|
||||
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "rocattach")
|
||||
add_subdirectory(rocprofiler-sdk-rocattach)
|
||||
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "tools")
|
||||
add_subdirectory(att-tool)
|
||||
add_subdirectory(rocprofiler-sdk-tool)
|
||||
add_subdirectory(rocprofv3-attach)
|
||||
|
||||
add_subdirectory(python)
|
||||
|
||||
|
||||
+11
-10
@@ -22,11 +22,12 @@
|
||||
|
||||
rocprofiler_activate_clang_tidy()
|
||||
|
||||
add_library(rocprofv3-attach SHARED)
|
||||
target_sources(rocprofv3-attach PRIVATE rocprofv3_attach.cpp ptrace_session.cpp)
|
||||
add_library(rocprofiler-sdk-rocattach-shared-library SHARED)
|
||||
target_sources(rocprofiler-sdk-rocattach-shared-library PRIVATE rocattach.cpp
|
||||
ptrace_session.cpp)
|
||||
|
||||
target_link_libraries(
|
||||
rocprofv3-attach
|
||||
rocprofiler-sdk-rocattach-shared-library
|
||||
PRIVATE rocprofiler-sdk::rocprofiler-sdk-shared-library
|
||||
rocprofiler-sdk::rocprofiler-sdk-headers
|
||||
rocprofiler-sdk::rocprofiler-sdk-build-flags
|
||||
@@ -34,16 +35,16 @@ target_link_libraries(
|
||||
rocprofiler-sdk::rocprofiler-sdk-cereal)
|
||||
|
||||
set_target_properties(
|
||||
rocprofv3-attach
|
||||
PROPERTIES LIBRARY_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/rocprofiler-sdk
|
||||
rocprofiler-sdk-rocattach-shared-library
|
||||
PROPERTIES OUTPUT_NAME rocprofiler-sdk-rocattach
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${PROJECT_VERSION}
|
||||
BUILD_RPATH "\$ORIGIN:\$ORIGIN/.."
|
||||
INSTALL_RPATH "\$ORIGIN:\$ORIGIN/..")
|
||||
|
||||
install(
|
||||
TARGETS rocprofv3-attach
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/rocprofiler-sdk
|
||||
COMPONENT tools
|
||||
EXPORT rocprofiler-sdk-tool-targets)
|
||||
TARGETS rocprofiler-sdk-rocattach-shared-library
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT rocattach
|
||||
EXPORT rocprofiler-sdk-rocattach-targets)
|
||||
+6
-3
@@ -21,8 +21,8 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "ptrace_session.hpp"
|
||||
#include "details/filesystem.hpp"
|
||||
|
||||
#include "lib/common/filesystem.hpp"
|
||||
#include "lib/common/logging.hpp"
|
||||
|
||||
#include <dlfcn.h>
|
||||
@@ -48,6 +48,8 @@ static_assert(sizeof(void*) == 8);
|
||||
static_assert(false);
|
||||
#endif
|
||||
|
||||
namespace fs = rocprofiler::common::filesystem;
|
||||
|
||||
namespace
|
||||
{
|
||||
/* Copied from glibc's elf.h. */
|
||||
@@ -176,8 +178,9 @@ get_linked_path(std::string_view _name, open_modes_vec_t&& _open_modes)
|
||||
auto
|
||||
get_this_library_path()
|
||||
{
|
||||
auto _this_lib_path = get_linked_path("librocprofv3-attach.so.1", {RTLD_NOLOAD | RTLD_LAZY});
|
||||
LOG_IF(FATAL, !_this_lib_path) << "librocprofv3-attach.so.1"
|
||||
auto _this_lib_path =
|
||||
get_linked_path("librocprofiler-sdk-rocattach.so.1", {RTLD_NOLOAD | RTLD_LAZY});
|
||||
LOG_IF(FATAL, !_this_lib_path) << "librocprofiler-sdk-rocattach.so.1"
|
||||
<< " could not locate itself in the list of loaded libraries";
|
||||
return fs::path{*_this_lib_path}.parent_path().string();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
// 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
|
||||
|
||||
#if defined __has_include
|
||||
# if __has_include(<version>)
|
||||
# include <version>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_lib_filesystem)
|
||||
# define ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM 1
|
||||
#else
|
||||
# if defined __has_include
|
||||
# if __has_include(<filesystem>)
|
||||
# include <filesystem>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM) && \
|
||||
ROCPROFILER_REGISTER_HAS_CPP_LIB_FILESYSTEM > 0
|
||||
# include <filesystem>
|
||||
namespace fs = ::std::filesystem; // NOLINT
|
||||
#else
|
||||
# include <experimental/filesystem>
|
||||
namespace fs = ::std::experimental::filesystem; // NOLINT
|
||||
#endif
|
||||
Reference in New Issue
Block a user