Skip to content

Commit

Permalink
Finished standalone ROCClr build
Browse files Browse the repository at this point in the history
  • Loading branch information
JacekJagosz committed May 14, 2022
1 parent ef2588e commit 851d417
Show file tree
Hide file tree
Showing 13 changed files with 406 additions and 157 deletions.
1 change: 1 addition & 0 deletions rocm-hip/abi_symbols
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ libamdhip64.so.5:_Z22hipCreateSurfaceObjectPP13__hip_surfacePK15hipResourceDesc
libamdhip64.so.5:_Z23hipDestroySurfaceObjectP13__hip_surface
libamdhip64.so.5:_Z24hipExtModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_j
libamdhip64.so.5:_Z24hipHccModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_
libamdhip64.so.5:_ZN8hip_impl22hipLaunchKernelGGLImplEmRK4dim3S2_jP12ihipStream_tPPv
libamdhip64.so.5:__hipGetPCH
libamdhip64.so.5:__hipPopCallConfiguration
libamdhip64.so.5:__hipPushCallConfiguration
Expand Down
142 changes: 142 additions & 0 deletions rocm-hip/files/0001-Use-GNUInstallDirs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
From 26c33f505713a4cebf638988346fc62ff85e7732 Mon Sep 17 00:00:00 2001
From: Jeremy Newton <[email protected]>
Date: Sat, 7 May 2022 14:23:21 -0400
Subject: [PATCH] Use GNUInstallDirs

---
CMakeLists.txt | 31 ++++++++++++++++++-------------
src/CMakeLists.txt | 6 +++---
2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c5a2e7f..546925b2 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,11 @@
cmake_minimum_required(VERSION 3.16.8)
project(hip)

+# Set default libdir to be "lib" for ROCm, distros will override this anyway:
+set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory")
+
+include(GNUInstallDirs)
+
# sample command for hip-rocclr runtime, you'll need to have rocclr built
# ROCM_PATH is the path where ROCM is installed
# For shared lib of hip-rocclr runtime
@@ -39,7 +44,7 @@ list(APPEND CMAKE_MODULE_PATH ${HIP_COMMON_DIR}/cmake)

# required to add the right link to libhsa-runtime in install/lib path
# CMAKE_PREFIX_PATH is used as rpath to search for libs outside HIP
-set(CMAKE_INSTALL_RPATH "${CMAKE_PREFIX_PATH}/lib")
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

#############################
@@ -275,9 +280,9 @@ endif (NOT CPACK_SET_DESTDIR)
#############################
# Build steps
#############################
-set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
-set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
-set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include)
+set(BIN_INSTALL_DIR ${CMAKE_INSTALL_FULL_BINDIR})
+set(LIB_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
+set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip)
set(CONFIG_LANG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip-lang)

@@ -325,10 +330,10 @@ endif()
#############################

# Install .hipInfo
-install(FILES ${PROJECT_BINARY_DIR}/.hipInfo DESTINATION lib)
+install(FILES ${PROJECT_BINARY_DIR}/.hipInfo DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Install .hipVersion
-install(FILES ${PROJECT_BINARY_DIR}/.hipVersion DESTINATION bin)
+install(FILES ${PROJECT_BINARY_DIR}/.hipVersion DESTINATION ${CMAKE_INSTALL_BINDIR})

# Install src, bin, include & cmake if necessary
execute_process(COMMAND test ${CMAKE_INSTALL_PREFIX} -ef ${CMAKE_CURRENT_SOURCE_DIR}
@@ -337,7 +342,7 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0)
if(WIN32)
install(DIRECTORY ${HIP_COMMON_BIN_DIR} DESTINATION . USE_SOURCE_PERMISSIONS)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
- install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/" DESTINATION bin
+ install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/" DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES_MATCHING PATTERN "*.pdb"
PATTERN "*.ilk"
PATTERN "CMakeFiles" EXCLUDE
@@ -354,11 +359,11 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0)
endif()

# The following two lines will be removed after upstream updation
- install(CODE "MESSAGE(\"Removing ${CMAKE_INSTALL_PREFIX}/include\")")
- install(CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/include)")
+ install(CODE "MESSAGE(\"Removing ${CMAKE_INSTALL_FULL_INCLUDEDIR}\")")
+ install(CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_FULL_INCLUDEDIR})")

install(DIRECTORY include DESTINATION .)
- install(DIRECTORY ${HIP_COMMON_INCLUDE_DIR}/hip/ DESTINATION include/hip/)
+ install(DIRECTORY ${HIP_COMMON_INCLUDE_DIR}/hip/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hip/)
install(DIRECTORY ${HIP_COMMON_DIR}/cmake DESTINATION .)
endif()

@@ -366,11 +371,11 @@ endif()
# FIXME: Associate with individual targets.
if(HIP_PLATFORM STREQUAL "amd")
install(FILES ${PROJECT_BINARY_DIR}/include/hip/amd_detail/hip_prof_str.h
- DESTINATION include/hip/amd_detail)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hip/amd_detail)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin DESTINATION . USE_SOURCE_PERMISSIONS)
endif()
install(FILES ${PROJECT_BINARY_DIR}/include/hip/hip_version.h
- DESTINATION include/hip)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hip)

#############################
# hip-config
@@ -548,7 +553,7 @@ endif()
# Target: clang
if(HIP_HIPCC_EXECUTABLE)
add_custom_target(analyze
- COMMAND ${HIP_HIPCC_EXECUTABLE} -fvisibility=hidden -fvisibility-inlines-hidden --analyze --analyzer-outputtext -isystem ${ROCM_PATH}/include -Wno-unused-command-line-argument -I${ROCM_PATH}/include -c src/*.cpp -Iinclude/ -I./
+ COMMAND ${HIP_HIPCC_EXECUTABLE} -fvisibility=hidden -fvisibility-inlines-hidden --analyze --analyzer-outputtext -isystem ${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR} -Wno-unused-command-line-argument -I${ROCM_PATH}/${CMAKE_INSTALL_INCLUDEDIR} -c src/*.cpp -Iinclude/ -I./
WORKING_DIRECTORY ${HIP_SRC_PATH})
if(CPPCHECK_EXE)
add_dependencies(analyze cppcheck)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ac88ddf5..2ce748d1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -257,7 +257,7 @@ if(__HIP_ENABLE_RTC)
add_dependencies(amdhip64 hiprtc-builtins)
install(TARGETS hiprtc-builtins
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION lib
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

@@ -325,7 +325,7 @@ target_link_libraries(device INTERFACE host)
INSTALL(TARGETS amdhip64 host device
EXPORT hip-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION lib
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::)
@@ -333,7 +333,7 @@ INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE h
INSTALL(TARGETS amdhip64 host device
EXPORT hip-lang-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION lib
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
INSTALL(EXPORT hip-lang-targets DESTINATION ${CONFIG_LANG_PACKAGE_INSTALL_DIR} NAMESPACE hip-lang::)
--
2.34.1

2 changes: 2 additions & 0 deletions rocm-hip/files/series
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0001-Revert-hip-Fix-and-install-cmake-targets-for-hip-pac.patch
0002-Revert-hip-Switch-to-component-based-packaging.patch
0001-Use-installed-rocclr-if-available.patch
0002-Fix-CL-icd-header-include.patch
0001-Use-GNUInstallDirs.patch
17 changes: 5 additions & 12 deletions rocm-hip/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ description: |
HIP is a C++ Runtime API and Kernel Language that allows developers to create portable applications for AMD and NVIDIA GPUs from single source code.
extract : False
builddeps :
- pkgconfig(OpenCL)
- pkgconfig(d3d)
- pkgconfig(gl)
- pkgconfig(libhsakmt)
- pkgconfig(x11-xcb)
Expand All @@ -31,22 +29,18 @@ setup : |
cd hipamd-rocm-%version%
%apply_patches
#FIXME: soname is broken when building from tar, upstream is fixing the issue:
#soname is broken when building from tar, upstream is fixing the issue:
sed -i 's/-${HIP_VERSION_GITHASH}//' CMakeLists.txt
#some hip cmake files don't respect the Linux FHS:
#sed -i "s/\(cmake DESTINATION \)./\1\${LIB_INSTALL_DIR}/" CMakeLists.txt
#HIP requires RPATH
sed -i "/CMAKE_INSTALL_RPATH/d" CMakeLists.txt
mkdir build
cd build
%cmake -S.. -B. \
-DHIP_COMMON_DIR=%workdir%/HIP-rocm-%version% \
-DCMAKE_INSTALL_LIBDIR=%libdir% \
-DHIP_COMPILER=clang \
-DROCM_PATH=%PREFIX% \
-DROCCLR_INCLUDE_DIR=/usr/include/rocclr/include \
-DHIP_VERSION_BUILD_ID=0
build : |
cd hipamd-rocm-%version%/build
Expand All @@ -55,7 +49,6 @@ install : |
cd hipamd-rocm-%version%/build
%make_install
#cmake hardcodes libdir, instead of using cmake's gnuinstalldirs
mv %installroot%%PREFIX%/lib %installroot%%libdir%
sed -i "s|lib\(/libamdhip64.so\)|lib64\1|" \
%installroot%%libdir%/cmake/hip*/*.cmake
#hip installs some cmake modules incorrectly:
mv %installroot%/usr/cmake %installroot%%libdir%/cmake/Modules
10 changes: 5 additions & 5 deletions rocm-hip/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<Path fileType="executable">/usr/bin/roc-obj-ls</Path>
<Path fileType="library">/usr/lib64/.hipInfo</Path>
<Path fileType="library">/usr/lib64/libamdhip64.so.5</Path>
<Path fileType="library">/usr/lib64/libamdhip64.so.5.1.20531-</Path>
<Path fileType="library">/usr/lib64/libamdhip64.so.5.1.20531</Path>
<Path fileType="library">/usr/lib64/libhiprtc-builtins.so.5</Path>
<Path fileType="library">/usr/lib64/libhiprtc-builtins.so.5.1.20531-</Path>
<Path fileType="library">/usr/lib64/libhiprtc-builtins.so.5.1.20531</Path>
</Files>
</Package>
<Package>
Expand Down Expand Up @@ -113,9 +113,9 @@
<Path fileType="header">/usr/include/hip/nvidia_detail/nvidia_hiprtc.h</Path>
<Path fileType="header">/usr/include/hip/surface_types.h</Path>
<Path fileType="header">/usr/include/hip/texture_types.h</Path>
<Path fileType="library">/usr/lib64/cmake/FindHIP.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/FindHIP/run_hipcc.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/FindHIP/run_make2cmake.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/Modules/FindHIP.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/Modules/FindHIP/run_hipcc.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/Modules/FindHIP/run_make2cmake.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/hip-lang/hip-lang-config-version.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/hip-lang/hip-lang-config.cmake</Path>
<Path fileType="library">/usr/lib64/cmake/hip-lang/hip-lang-targets-relwithdebinfo.cmake</Path>
Expand Down
2 changes: 1 addition & 1 deletion rocm-opencl/abi_libs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libamdocl64.so
libcltrace.so
libcltrace.so.5.1
librocclr.so.5.1
4 changes: 2 additions & 2 deletions rocm-opencl/abi_symbols
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ libamdocl64.so:clSetUserEventStatus
libamdocl64.so:clUnloadCompiler
libamdocl64.so:clUnloadPlatformCompiler
libamdocl64.so:clWaitForEvents
libcltrace.so:vdiAgent_OnLoad
libcltrace.so:vdiAgent_OnUnload
libcltrace.so.5.1:vdiAgent_OnLoad
libcltrace.so.5.1:vdiAgent_OnUnload
librocclr.so.5.1:AMD_CPU_AFFINITY
librocclr.so.5.1:AMD_DIRECT_DISPATCH
librocclr.so.5.1:AMD_GPU_FORCE_SINGLE_FP_DENORM
Expand Down
1 change: 0 additions & 1 deletion rocm-opencl/abi_used_libs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
UNKNOWN
ld-linux-x86-64.so.2
libOpenCL.so.1
libamd_comgr.so.2
libc.so.6
libgcc_s.so.1
libhsa-runtime64.so.1
Expand Down
30 changes: 0 additions & 30 deletions rocm-opencl/abi_used_symbols
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,6 @@ libOpenCL.so.1:clReleaseDevice
libOpenCL.so.1:clReleaseKernel
libOpenCL.so.1:clReleaseProgram
libOpenCL.so.1:clRetainDevice
libamd_comgr.so.2:amd_comgr_action_data_count
libamd_comgr.so.2:amd_comgr_action_data_get_data
libamd_comgr.so.2:amd_comgr_action_info_set_isa_name
libamd_comgr.so.2:amd_comgr_action_info_set_language
libamd_comgr.so.2:amd_comgr_action_info_set_logging
libamd_comgr.so.2:amd_comgr_action_info_set_option_list
libamd_comgr.so.2:amd_comgr_create_action_info
libamd_comgr.so.2:amd_comgr_create_data
libamd_comgr.so.2:amd_comgr_create_data_set
libamd_comgr.so.2:amd_comgr_data_set_add
libamd_comgr.so.2:amd_comgr_demangle_symbol_name
libamd_comgr.so.2:amd_comgr_destroy_action_info
libamd_comgr.so.2:amd_comgr_destroy_data_set
libamd_comgr.so.2:amd_comgr_destroy_metadata
libamd_comgr.so.2:amd_comgr_do_action
libamd_comgr.so.2:amd_comgr_get_data
libamd_comgr.so.2:amd_comgr_get_data_isa_name
libamd_comgr.so.2:amd_comgr_get_data_metadata
libamd_comgr.so.2:amd_comgr_get_isa_metadata
libamd_comgr.so.2:amd_comgr_get_metadata_kind
libamd_comgr.so.2:amd_comgr_get_metadata_list_size
libamd_comgr.so.2:amd_comgr_get_metadata_string
libamd_comgr.so.2:amd_comgr_index_list_metadata
libamd_comgr.so.2:amd_comgr_iterate_map_metadata
libamd_comgr.so.2:amd_comgr_iterate_symbols
libamd_comgr.so.2:amd_comgr_metadata_lookup
libamd_comgr.so.2:amd_comgr_release_data
libamd_comgr.so.2:amd_comgr_set_data
libamd_comgr.so.2:amd_comgr_set_data_name
libamd_comgr.so.2:amd_comgr_symbol_get_info
libc.so.6:__cxa_atexit
libc.so.6:__errno_location
libc.so.6:__isoc99_sscanf
Expand Down
Loading

0 comments on commit 851d417

Please sign in to comment.