Changing build directory structure to match rocm

Change-Id: I22ed8ef777cfdbebe6caca65b68ff5e6bb12d35e


[ROCm/rocprofiler commit: 6dc1066d5d]
This commit is contained in:
Ammar ELWazir
2023-06-06 01:20:05 +00:00
committed by Ammar Elwazir
parent 04508527df
commit f5033efa6d
10 changed files with 78 additions and 52 deletions
@@ -33,7 +33,7 @@ set_target_properties(
att_plugin
PROPERTIES CXX_VISIBILITY_PRESET hidden
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler)
target_compile_definitions(att_plugin PRIVATE HIP_PROF_HIP_API_STRING=1
__HIP_PLATFORM_HCC__=1)
@@ -28,7 +28,7 @@ add_library(cli_plugin SHARED ${CLI_SOURCES} ${ROCPROFILER_UTIL_SRC_FILES})
set_target_properties(cli_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler)
target_compile_definitions(cli_plugin
PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1)
@@ -31,7 +31,7 @@ add_library(ctf_plugin SHARED
set_target_properties(ctf_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../exportmap"
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/rocprofiler")
set(METADATA_STREAM_FILE_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/plugin/ctf")
target_compile_definitions(ctf_plugin PUBLIC AMD_INTERNAL_BUILD PRIVATE
HIP_PROF_HIP_API_STRING=1
@@ -28,7 +28,7 @@ add_library(file_plugin SHARED ${FILE_SOURCES} ${ROCPROFILER_UTIL_SRC_FILES})
set_target_properties(file_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler)
target_compile_definitions(file_plugin
PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_HCC__=1)
@@ -7,7 +7,7 @@ add_library(perfetto_plugin
set_target_properties(perfetto_plugin PROPERTIES
CXX_VISIBILITY_PRESET hidden
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../exportmap
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/rocprofiler)
target_compile_definitions(perfetto_plugin
PRIVATE HIP_PROF_HIP_API_STRING=1
+4 -4
View File
@@ -25,7 +25,7 @@ This filter could be for counters/traces/pc-samples etc.
Now that the input is taken care of, one also needs to provide a "Buffer" which
will store the output results generated during a session. This buffer will contain
different records corresponding to the filter type chosen. A flush function can also
be specified for the buffer, which will be used to flush the buffer records.
be specified for the buffer, which will be used to flush the buffer records.
A filter and buffer are associated together.
Once a Session, Buffer, Filter have all been created, the session can be started.
@@ -51,7 +51,7 @@ This code sample demonstrates how to use the APIs to collect counters and metric
In order to get the samples to compile, make sure to copy rocprofiler binaries into /opt/rocm/lib
Running 'make install' inside the rocprofiler/build folder will copy the binaries to /opt/rocm/lib
Alternately, change the 'ROCPROFILER_LIBS_PATH' variable in the Makefile to point to the rocprofiler/build folder.
Alternately, change the 'ROCPROFILER_LIBS_PATH' variable in the Makefile to point to the rocprofiler/build folder.
After modifications to Makefile are done, run:
```bash
@@ -72,9 +72,9 @@ then below command will work:
export ROCPROFILER_METRICS_PATH=/opt/rocm/libexec/rocprofiler/counters/derived_counters.xml
```
Otherwise, make it point to rocprofiler/build/counters/derived_counters.xml like below:
Otherwise, make it point to rocprofiler/build/libexec/rocprofiler/counters/derived_counters.xml like below:
```bash
export ROCPROFILER_METRICS_PATH=<path_to_rocprofiler>/rocprofiler/buid/counters/derived_counters.xml
export ROCPROFILER_METRICS_PATH=<path_to_rocprofiler>/rocprofiler/build/libexec/rocprofiler/counters/derived_counters.xml
```
Finally, run a sample:
+50 -28
View File
@@ -195,8 +195,10 @@ file(GLOB CORE_PC_SAMPLING_FILES ${CORE_PC_SAMPLING_DIR}/core/*.cpp ${CORE_PC_SA
add_library(${ROCPROFILER_TARGET} SHARED ${OLD_LIB_SRC})
set_target_properties(${ROCPROFILER_TARGET} PROPERTIES
CXX_VISIBILITY_PRESET hidden
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
VERSION 1.0.0
SOVERSION 1)
# As ROCR hsa_api_trace header file is not usable unless AMD_INTERNAL_BUILD is defined
target_compile_definitions(${ROCPROFILER_TARGET} PUBLIC AMD_INTERNAL_BUILD)
target_include_directories(${ROCPROFILER_TARGET}
@@ -206,10 +208,15 @@ target_include_directories(${ROCPROFILER_TARGET}
${LIB_DIR} ${ROOT_DIR}
${PROJECT_SOURCE_DIR}/include/rocprofiler)
target_link_libraries(${ROCPROFILER_TARGET} PRIVATE ${AQLPROFILE_LIB} hsa-runtime64::hsa-runtime64 c stdc++)
get_target_property(ROCPROFILER_LIBRARY_V1_NAME ${ROCPROFILER_TARGET} NAME)
get_target_property(ROCPROFILER_LIBRARY_V1_VERSION ${ROCPROFILER_TARGET} VERSION)
get_target_property(ROCPROFILER_LIBRARY_V1_SOVERSION ${ROCPROFILER_TARGET} SOVERSION)
## Install libraries: Non versioned lib file in dev package
# install ( TARGETS ${ROCPROFILER_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev NAMELINK_COMPONENT runtime)
install ( TARGETS ${ROCPROFILER_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP)
install ( TARGETS ${ROCPROFILER_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan NAMELINK_SKIP)
## Skipping NameLink as it will be installed using symlinks
install ( TARGETS ${ROCPROFILER_TARGET} LIBRARY NAMELINK_SKIP DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime)
install ( TARGETS ${ROCPROFILER_TARGET} LIBRARY NAMELINK_SKIP DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan)
#### V2 Library
# Compiling/Installing ROCProfiler API
@@ -242,17 +249,10 @@ set_target_properties(rocprofiler-v2 PROPERTIES
DEFINE_SYMBOL "ROCPROFILER_EXPORTS"
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/exportmap
OUTPUT_NAME rocprofiler64
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/v2
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
# Add custom command to copy the v2 library to buil-dir as well
add_custom_command(TARGET rocprofiler-v2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/v2/librocprofiler64.so.2 ${CMAKE_BINARY_DIR}
)
# Add custom target to trigger the copy command
add_custom_target(copy_v2_library DEPENDS rocprofiler-v2)
target_compile_definitions(rocprofiler-v2
# As ROCR hsa_api_trace header file is not usable unless AMD_INTERNAL_BUILD is defined
PRIVATE AMD_INTERNAL_BUILD
@@ -276,28 +276,50 @@ else()
target_link_options(rocprofiler-v2 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap -Wl,--no-undefined)
target_link_libraries(rocprofiler-v2 PRIVATE ${AQLPROFILE_LIB} hsa-runtime64::hsa-runtime64 Threads::Threads atomic numa dl c stdc++ stdc++fs amd_comgr ${PCIACCESS_LIBRARIES})
endif()
get_target_property(ROCPROFILER_LIBRARY_V2_NAME rocprofiler-v2 OUTPUT_NAME)
get_target_property(ROCPROFILER_LIBRARY_V2_VERSION rocprofiler-v2 VERSION)
get_target_property(ROCPROFILER_LIBRARY_V2_SOVERSION rocprofiler-v2 SOVERSION)
## Prepare Name Link SO files for V1 & V2 Libraries
add_custom_command(TARGET rocprofiler-v2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_BINARY_DIR}/lib/lib${ROCPROFILER_LIBRARY_V1_NAME}.so
COMMAND ${CMAKE_COMMAND} -E create_symlink
lib${ROCPROFILER_LIBRARY_V1_NAME}.so.${ROCPROFILER_LIBRARY_V1_SOVERSION}
${CMAKE_BINARY_DIR}/lib/lib${ROCPROFILER_LIBRARY_V1_NAME}.so
COMMAND ${CMAKE_COMMAND} -E create_symlink
lib${ROCPROFILER_LIBRARY_V2_NAME}.so.${ROCPROFILER_LIBRARY_V2_SOVERSION}
${CMAKE_BINARY_DIR}/lib/lib${ROCPROFILER_LIBRARY_V2_NAME}v2.so
)
# Add custom target to trigger the create_symlink command
add_custom_target(create_rocprofiler_lib DEPENDS rocprofiler-v2 ${ROCPROFILER_TARGET})
## Install libraries: Non versioned lib file in dev package
# install(TARGETS rocprofiler-v2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev)
install(TARGETS rocprofiler-v2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_SKIP)
# install(TARGETS rocprofiler-v2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan)
## Skipping NameLink as it will be installed using symlinks
install(TARGETS rocprofiler-v2 LIBRARY NAMELINK_SKIP DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime)
install(TARGETS rocprofiler-v2 LIBRARY NAMELINK_SKIP DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan)
file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/librocprofiler64.so
CONTENT "OUTPUT_FORMAT(elf64-x86-64)\nINPUT(librocprofiler64.so.1)")
install(FILES ${CMAKE_BINARY_DIR}/librocprofiler64.so DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT runtime)
## Installing NameLinks for V1 & V2
## librocprofiler64.so links to V1 library
## librocprofiler64v2.so links to V2 library
install(CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
lib${ROCPROFILER_LIBRARY_V1_NAME}.so.${ROCPROFILER_LIBRARY_V1_SOVERSION} \
${CMAKE_INSTALL_PREFIX}/lib/lib${ROCPROFILER_LIBRARY_V1_NAME}.so \
)" COMPONENT dev
)
install(CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
lib${ROCPROFILER_LIBRARY_V2_NAME}.so.${ROCPROFILER_LIBRARY_V2_SOVERSION} \
${CMAKE_INSTALL_PREFIX}/lib/lib${ROCPROFILER_LIBRARY_V2_NAME}v2.so \
)" COMPONENT dev
)
file(CONFIGURE OUTPUT ${CMAKE_BINARY_DIR}/librocprofiler64v2.so
CONTENT "OUTPUT_FORMAT(elf64-x86-64)\nINPUT(librocprofiler64.so.${PROJECT_VERSION_MAJOR})")
install(FILES ${CMAKE_BINARY_DIR}/librocprofiler64v2.so DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT runtime)
configure_file(${PROJECT_SOURCE_DIR}/src/core/counters/metrics/basic_counters.xml ${PROJECT_BINARY_DIR}/counters/basic_counters.xml COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/core/counters/metrics/derived_counters.xml ${PROJECT_BINARY_DIR}/counters/derived_counters.xml COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/core/counters/metrics/basic_counters.xml ${PROJECT_BINARY_DIR}/libexec/rocprofiler/counters/basic_counters.xml COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/core/counters/metrics/derived_counters.xml ${PROJECT_BINARY_DIR}/libexec/rocprofiler/counters/derived_counters.xml COPYONLY)
install(DIRECTORY
${PROJECT_BINARY_DIR}/counters
${PROJECT_BINARY_DIR}/libexec/rocprofiler/counters
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${PROJECT_NAME}
USE_SOURCE_PERMISSIONS
COMPONENT runtime)
@@ -13,6 +13,7 @@ add_library(rocprofiler_tool SHARED ${ROCPROFILER_TOOL_SRC_FILES} ${ROCPROFILER_
set_target_properties(rocprofiler_tool PROPERTIES
CXX_VISIBILITY_PRESET hidden
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/rocprofiler
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/exportmap)
target_include_directories(rocprofiler_tool
@@ -31,7 +31,6 @@ THE SOFTWARE.
#include <string>
#include <thread>
#include <array>
#include <experimental/filesystem>
#include "src/utils/helper.h"
#include "utils/csv_parser.h"
@@ -47,22 +46,20 @@ std::string binary_path;
std::string profiler_api_lib_path = "";
static void init_test_path() {
lib_path = "lib/rocprofiler/librocprofiler_tool.so";
metrics_path = "libexec/rocprofiler/counters/derived_counters.xml";
profiler_api_lib_path = "/lib";
if (is_installed_path()) {
INFO_LOGGING("operating from /opt/rocm");
running_path = "share/rocprofiler/tests/runFeatureTests";
lib_path = "lib/rocprofiler/librocprofiler_tool.so";
golden_trace_path = "share/rocprofiler/tests/featuretests/profiler/apps/goldentraces/";
test_app_path = "share/rocprofiler/tests/featuretests/profiler/apps/";
metrics_path = "libexec/rocprofiler/counters/derived_counters.xml";
binary_path = "bin/rocprofv2";
profiler_api_lib_path = "/lib";
} else {
INFO_LOGGING("operating from ./build/");
running_path = "tests-v2/featuretests/profiler/runFeatureTests";
lib_path = "librocprofiler_tool.so";
golden_trace_path = "tests-v2/featuretests/profiler/apps/goldentraces/";
test_app_path = "tests-v2/featuretests/profiler/apps/";
metrics_path = "counters/derived_counters.xml";
binary_path = "rocprofv2";
}
}
@@ -77,7 +74,7 @@ void __attribute__((constructor)) globalsetting() {
}
/**
* Sets application enviornment by seting HSA_TOOLS_LIB.
* Sets application enviornment by setting COUNTERS_PATH,LD_PRELOAD,LD_LIBRARY_PATH.
*/
void ApplicationParser::SetApplicationEnv(const char* app_name) {
std::string app_path;
@@ -91,7 +88,7 @@ void ApplicationParser::SetApplicationEnv(const char* app_name) {
ld_library_path << app_path << profiler_api_lib_path << []() {
const char* path = getenv("LD_LIBRARY_PATH");
if (path != nullptr) return ":" + std::string(path);
return std::string("");
return std::string();
}();
setenv("LD_LIBRARY_PATH", ld_library_path.str().c_str(), true);
@@ -104,6 +101,15 @@ void ApplicationParser::SetApplicationEnv(const char* app_name) {
setenv("LD_PRELOAD", hsa_tools_lib_path.str().c_str(), true);
std::stringstream ld_lib_path;
ld_lib_path << app_path << "lib" << []() {
const char* path = getenv("LD_LIBRARY_PATH");
if (path != nullptr)
return ":" + std::string(path);
return std::string("");
}();
setenv("LD_LIBRARY_PATH", ld_lib_path.str().c_str(), true);
std::stringstream os;
os << app_path << test_app_path << app_name;
@@ -1204,7 +1210,6 @@ TEST(ProfilerMPTest, WhenRunningMultiProcessTestItPasses) {
// EXPECT_EQ(hasFile(), true);
// }
// class VectorAddFileAndFolderTest : public FilePluginTest {
// protected:
// virtual void SetUp() {
@@ -34,22 +34,20 @@ std::string binary_path;
std::string profiler_api_lib_path = "";
static void init_test_path() {
lib_path = "lib/rocprofiler/librocprofiler_tool.so";
metrics_path = "libexec/rocprofiler/counters/derived_counters.xml";
profiler_api_lib_path = "/lib";
if (is_installed_path()) {
INFO_LOGGING("operating from /opt/rocm");
running_path = "share/rocprofiler/tests/runTracerFeatureTests";
lib_path = "lib/rocprofiler/librocprofiler_tool.so";
golden_trace_path = "share/rocprofiler/tests/featuretests/tracer/apps/goldentraces/";
test_app_path = "share/rocprofiler/tests/featuretests/tracer/apps/";
metrics_path = "libexec/rocprofiler/counters/derived_counters.xml";
binary_path = "bin/rocprofv2";
profiler_api_lib_path = "/lib";
} else {
INFO_LOGGING("operating from ./build");
running_path = "tests-v2/featuretests/tracer/runTracerFeatureTests";
lib_path = "librocprofiler_tool.so";
golden_trace_path = "tests-v2/featuretests/tracer/apps/goldentraces/";
test_app_path = "tests-v2/featuretests/tracer/apps/";
metrics_path = "counters/derived_counters.xml";
binary_path = "rocprofv2";
}
}
@@ -66,7 +64,7 @@ void ApplicationParser::SetApplicationEnv(const char* app_name, const char* trac
ld_library_path << app_path << profiler_api_lib_path << []() {
const char* path = getenv("LD_LIBRARY_PATH");
if (path != nullptr) return ":" + std::string(path);
return std::string("");
return std::string();
}();
setenv("LD_LIBRARY_PATH", ld_library_path.str().c_str(), true);