Skip to content

Commit

Permalink
Merge pull request #125 from RadeonOpenCompute/rocm-4.5.x
Browse files Browse the repository at this point in the history
ROCm 4.5.0 updates
  • Loading branch information
skeelyamd authored Oct 27, 2021
2 parents f114e4d + f32dfa8 commit fc99cf8
Show file tree
Hide file tree
Showing 49 changed files with 1,584 additions and 391 deletions.
115 changes: 58 additions & 57 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## The University of Illinois/NCSA
## Open Source License (NCSA)
##
## Copyright (c) 2014-2020, Advanced Micro Devices, Inc. All rights reserved.
## Copyright (c) 2014-2021, Advanced Micro Devices, Inc. All rights reserved.
##
## Developed by:
##
Expand All @@ -17,14 +17,14 @@
## of this software and associated documentation files (the "Software"), to
## deal with 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
## 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:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimers.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimers in
## the documentation and#or other materials provided with the distribution.
## the documentation and/or other materials provided with the distribution.
## - Neither the names of Advanced Micro Devices, Inc,
## nor the names of its contributors may be used to endorse or promote
## products derived from this Software without specific prior written
Expand All @@ -40,19 +40,7 @@
##
################################################################################

cmake_minimum_required ( VERSION 3.5.0 )

## Cosmetic Cmake version warnings.
if(NOT EXISTS VERSION_WARNED)
set (VERSION_WARNED FALSE CACHE BOOL "")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.6.0" AND NOT ${VERSION_WARNED})
message("Your CMake version is too old for full functionality.
Generated package file names may be incorrect.
Please update to CMake 3.6 or newer to generate correct package file names")
set( VERSION_WARNED TRUE CACHE BOOL "Suppress cosmetic build errors due to CMake version after first warning." FORCE )
mark_as_advanced( FORCE VERSION_WARNED )
endif()
cmake_minimum_required ( VERSION 3.7 )

## Clear target dependency data.
## Needed to allow UI transitions between static and dynamic builds.
Expand Down Expand Up @@ -97,7 +85,7 @@ if (ROCM_CCACHE_BUILD)
endif() # if (ROCM_CCACHE_BUILD)

## Get version strings
get_version ( "1.3.0" )
get_version ( "1.4.0" )
if ( ${ROCM_PATCH_VERSION} )
set ( VERSION_PATCH ${ROCM_PATCH_VERSION})
endif()
Expand Down Expand Up @@ -144,10 +132,13 @@ set ( HSA_CXX_FLAGS ${HSA_COMMON_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvis
set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-deprecated-declarations )

if ( CMAKE_COMPILER_IS_GNUCXX )
set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=unused-but-set-variable -Wno-error=maybe-uninitialized)
set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=maybe-uninitialized -Wno-error=unused-but-set-variable)
endif ()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=self-assign)
if( ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 13)
set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=unused-but-set-variable)
endif()
endif()

set ( DRVDEF "${CMAKE_CURRENT_SOURCE_DIR}/hsacore.so.def" )
Expand All @@ -163,6 +154,7 @@ set_property(TARGET ${CORE_RUNTIME_TARGET} PROPERTY LINK_FLAGS ${HSA_SHARED_LINK
set ( SRCS core/util/lnx/os_linux.cpp
core/util/small_heap.cpp
core/util/timer.cpp
core/util/flag.cpp
core/runtime/amd_blit_kernel.cpp
core/runtime/amd_blit_sdma.cpp
core/runtime/amd_cpu_agent.cpp
Expand Down Expand Up @@ -315,8 +307,8 @@ install ( TARGETS ${CORE_RUNTIME_TARGET} EXPORT ${CORE_RUNTIME_NAME}Targets
# TODO: Fix me for flat directory layout. Should be ${CMAKE_INSTALL_INCLUDEDIR}
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa COMPONENT dev )

# Legacy symlink.
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION hsa/include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa COMPONENT dirlink)
# Legacy symlink - not packaged (CPack is bugged until ~3.18, see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4637)
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION hsa/include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )

# Legacy symlinks.
if ( ${BUILD_SHARED_LIBS} )
Expand All @@ -335,7 +327,7 @@ install ( EXPORT ${CORE_RUNTIME_NAME}Targets

# Adds the target alias hsa-runtime64::hsa-runtime64 to the local cmake cache.
# This isn't necessary today. It's harmless preparation for some
# hypothetical future in which the we might be inluded by add_subdirectory()
# hypothetical future in which the we might be included by add_subdirectory()
# in some other project's cmake file. It allows uniform use of find_package
# and target_link_library() without regard to whether a target is external or
# a subdirectory of the current build.
Expand Down Expand Up @@ -388,76 +380,85 @@ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.")

## Only pack the "binary" and "dev" components, post install script will add the directory link.
set (CPACK_DEB_COMPONENT_INSTALL ON)
set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set (CPACK_COMPONENTS_ALL binary dev)

set ( CPACK_PACKAGE_NAME "hsa-rocr-dev" )
set ( CPACK_COMPONENTS_ALL binary dev )
set ( CPACK_DEB_COMPONENT_INSTALL ON)
set ( CPACK_RPM_COMPONENT_INSTALL ON)
set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." )
set ( CPACK_PACKAGE_VERSION ${PACKAGE_VERSION_STRING} )
set ( CPACK_PACKAGE_CONTACT "TODO Advanced Micro Devices, Inc." )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "AMD Heterogeneous System Architecture HSA - Linux HSA Runtime for Boltzmann (ROCm) platforms" )
set ( CPACK_COMPONENT_BINARY_DESCRIPTION "AMD Heterogeneous System Architecture HSA - Linux HSA Runtime for Boltzmann (ROCm) platforms" )
set ( CPACK_COMPONENT_DEV_DESCRIPTION "AMD Heterogeneous System Architecture HSA development package.\n This package contains the headers and cmake files for the hsa-rocr package." )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" )

## Process the Debian install/remove scripts to update the CPACK variables
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst.in DEBIAN/postinst @ONLY )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm.in DEBIAN/prerm @ONLY )

if ( DEFINED ENV{ROCM_LIBPATCH_VERSION} )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.$ENV{ROCM_LIBPATCH_VERSION}" )
message ( "Using CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}" )
endif()

# Debian package specific variables
set ( CPACK_DEBIAN_BINARY_PACKAGE_NAME "hsa-rocr")
set ( CPACK_DEBIAN_DEV_PACKAGE_NAME "hsa-rocr-dev")
if ( DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE} )
set ( CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE} )
else()
set ( CPACK_DEBIAN_PACKAGE_RELEASE "local" )
endif()
message ( "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" )
set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" )
set ( CPACK_DEBIAN_PACKAGE_DEPENDS "hsakmt-roct" )
set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCR-Runtime" )
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "DEBIAN/postinst;DEBIAN/prerm" )

# Declare that this package will replace functionality provided by hsa-ext-rocr-dev package
## Process the Debian install/remove scripts to update the CPACK variables
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/Binary/postinst.in DEBIAN/Binary/postinst @ONLY )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/Binary/prerm.in DEBIAN/Binary/prerm @ONLY )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/Dev/postinst.in DEBIAN/Dev/postinst @ONLY )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/Dev/prerm.in DEBIAN/Dev/prerm @ONLY )

set ( CPACK_DEBIAN_BINARY_PACKAGE_CONTROL_EXTRA "DEBIAN/Binary/postinst;DEBIAN/Binary/prerm" )
set ( CPACK_DEBIAN_DEV_PACKAGE_CONTROL_EXTRA "DEBIAN/Dev/postinst;DEBIAN/Dev/prerm" )

# Declare package relationships (hsa-ext-rocr-dev is a legacy package that we subsume)
set ( CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS "hsakmt-roct" )
set ( CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "hsa-rocr" )
if ( ROCM_DEP_ROCMCORE )
string ( APPEND PACK_DEBIAN_BINARY_PACKAGE_DEPENDS ", rocm-core" )
string ( APPEND CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ", rocm-core" )
endif()
set ( CPACK_DEBIAN_PACKAGE_BREAKS "hsa-ext-rocr-dev" )
set ( CPACK_DEBIAN_PACKAGE_PROVIDES "hsa-ext-rocr-dev" )
set ( CPACK_DEBIAN_PACKAGE_REPLACES "hsa-ext-rocr-dev" )
set ( CPACK_DEBIAN_PACKAGE_CONFLICTS "hsa-ext-rocr-dev" )

# RPM package specific variables
set ( CPACK_RPM_BINARY_PACKAGE_NAME "hsa-rocr" )
set ( CPACK_RPM_DEV_PACKAGE_NAME "hsa-rocr-devel" )
if ( DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE} )
set ( CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE} )
else()
set ( CPACK_RPM_PACKAGE_RELEASE "local" )
endif()

# 'dist' breaks manual builds on debian systems due to empty Provides
execute_process( COMMAND rpm --eval %{?dist}
RESULT_VARIABLE PROC_RESULT
OUTPUT_VARIABLE EVAL_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE )
message("RESULT_VARIABLE ${PROC_RESULT} OUTPUT_VARIABLE: ${EVAL_RESULT}")

if ( PROC_RESULT EQUAL "0" AND NOT EVAL_RESULT STREQUAL "" )
string ( APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}" )
endif()
string ( APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}" )
set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" )
message("CPACK_RPM_PACKAGE_RELEASE: ${CPACK_RPM_PACKAGE_RELEASE}")
set ( CPACK_RPM_PACKAGE_DEPENDS "hsakmt-roct" )

# Declare that this package will replace functionality provided by hsa-ext-rocr-dev package
set ( CPACK_RPM_PACKAGE_PROVIDES "hsa-ext-rocr-dev" )
set ( CPACK_RPM_PACKAGE_OBSOLETES "hsa-ext-rocr-dev" )
set ( CPACK_RPM_PACKAGE_CONFLICTS "hsa-ext-rocr-dev" )

## Process the Rpm install/remove scripts to update the CPACK variables
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/post.in" RPM/post @ONLY )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/postun.in" RPM/postun @ONLY )

set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post" )
set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/postun" )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/Binary/post.in" RPM/Binary/post @ONLY )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/Binary/postun.in" RPM/Binary/postun @ONLY )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/Dev/post.in" RPM/Dev/post @ONLY )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/Dev/postun.in" RPM/Dev/postun @ONLY )

set ( CPACK_RPM_BINARY_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/Binary/post" )
set ( CPACK_RPM_BINARY_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/Binary/postun" )
set ( CPACK_RPM_DEV_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/Dev/post" )
set ( CPACK_RPM_DEV_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/Dev/postun" )

# Declare package relationships (hsa-ext-rocr-dev is a legacy package that we subsume)
set ( CPACK_RPM_BINARY_PACKAGE_REQUIRES "hsakmt-roct" )
set ( CPACK_RPM_DEV_PACKAGE_REQUIRES "hsa-rocr" )
if ( ROCM_DEP_ROCMCORE )
string ( APPEND CPACK_RPM_BINARY_PACKAGE_REQUIRES " rocm-core" )
string ( APPEND CPACK_RPM_DEV_PACKAGE_REQUIRES " rocm-core" )
endif()
set ( CPACK_RPM_PACKAGE_PROVIDES "hsa-ext-rocr-dev hsa-rocr-dev" )
set ( CPACK_RPM_PACKAGE_OBSOLETES "hsa-ext-rocr-dev" )

## Include packaging
include ( CPack )
62 changes: 62 additions & 0 deletions src/DEBIAN/Binary/postinst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

################################################################################
##
## The University of Illinois/NCSA
## Open Source License (NCSA)
##
## Copyright (c) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
##
## Developed by:
##
## AMD Research and AMD HSA Software Development
##
## Advanced Micro Devices, Inc.
##
## www.amd.com
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to
## deal with 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:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimers.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimers in
## the documentation and/or other materials provided with the distribution.
## - Neither the names of Advanced Micro Devices, Inc,
## nor the names of its contributors may be used to endorse or promote
## products derived from this Software without specific prior written
## permission.
##
## 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 CONTRIBUTORS 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 WITH THE SOFTWARE.
##
################################################################################

set -e

# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build
do_ldconfig() {
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
echo @CPACK_PACKAGING_INSTALL_PREFIX@/lib > /etc/ld.so.conf.d/hsa-rocr.conf
ldconfig
fi
}

case "$1" in
( configure )
do_ldconfig
;;
( * )
exit 0
;;
esac
12 changes: 4 additions & 8 deletions src/DEBIAN/prerm.in → src/DEBIAN/Binary/prerm.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## The University of Illinois/NCSA
## Open Source License (NCSA)
##
## Copyright (c) 2020-2020, Advanced Micro Devices, Inc. All rights reserved.
## Copyright (c) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
##
## Developed by:
##
Expand All @@ -19,14 +19,14 @@
## of this software and associated documentation files (the "Software"), to
## deal with 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
## 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:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimers.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimers in
## the documentation and#or other materials provided with the distribution.
## the documentation and/or other materials provided with the distribution.
## - Neither the names of Advanced Micro Devices, Inc,
## nor the names of its contributors may be used to endorse or promote
## products derived from this Software without specific prior written
Expand All @@ -47,18 +47,14 @@ set -e
# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build
rm_ldconfig() {
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf
rm -f /etc/ld.so.conf.d/hsa-rocr.conf
ldconfig
fi
}

case "$1" in
( remove )
rm_ldconfig
# Workaround for CPACK directory symlink handling error.
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/hsa
;;
( purge )
;;
( * )
exit 0
Expand Down
18 changes: 3 additions & 15 deletions src/DEBIAN/postinst.in → src/DEBIAN/Dev/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## The University of Illinois/NCSA
## Open Source License (NCSA)
##
## Copyright (c) 2020-2020, Advanced Micro Devices, Inc. All rights reserved.
## Copyright (c) 2020-2021, Advanced Micro Devices, Inc. All rights reserved.
##
## Developed by:
##
Expand All @@ -19,14 +19,14 @@
## of this software and associated documentation files (the "Software"), to
## deal with 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
## 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:
##
## - Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimers.
## - Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimers in
## the documentation and#or other materials provided with the distribution.
## the documentation and/or other materials provided with the distribution.
## - Neither the names of Advanced Micro Devices, Inc,
## nor the names of its contributors may be used to endorse or promote
## products derived from this Software without specific prior written
Expand All @@ -44,24 +44,12 @@

set -e

# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build
do_ldconfig() {
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
echo @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf
ldconfig
fi
}

case "$1" in
( configure )
do_ldconfig
# Workaround for CPACK directory symlink handling error.
mkdir -p @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/include
ln -sf ../../include/hsa @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/include/hsa
;;
abort-upgrade|abort-remove|abort-deconfigure)
echo "$1"
;;
( * )
exit 0
;;
Expand Down
Loading

0 comments on commit fc99cf8

Please sign in to comment.