From 76d33c555f7c163422e45f23c4e41ab9d4d44e53 Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Tue, 4 Jun 2024 12:36:20 -0500 Subject: [PATCH] Changes to build ROCr & thunk (optionally tests) in rocr-runtime repo Create a new top-level CMakeLists.txt file to control building thunk and ROCr. kfdtest and rocrtest are built separately. Most of the cmake code that existed for thunk, ROCr, rocrtst and kfdtest still reside in their respective CMakeLists.txt files, except the CPack packaging directives which have been moved to the top-level CMakeLists.txt. Change-Id: I1a537359029504af8b1abb324bc6f0d75d98471e [ROCm/ROCR-Runtime commit: 662f6817d79853d96145a5c3278dda915f21b736] --- projects/rocr-runtime/CMakeLists.txt | 303 ++++++++++++++++++ .../DEBIAN/Binary/postinst.in | 5 +- .../hsa-runtime => }/DEBIAN/Binary/prerm.in | 4 +- .../hsa-runtime => }/DEBIAN/Dev/postinst.in | 0 .../hsa-runtime => }/DEBIAN/Dev/prerm.in | 0 projects/rocr-runtime/LICENSE.txt | 37 +++ projects/rocr-runtime/README.md | 166 ++++++++++ .../hsa-runtime => }/RPM/Binary/post.in | 0 .../hsa-runtime => }/RPM/Binary/postun.in | 0 .../{runtime/hsa-runtime => }/RPM/Dev/post.in | 0 .../hsa-runtime => }/RPM/Dev/postun.in | 0 .../hsa-runtime => }/RPM/hsa-rocr.spec.in | 6 + .../{runtime => }/cmake_modules/utils.cmake | 14 + .../rocr-runtime/libhsakmt/CMakeLists.txt | 174 +--------- .../rocr-runtime/libhsakmt/DEBIAN/control | 8 - .../libhsakmt/DEBIAN/x86_64-libhsakmt.conf | 1 - .../rocrtst/suites/test_common/CMakeLists.txt | 6 +- .../runtime/hsa-runtime/CMakeLists.txt | 128 -------- .../runtime/hsa-runtime/README.md | 239 -------------- .../hsa-runtime/cmake_modules/utils.cmake | 24 -- 20 files changed, 546 insertions(+), 569 deletions(-) create mode 100644 projects/rocr-runtime/CMakeLists.txt rename projects/rocr-runtime/{runtime/hsa-runtime => }/DEBIAN/Binary/postinst.in (95%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/DEBIAN/Binary/prerm.in (97%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/DEBIAN/Dev/postinst.in (100%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/DEBIAN/Dev/prerm.in (100%) create mode 100644 projects/rocr-runtime/LICENSE.txt create mode 100644 projects/rocr-runtime/README.md rename projects/rocr-runtime/{runtime/hsa-runtime => }/RPM/Binary/post.in (100%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/RPM/Binary/postun.in (100%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/RPM/Dev/post.in (100%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/RPM/Dev/postun.in (100%) rename projects/rocr-runtime/{runtime/hsa-runtime => }/RPM/hsa-rocr.spec.in (96%) rename projects/rocr-runtime/{runtime => }/cmake_modules/utils.cmake (94%) delete mode 100644 projects/rocr-runtime/libhsakmt/DEBIAN/control delete mode 100644 projects/rocr-runtime/libhsakmt/DEBIAN/x86_64-libhsakmt.conf delete mode 100644 projects/rocr-runtime/runtime/hsa-runtime/README.md diff --git a/projects/rocr-runtime/CMakeLists.txt b/projects/rocr-runtime/CMakeLists.txt new file mode 100644 index 0000000000..d5de377dad --- /dev/null +++ b/projects/rocr-runtime/CMakeLists.txt @@ -0,0 +1,303 @@ +################################################################################ +## +## The University of Illinois/NCSA +## Open Source License (NCSA) +## +## Copyright (c) 2014-2024, 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. +## +################################################################################ + + +cmake_minimum_required(VERSION 3.7) + +# Set the project name +project("rocr") + +# option(BUILD_TESTS "Build tests" OFF) + +function(add_rocm_subdir subdir subdir_assigns) + message("add_rocm_subdir() -- " ${subdir}) + # message(" subdir_assigns before:" ${subdir_assigns} "EOM") + string(STRIP "${subdir_assigns}" subdir_assigns) + message(" subdir_assigns:" ${subdir_assigns} "EOM") + + # if the subdir_assigns is defined and non-empty, then.. + + if(NOT "${subdir_assigns}" STREQUAL "") + foreach(assignment IN LISTS subdir_assigns) + # The format of each var should be VARNAME=VALUE + message("assignment: " ${assignment}) + string(REPLACE "=" ";" pair ${assignment}) + list(GET pair 0 var_name) + list(GET pair 1 var_value) + + # Set variable locally for this function and for the subdirectory + set(${var_name} "${var_value}") + message("The value of ${var_name} is: ${${var_name}}") + endforeach() + endif() + add_subdirectory(${subdir}) +endfunction() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") +include(utils) + + +## Get version strings +get_version("1.14.0") +if (${ROCM_PATCH_VERSION}) + set(VERSION_PATCH ${ROCM_PATCH_VERSION}) +endif() +set(SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") +set(PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_COMMIT_COUNT}") + +# Handling of BUILD_SHARED_LIBS in this top-level CMake: +# * Default is to build shared libraries +# * Except thunk will ignore this; it is always static +if (NOT DEFINED BUILD_SHARED_LIBS) + set (BUILD_SHARED_DEFAULT ON) +else() + set (BUILD_SHARED_DEFAULT OFF) +endif() + +# Build libhsakmt as static +set(SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) +set(BUILD_SHARED_LIBS OFF) +add_rocm_subdir(libhsakmt "${THUNK_DEFINITIONS}") +set_target_properties(hsakmt PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhsakmt/archive" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhsakmt/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libhsakmt/runtime") + +set (BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS}) +add_rocm_subdir(runtime/hsa-runtime "${ROCR_DEFINITIONS}") +set_target_properties(hsa-runtime64 PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rocr/archive" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rocr/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rocr/runtime") +add_dependencies(hsa-runtime64 hsakmt) + +# Optionally record the package's find module in the user's package cache. +if ( NOT DEFINED EXPORT_TO_USER_PACKAGE_REGISTRY ) + set ( EXPORT_TO_USER_PACKAGE_REGISTRY "off") +endif() +set ( EXPORT_TO_USER_PACKAGE_REGISTRY ${EXPORT_TO_USER_PACKAGE_REGISTRY} CACHE BOOL "Add cmake package config location to the user's cmake package registry.") +if(${EXPORT_TO_USER_PACKAGE_REGISTRY}) + # Enable writing to the registry + set(CMAKE_EXPORT_PACKAGE_REGISTRY ON) + # Generate a target file for the build + export(TARGETS ${CORE_RUNTIME_NAME} NAMESPACE ${CORE_RUNTIME_NAME}:: FILE ${CORE_RUNTIME_NAME}Targets.cmake) + # Record the package in the user's cache. + export(PACKAGE ${CORE_RUNTIME_NAME}) +endif() + + +## Packaging directives +set(CPACK_VERBOSE 1) +set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build") +set(ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.") + +# From libhsakmt: +set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "Default packaging prefix.") + +if(DEFINED CPACK_PACKAGING_INSTALL_PREFIX) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") +endif() + +# ASAN Package will have libraries and license file +if (ENABLE_ASAN_PACKAGING) + # ASAN Package requires only asan component with libraries and license file + set(CPACK_COMPONENTS_ALL asan) +else() + set(CPACK_COMPONENTS_ALL binary dev) +endif() +set(CPACK_COMPONENTS_GROUPING IGNORE) +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 "AMD HSA Support ") +set(CPACK_COMPONENT_DESCRIPTION "AMD Heterogeneous System Architecture HSA - Linux HSA Runtime for Boltzmann (ROCm) platforms\nIncludes HSAKMT, the user-mode API interfaces used to interact with the ROCk driver.\n Contains the headers, pkgonfig and\n cmake files for ROCT.") +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 rocr-runtime package.") +set(CPACK_COMPONENT_ASAN_DESCRIPTION "AMD Heterogeneous System Architecture HSA - Linux HSA instrumented libraries for Boltzmann (ROCm) platforms") + +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") +set(CPACK_DEBIAN_ASAN_PACKAGE_NAME "hsa-rocr-asan") +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_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCR-Runtime") + +## 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) +set(CPACK_DEBIAN_BINARY_PACKAGE_CONTROL_EXTRA "DEBIAN/Binary/postinst;DEBIAN/Binary/prerm") + +# Needed since some packages still say they need hsakmt-roct +set(CPACK_DEBIAN_PACKAGE_REPLACES "hsakmt-roct,hsa-ext-rocr-dev,hsa-runtime64") +set(CPACK_DEBIAN_PACKAGE_PROVIDES "hsakmt-roct,hsa-runtime64") +set(CPACK_RPM_PACKAGE_OBSOLETES "hsakmt-roct,hsakmt-roct-dev,hsakmt-roct,hsa-ext-rocr-dev,hsa-runtime64") +set(CPACK_RPM_PACKAGE_PROVIDES "hsakmt-roct,hsa-ext-rocr-dev,hsa-rocr-dev,hsa-runtime64") +set(CPACK_DEBIAN_DEV_PACKAGE_REPLACES "hsakmt-roct,hsakmt-roct-dev,hsa-runtime64") +set(CPACK_DEBIAN_DEV_PACKAGE_PROVIDES "hsakmt-roct,hsakmt-roct-dev,hsa-runtime64") +set(CPACK_RPM_DEV_PACKAGE_PROVIDES "hsakmt-roct,hsakmt-roct-dev,hsa-runtime64") + + +# package dependencies +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core") +set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") +# Setting devel package dependendent version +set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core, hsa-rocr, hsakmt-roct-dev") + +set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") + +set(CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS "libdrm-amdgpu-amdgpu1 | libdrm-amdgpu1, libnuma1, libelf1") +set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core-asan, libdrm-amdgpu-amdgpu1 | libdrm-amdgpu1, libnuma1, libelf1") +set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") + +set(CPACK_DEBIAN_BINARY_PACKAGE_RECOMMENDS "libdrm-amdgpu-amdgpu1") +if (ROCM_DEP_ROCMCORE) + string(APPEND CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS ", rocm-core") + string(APPEND CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ", rocm-core-asan") +endif() +if (HSA_DEP_ROCPROFILER_REGISTER) + string(APPEND CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS ", rocprofiler-register") +endif() +# Declare package relationships (hsa-ext-rocr-dev is a legacy package that we subsume) +set(CPACK_DEBIAN_PACKAGE_BREAKS "hsa-ext-rocr-dev") + +# RPM package specific variables +set(EL7_DISTRO "FALSE") +Checksetel7(EL7_DISTRO) +set(CPACK_RPM_BINARY_PACKAGE_NAME "hsa-rocr") +# Since we changed the package name to match RPM specs, take care of older builds that had -dev installed +# Also cover the fact that this now replaces the old binary package hsakmt-roct +set(CPACK_RPM_DEV_PACKAGE_OBSOLETES "hsakmt-roct-dev hsakmt-roct") + +set(CPACK_RPM_DEV_PACKAGE_NAME "hsa-rocr-devel") +set(CPACK_RPM_ASAN_PACKAGE_NAME "hsa-rocr-asan") +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() + +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_LICENSE "NCSA") + +## Process the Rpm install/remove scripts to update the CPACK variables +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) +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") + +# package dependencies +set(CPACK_RPM_DEV_PACKAGE_REQUIRES "rocm-core , hsa-rocr , hsakmt-roct-devel") + +# +if (${EL7_DISTRO} STREQUAL "TRUE") + set(CPACK_RPM_BINARY_PACKAGE_REQUIRES "libdrm-amdgpu, numactl-libs") + set(CPACK_RPM_ASAN_PACKAGE_REQUIRES "libdrm-amdgpu, numactl-libs, libdrm-amdgpu-devel") + set(CPACK_RPM_PACKAGE_REQUIRES "libdrm-amdgpu-devel") + string(APPEND CPACK_RPM_DEV_PACKAGE_REQUIRES ", libdrm-amdgpu-devel") + +else() + set(CPACK_RPM_BINARY_PACKAGE_REQUIRES "(libdrm-amdgpu or libdrm or libdrm_amdgpu1), (libnuma1 or numactl-libs)") + set(CPACK_RPM_ASAN_PACKAGE_REQUIRES "(libdrm-amdgpu or libdrm or libdrm_amdgpu1), (libnuma1 or numactl-libs), (libdrm-amdgpu-devel or libdrm-devel)") + set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/hsa-rocr.spec.in") + set(CPACK_RPM_PACKAGE_RECOMMENDS "libdrm-amdgpu, libdrm-amdgpu-devel") + + set(CPACK_RPM_PACKAGE_REQUIRES "(libdrm-amdgpu-devel or libdrm-devel)") + string(APPEND CPACK_RPM_DEV_PACKAGE_REQUIRES ", (libdrm-amdgpu-devel or libdrm-devel)") + set(CPACK_RPM_DEV_PACKAGE_RECOMMENDS "libdrm-amdgpu-devel") + set(CPACK_RPM_ASAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-devel") + +endif() + +if (ROCM_DEP_ROCMCORE) + string(APPEND CPACK_RPM_BINARY_PACKAGE_REQUIRES " rocm-core") + string(APPEND CPACK_RPM_ASAN_PACKAGE_REQUIRES " rocm-core-asan") +else() + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_DEV_PACKAGE_REQUIRES ${CPACK_RPM_DEV_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ${CPACK_DEBIAN_DEV_PACKAGE_DEPENDS}) + string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_ASAN_PACKAGE_REQUIRES}) + string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS}) +endif() +if (HSA_DEP_ROCPROFILER_REGISTER) + string(APPEND CPACK_RPM_BINARY_PACKAGE_REQUIRES " rocprofiler-register") +endif() + +if(NOT BUILD_SHARED_LIBS) + # Suffix package name with static + set(CPACK_RPM_STATIC_PACKAGE_NAME "hsa-rocr-static-devel") + set(CPACK_DEBIAN_STATIC_PACKAGE_NAME "hsa-rocr-static-dev") + set(CPACK_COMPONENT_STATIC_DESCRIPTION "HSA (Heterogenous System Architecture) core runtime - Linux static libraries") + set(CPACK_RPM_STATIC_PACKAGE_REQUIRES "${CPACK_RPM_BINARY_PACKAGE_REQUIRES}") + string(APPEND CPACK_RPM_STATIC_PACKAGE_REQUIRES " hsakmt-roct-devel") + set(CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS "${CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS}") + string(APPEND CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS ", hsakmt-roct-dev") +endif() + +## Include packaging +include(CPack) + +# static package generation +# Group binary and dev component to single package +if(NOT BUILD_SHARED_LIBS) + cpack_add_component_group("static") + cpack_add_component(binary GROUP static) + cpack_add_component(dev GROUP static) +endif() + +cpack_add_component(asan + DISPLAY_NAME "ASAN" + DESCRIPTION "ASAN libraries for rocr-runtime") diff --git a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/postinst.in b/projects/rocr-runtime/DEBIAN/Binary/postinst.in similarity index 95% rename from projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/postinst.in rename to projects/rocr-runtime/DEBIAN/Binary/postinst.in index fc8a185689..8a7b726924 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/postinst.in +++ b/projects/rocr-runtime/DEBIAN/Binary/postinst.in @@ -47,7 +47,7 @@ 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@/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/hsa-rocr.conf + echo @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/rocr-runtime.conf ldconfig fi } @@ -56,6 +56,9 @@ case "$1" in ( configure ) do_ldconfig ;; + ( abort-upgrade | abort-remove | abort-deconfigure ) + echo "$1" + ;; ( * ) exit 0 ;; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/prerm.in b/projects/rocr-runtime/DEBIAN/Binary/prerm.in similarity index 97% rename from projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/prerm.in rename to projects/rocr-runtime/DEBIAN/Binary/prerm.in index cbc66dff39..cc24b3ef48 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Binary/prerm.in +++ b/projects/rocr-runtime/DEBIAN/Binary/prerm.in @@ -47,7 +47,7 @@ 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.conf + rm -f /etc/ld.so.conf.d/rocr-runtime.conf ldconfig fi } @@ -56,6 +56,8 @@ case "$1" in ( remove | upgrade) rm_ldconfig ;; + ( purge ) + ;; ( * ) exit 0 ;; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Dev/postinst.in b/projects/rocr-runtime/DEBIAN/Dev/postinst.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Dev/postinst.in rename to projects/rocr-runtime/DEBIAN/Dev/postinst.in diff --git a/projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Dev/prerm.in b/projects/rocr-runtime/DEBIAN/Dev/prerm.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/DEBIAN/Dev/prerm.in rename to projects/rocr-runtime/DEBIAN/Dev/prerm.in diff --git a/projects/rocr-runtime/LICENSE.txt b/projects/rocr-runtime/LICENSE.txt new file mode 100644 index 0000000000..d0b749bc73 --- /dev/null +++ b/projects/rocr-runtime/LICENSE.txt @@ -0,0 +1,37 @@ +The University of Illinois/NCSA +Open Source License (NCSA) + +Copyright (c) 2014-2024, 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. diff --git a/projects/rocr-runtime/README.md b/projects/rocr-runtime/README.md new file mode 100644 index 0000000000..ea532c7a11 --- /dev/null +++ b/projects/rocr-runtime/README.md @@ -0,0 +1,166 @@ +# ROCR Runtime + +This ROCm Runtime (ROCr) repo combines 2 previously separate repos into a single repo: +- The HSA Runtime (`hsa-runtime`) for AMD GPU application development and +- The ROCt Thunk Library (`libhsakmt`), a "thunk" interface to the ROCm kernel driver (ROCk), used by the runtime. + +## Infrastructure + +The HSA runtime is a thin, user-mode API that exposes the necessary interfaces to access and interact with graphics hardware driven by the AMDGPU driver set and the ROCK kernel driver. Together they enable programmers to directly harness the power of AMD discrete graphics devices by allowing host applications to launch compute kernels directly to the graphics hardware. + +The capabilities expressed by the HSA Runtime API are: + +* Error handling +* Runtime initialization and shutdown +* System and agent information +* Signals and synchronization +* Architected dispatch +* Memory management +* HSA runtime fits into a typical software architecture stack. + +The HSA runtime provides direct access to the graphics hardware to give the programmer more control of the execution. An example of low level hardware access is the support of one or more user mode queues provides programmers with a low-latency kernel dispatch interface, allowing them to develop customized dispatch algorithms specific to their application. + +The HSA Architected Queuing Language is an open standard, defined by the HSA Foundation, specifying the packet syntax used to control supported AMD/ATI Radeon (c) graphics devices. The AQL language supports several packet types, including packets that can command the hardware to automatically resolve inter-packet dependencies (barrier AND & barrier OR packet), kernel dispatch packets and agent dispatch packets. + +In addition to user mode queues and AQL, the HSA runtime exposes various virtual address ranges that can be accessed by one or more of the system's graphics devices, and possibly the host. The exposed virtual address ranges either support a fine grained or a coarse grained access. Updates to memory in a fine grained region are immediately visible to all devices that can access it, but only one device can have access to a coarse grained allocation at a time. Ownership of a coarse grained region can be changed using the HSA runtime memory APIs, but this transfer of ownership must be explicitly done by the host application. + +Programmers should consult the HSA Runtime Programmer's Reference Manual for a full description of the HSA Runtime APIs, AQL and the HSA memory policy. + +## Known issues + +* Each HSA process creates an internal DMA queue, but there is a system-wide limit of four DMA queues. When the limit is reached HSA processes will use internal kernels for copies. + +## Artifacts produced by the build + +- **libhsakmt (ROCt)** - User-mode API interfaces for interacting with the ROCk driver +- **Runtime (ROCr)** - Core runtime supporting HSA standards +- **rocrtst** - Runtime test suites for HSA implementation validation and performance testing +- **kfdtest** - Validation tests for ROCt + +## Building the ROCR Runtime + +### Target platform requirements +Please see the [ROCm System requirements (Linux)](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html). + +Ensure you have the following installed: + +- CMake 3.7 or higher +- `libelf-dev` +- `g++` +- `libdrm-amdgpu-dev` or `libdrm-dev` +- `rocm-core` + +### ROCr & ROCt Build Instructions +1. **Clone this repository and cd into its root** +2. **Prepare the build directory** + ```sh + mkdir build && cd build + ``` +3. **Configure the build (example)** + ```sh + cmake -DCMAKE_INSTALL_PREFIX=/opt//llvm .. + ``` +4. **Compile the project** + ```sh + make + ``` +5. **Install the runtime** + ```sh + make install + ``` +6. **(Optional) Build packages** + ```sh + make package + ``` +#### Non-default CMake Build Options +- *Produce a release build instead of debug* + ```sh + -DCMAKE_BUILD_TYPE=Release + ``` + +- *Control whether libhsakmt and libhsa-runtime are shared or static* + The default (when `BUILD_SHARED_LIBS` is unset) is for libhsakmt to be static and libhsa-runtime to be shared. Setting `BUILD_SHARED_LIBS` to `OFF` will make both static and setting it to `ON` will make them both shared. + ```sh + -DBUILD_SHARED_LIBS=OFF # or ON for both libs shared + ``` +### Building the tests +#### rocrtst +1. **Go to rocrtst root** + ```sh + cd /rocrtst/suites/test_common + ``` +2. **Prepare the build directory** + ```sh + mkdir build && cd build + ``` +3. **Configure the build** + Example configuration: + ```sh + cmake \ + -DCMAKE_PREFIX_PATH=";" \ + -DROCM_DIR="$ROCM_INSTALL_PATH" \ + -DOPENCL_DIR="" \ + .. + ``` +4. **Compile the project** + ```sh + make + make rocrtst_kernels + ``` +5. ** Run the tests + Make sure libhsa-runtime.so is in the library path; e.g., + ```sh + $ LD_LIBRARY_PATH= ./rocrtst -h # See help options + ``` +#### kfdtest +1. **Go to kfdtest root** + ```sh + cd /libhsakmt/tests/kfdtest + ``` +2. **Prepare the build directory** + ```sh + mkdir build && cd build + ``` +3. **Configure the build** + Example configuration: + ```sh + cmake \ + -DCMAKE_PREFIX_PATH="" \ + -DROCM_DIR="$ROCM_INSTALL_PATH" \ + .. + ``` +4. **Compile the project** + ```sh + make + ``` +## Using the ROCR Runtime + +After installation, you can link against the runtime by using the provided CMake package configurations. For example, to use the ROCR runtime in your project: + +```cmake +find_package(hsa-runtime64 1.0 REQUIRED) +add_executable(MyApp main.cpp) +target_link_libraries(MyApp PRIVATE hsa-runtime64::hsa-runtime64) +``` +## Disclaimer +The information contained herein is for informational purposes only, and is +subject to change without notice. While every precaution has been taken in the +preparation of this document, it may contain technical inaccuracies, omissions +and typographical errors, and AMD is under no obligation to update or otherwise +correct this information. Advanced Micro Devices, Inc. makes no representations +or warranties with respect to the accuracy or completeness of the contents of +this document, and assumes no liability of any kind, including the implied +warranties of noninfringement, merchantability or fitness for particular +purposes, with respect to the operation or use of AMD hardware, software or +other products described herein. No license, including implied or arising by +estoppel, to any intellectual property rights is granted by this document. +Terms and limitations applicable to the purchase or use of AMD's products are +as set forth in a signed agreement between the parties or in AMD's Standard +Terms and Conditions of Sale. + +AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced +Micro Devices, Inc. Other product names used in this publication are for +identification purposes only and may be trademarks of their respective +companies. + +Copyright © 2014-2024 Advanced Micro Devices, Inc. All rights reserved. \ No newline at end of file diff --git a/projects/rocr-runtime/runtime/hsa-runtime/RPM/Binary/post.in b/projects/rocr-runtime/RPM/Binary/post.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/RPM/Binary/post.in rename to projects/rocr-runtime/RPM/Binary/post.in diff --git a/projects/rocr-runtime/runtime/hsa-runtime/RPM/Binary/postun.in b/projects/rocr-runtime/RPM/Binary/postun.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/RPM/Binary/postun.in rename to projects/rocr-runtime/RPM/Binary/postun.in diff --git a/projects/rocr-runtime/runtime/hsa-runtime/RPM/Dev/post.in b/projects/rocr-runtime/RPM/Dev/post.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/RPM/Dev/post.in rename to projects/rocr-runtime/RPM/Dev/post.in diff --git a/projects/rocr-runtime/runtime/hsa-runtime/RPM/Dev/postun.in b/projects/rocr-runtime/RPM/Dev/postun.in similarity index 100% rename from projects/rocr-runtime/runtime/hsa-runtime/RPM/Dev/postun.in rename to projects/rocr-runtime/RPM/Dev/postun.in diff --git a/projects/rocr-runtime/runtime/hsa-runtime/RPM/hsa-rocr.spec.in b/projects/rocr-runtime/RPM/hsa-rocr.spec.in similarity index 96% rename from projects/rocr-runtime/runtime/hsa-runtime/RPM/hsa-rocr.spec.in rename to projects/rocr-runtime/RPM/hsa-rocr.spec.in index 3ccc64efc7..0ad57e5628 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/RPM/hsa-rocr.spec.in +++ b/projects/rocr-runtime/RPM/hsa-rocr.spec.in @@ -70,12 +70,18 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT @RPM_SYMLINK_POSTINSTALL@ @CPACK_RPM_SPEC_POSTINSTALL@ +%posttrans +@CPACK_RPM_SPEC_POSTTRANS@ + %postun @CPACK_RPM_SPEC_POSTUNINSTALL@ %pre @CPACK_RPM_SPEC_PREINSTALL@ +%pretrans +@CPACK_RPM_SPEC_PRETRANS@ + %preun @CPACK_RPM_SPEC_PREUNINSTALL@ diff --git a/projects/rocr-runtime/runtime/cmake_modules/utils.cmake b/projects/rocr-runtime/cmake_modules/utils.cmake similarity index 94% rename from projects/rocr-runtime/runtime/cmake_modules/utils.cmake rename to projects/rocr-runtime/cmake_modules/utils.cmake index 415e2d757f..cfeae56ca3 100644 --- a/projects/rocr-runtime/runtime/cmake_modules/utils.cmake +++ b/projects/rocr-runtime/cmake_modules/utils.cmake @@ -217,3 +217,17 @@ function ( listsubdirs DIRPATH SUBDIRECTORIES ) endforeach() set (${SUBDIRECTORIES} ${FOLDERS} PARENT_SCOPE) endfunction() + +## Sets el7 flag to be true +function (Checksetel7 EL7_DISTRO) +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 "") + if ("${EVAL_RESULT}" STREQUAL ".el7") + set (${EL7_DISTRO} TRUE PARENT_SCOPE) + endif() +endif() +endfunction() diff --git a/projects/rocr-runtime/libhsakmt/CMakeLists.txt b/projects/rocr-runtime/libhsakmt/CMakeLists.txt index 4ebfb4b6aa..4db94f1875 100644 --- a/projects/rocr-runtime/libhsakmt/CMakeLists.txt +++ b/projects/rocr-runtime/libhsakmt/CMakeLists.txt @@ -36,7 +36,6 @@ project ( ${HSAKMT_TARGET} VERSION 1.9.0) if ( NOT DEFINED BUILD_SHARED_LIBS ) set ( BUILD_SHARED_LIBS "off" ) endif() -set ( BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Build shared library (.so) or not.") # Optionally, build HSAKMT with ccache. set(ROCM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build") @@ -49,7 +48,7 @@ if (ROCM_CCACHE_BUILD) endif() # if (CCACHE_PROGRAM) endif() # if (ROCM_CCACHE_BUILD) -list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) +list( PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) ## Include common cmake modules include ( utils ) @@ -187,30 +186,20 @@ if( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) set ( CMAKE_INSTALL_PREFIX "/opt/rocm" ) endif() set ( CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "Default installation directory." FORCE ) -set ( CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "Default packaging prefix." ) -set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators." ) - -## set components -if ( ENABLE_ASAN_PACKAGING ) - # ASAN Package requires only asan component with libraries and license file - set ( CPACK_COMPONENTS_ALL asan ) -else() - set ( CPACK_COMPONENTS_ALL devel ) -endif() # Installs binaries and exports the library usage data to ${HSAKMT_TARGET}Targets install ( TARGETS ${HSAKMT_TARGET} EXPORT ${HSAKMT_TARGET}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT asan ) install ( TARGETS ${HSAKMT_TARGET} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel ) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT binary + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT binary ) -#install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT devel ) +#install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT dev ) # Install public headers install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${HSAKMT_TARGET} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT devel PATTERN "linux" EXCLUDE ) + COMPONENT dev PATTERN "linux" EXCLUDE ) # Option to build header path migration helpers. option(INCLUDE_PATH_COMPATIBILITY "Generate backward compatible headers and include paths. Use of these headers will warn when included." OFF) @@ -237,7 +226,7 @@ install ( EXPORT ${HSAKMT_TARGET}Targets FILE ${HSAKMT_TARGET}Targets.cmake NAMESPACE ${HSAKMT_TARGET}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${HSAKMT_TARGET} - COMPONENT devel) + COMPONENT dev) # Adds the target alias hsakmt::hsakmt to the local cmake cache. # This isn't necessary today. It's harmless preparation for some @@ -265,7 +254,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${HSAKMT_TARGET}-config-version.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${HSAKMT_TARGET} - COMPONENT devel) + COMPONENT dev) # Optionally record the package's find module in the user's package cache. if ( NOT DEFINED EXPORT_TO_USER_PACKAGE_REGISTRY ) @@ -286,161 +275,18 @@ endif() # TODO: Add support for relocatable packages. configure_file ( libhsakmt.pc.in libhsakmt.pc @ONLY ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/libhsakmt.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT devel) +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/libhsakmt.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT dev) ########################### # Packaging directives ########################### # Use component packaging -set(CPACK_COMPONENTS_GROUPING IGNORE) -set(CPACK_DEB_COMPONENT_INSTALL ON) -set(CPACK_RPM_COMPONENT_INSTALL ON) -set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") -set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) -set(CPACK_PACKAGE_CONTACT "AMD GFX mailing list ") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md") -set(CPACK_COMPONENT_DESCRIPTION "HSAKMT development package.\n This package includes the user-mode API interfaces\nused to interact with the ROCk driver.\n This package contains the headers, pkgonfig and\n cmake files for the ROCT package.") + set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.") # Install License file -install ( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT devel) +install ( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT dev) if ( ENABLE_ASAN_PACKAGING ) install ( FILES ${CPACK_RESOURCE_FILE_LICENSE} DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan COMPONENT asan) endif() - -# Make proper version for appending -# Default Value is 99999, setting it first -set(ROCM_VERSION_FOR_PACKAGE "99999") -if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) - set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION}) -endif() - -# Prepare final version for the CPACK use -set(PACKAGE_VERSION_STR "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") -set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION_STR}") - -# Debian package specific variables -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm/ROCT-Thunk-Interface") -set(CPACK_DEBIAN_PACKAGE_NAME "hsakmt-roct-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() -## 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 ) -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "DEBIAN/postinst;DEBIAN/prerm") -# Needed since some packages still say they need hsakmt-roct -set(CPACK_DEBIAN_PACKAGE_REPLACES "hsakmt-roct") -set(CPACK_DEBIAN_PACKAGE_PROVIDES "hsakmt-roct") -set(CPACK_RPM_PACKAGE_OBSOLETES "hsakmt-roct") -set(CPACK_RPM_PACKAGE_PROVIDES "hsakmt-roct") - -# Debian devel component specific flags -set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME "hsakmt-roct-dev") -set(CPACK_DEBIAN_DEVEL_PACKAGE_REPLACES "hsakmt-roct") -set(CPACK_DEBIAN_DEVEL_PACKAGE_PROVIDES "hsakmt-roct") -set(CPACK_RPM_DEVEL_PACKAGE_PROVIDES "hsakmt-roct") - -# Debian package specific variable for ASAN -set(CPACK_DEBIAN_ASAN_PACKAGE_NAME "hsakmt-roct-asan" ) - -## 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 ) -## RPM package specific variables -set ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post" ) -set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/postun" ) - -if(DEFINED CPACK_PACKAGING_INSTALL_PREFIX) - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") -endif() -set(CPACK_RPM_PACKAGE_NAME "hsakmt-roct-devel") -set(CPACK_RPM_PACKAGE_LICENSE "MIT") - -# RPM package specific variable for ASAN -set(CPACK_RPM_ASAN_PACKAGE_NAME "hsakmt-roct-asan" ) - -# RPM package devel specific variable -set(CPACK_RPM_DEVEL_PACKAGE_NAME "hsakmt-roct-devel") -# Since we changed the package name to match RPM specs, take care of older builds that had -dev installed -# Also cover the fact that this now replaces the old binary package hsakmt-roct -set(CPACK_RPM_PACKAGE_OBSOLETES "hsakmt-roct-dev hsakmt-roct") -set(CPACK_RPM_DEVEL_PACKAGE_OBSOLETES "hsakmt-roct-dev hsakmt-roct") - -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() -## Specify a RPM SPEC template -# This template was generated by using "CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE" -# but I've modified it to support CPACK_RPM_PACKAGE_RECOMMENDS for EL8+ and SLE -set ( CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/${CPACK_RPM_PACKAGE_NAME}.spec.in" ) - -# '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() - -# Setting devel package dependendent version -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core") -set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") -set(CPACK_DEBIAN_PACKAGE_REPLACES "hsakmt-roct") -set(CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core") -set(CPACK_DEBIAN_DEVEL_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") -set(CPACK_DEBIAN_DEVEL_PACKAGE_REPLACES "hsakmt-roct") - -# Debian package specific variable for ASAN -set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "libdrm-amdgpu-dev | libdrm-dev, rocm-core-asan") -set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-dev") - -set(CPACK_RPM_PACKAGE_REQUIRES "rocm-core") -set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES "rocm-core") -# RPM package specific variable for ASAN -set(CPACK_RPM_ASAN_PACKAGE_REQUIRES "rocm-core-asan") - -# NOTE: CentOS/RHEL <8 and SUSE <10 do not have support for rpm recommends, -# so HSAKMT_REQUIRES_LIBDRM should be defined when building EL7 to avoid -# producing binaries which do not install on CentOS7 or RHEL7 -if(HSAKMT_REQUIRES_LIBDRM) - string ( APPEND CPACK_RPM_PACKAGE_REQUIRES ", libdrm-amdgpu-devel" ) - string ( APPEND CPACK_RPM_DEVEL_PACKAGE_REQUIRES ", libdrm-amdgpu-devel" ) - string ( APPEND CPACK_RPM_ASAN_PACKAGE_REQUIRES ", libdrm-amdgpu-devel" ) -else() - string ( APPEND CPACK_RPM_PACKAGE_REQUIRES ", (libdrm-amdgpu-devel or libdrm-devel)" ) - string ( APPEND CPACK_RPM_DEVEL_PACKAGE_REQUIRES ", (libdrm-amdgpu-devel or libdrm-devel)" ) - string ( APPEND CPACK_RPM_ASAN_PACKAGE_REQUIRES ", (libdrm-amdgpu-devel or libdrm-devel)" ) - set(CPACK_RPM_PACKAGE_RECOMMENDS "libdrm-amdgpu-devel" ) - set(CPACK_RPM_DEVEL_PACKAGE_RECOMMENDS "libdrm-amdgpu-devel" ) - set(CPACK_RPM_ASAN_PACKAGE_RECOMMENDS "libdrm-amdgpu-devel" ) -endif() - -# Set the names now using CPACK utility -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") - -# Remove dependency on rocm-core if -DROCM_DEP_ROCMCORE=ON not given to cmake -if(NOT ROCM_DEP_ROCMCORE) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_RPM_DEVEL_PACKAGE_REQUIRES ${CPACK_RPM_DEVEL_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core" "" CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS ${CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS}) - string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_ASAN_PACKAGE_REQUIRES}) - string(REGEX REPLACE ",? ?rocm-core-asan" "" CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS}) -endif() - -include(CPack) - -cpack_add_component(asan - DISPLAY_NAME "ASAN" - DESCRIPTION "ASAN libraries for the LIBHSAKMT") diff --git a/projects/rocr-runtime/libhsakmt/DEBIAN/control b/projects/rocr-runtime/libhsakmt/DEBIAN/control deleted file mode 100644 index fd01eac6bd..0000000000 --- a/projects/rocr-runtime/libhsakmt/DEBIAN/control +++ /dev/null @@ -1,8 +0,0 @@ -Package: hsakmt-rocm-dev -Architecture: $arch -Maintainer: Advanced Micro Devices Inc. -Depends:libpci3, libnuma1 -Priority: optional -Version: $version -Description: Thunk library for AMD KFD - diff --git a/projects/rocr-runtime/libhsakmt/DEBIAN/x86_64-libhsakmt.conf b/projects/rocr-runtime/libhsakmt/DEBIAN/x86_64-libhsakmt.conf deleted file mode 100644 index a4551d4820..0000000000 --- a/projects/rocr-runtime/libhsakmt/DEBIAN/x86_64-libhsakmt.conf +++ /dev/null @@ -1 +0,0 @@ -/opt/rocm/lib diff --git a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt index 81ed2b4a6b..d5bc906b21 100755 --- a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt +++ b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt @@ -65,7 +65,7 @@ set ( CPACK_DEBIAN_PACKAGE_RELEASE "local" ) if( DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE} ) set ( CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE} ) endif() -set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core") +set (CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-core,hsa-rocr") ## RPM package variables set ( CPACK_RPM_PACKAGE_RELEASE "local" ) @@ -80,7 +80,7 @@ execute_process( COMMAND rpm --eval %{?dist} if ( PROC_RESULT EQUAL "0" AND NOT EVAL_RESULT STREQUAL "" ) string ( APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}" ) endif() -set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core") +set (CPACK_RPM_PACKAGE_REQUIRES "rocm-core,hsa-rocr") set(DEFAULT_TARGETS "gfx700;gfx701;gfx702;gfx801;gfx802;gfx803;gfx805;gfx810" "gfx900;gfx902;gfx904;gfx906;gfx908;gfx909;gfx90a;gfx90c;gfx940;gfx941;gfx942" @@ -104,7 +104,7 @@ endif() # # Required Defines first: -find_package(hsa-runtime64 REQUIRED ) +find_package(hsa-runtime64 REQUIRED) find_package(rocm_smi REQUIRED) set (ONLY64STR "64") diff --git a/projects/rocr-runtime/runtime/hsa-runtime/CMakeLists.txt b/projects/rocr-runtime/runtime/hsa-runtime/CMakeLists.txt index e8b2cef650..64122a3765 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/CMakeLists.txt +++ b/projects/rocr-runtime/runtime/hsa-runtime/CMakeLists.txt @@ -84,18 +84,9 @@ if (ROCM_CCACHE_BUILD) endif() # if (CCACHE_PROGRAM) endif() # if (ROCM_CCACHE_BUILD) -## Get version strings -get_version ( "1.14.0" ) -if ( ${ROCM_PATCH_VERSION} ) - set ( VERSION_PATCH ${ROCM_PATCH_VERSION}) -endif() -set ( SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) -set ( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_COMMIT_COUNT}" ) - ## Find external dependencies. find_package(PkgConfig) find_package(LibElf REQUIRED) -find_package(hsakmt 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm) pkg_check_modules(drm REQUIRED IMPORTED_TARGET libdrm) ## Create the rocr target. @@ -415,123 +406,4 @@ if( NOT ${BUILD_SHARED_LIBS} ) COMPONENT dev) endif() -# Optionally record the package's find module in the user's package cache. -if ( NOT DEFINED EXPORT_TO_USER_PACKAGE_REGISTRY ) - set ( EXPORT_TO_USER_PACKAGE_REGISTRY "off" ) -endif() -set ( EXPORT_TO_USER_PACKAGE_REGISTRY ${EXPORT_TO_USER_PACKAGE_REGISTRY} CACHE BOOL "Add cmake package config location to the user's cmake package registry.") -if(${EXPORT_TO_USER_PACKAGE_REGISTRY}) - # Enable writing to the registry - set(CMAKE_EXPORT_PACKAGE_REGISTRY ON) - # Generate a target file for the build - export(TARGETS ${CORE_RUNTIME_NAME} NAMESPACE ${CORE_RUNTIME_NAME}:: FILE ${CORE_RUNTIME_NAME}Targets.cmake) - # Record the package in the user's cache. - export(PACKAGE ${CORE_RUNTIME_NAME}) -endif() -## Packaging directives -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_COMPONENTS_ALL binary dev ) -# ASAN Package will have libraries and license file -if(ENABLE_ASAN_PACKAGING) - set(CPACK_COMPONENTS_ALL asan) -endif() -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 "AMD HSA Support ") -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_COMPONENT_ASAN_DESCRIPTION "AMD Heterogeneous System Architecture HSA - Linux HSA instrumented libraries for Boltzmann (ROCm) platforms" ) -set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" ) - -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") -set ( CPACK_DEBIAN_ASAN_PACKAGE_NAME "hsa-rocr-asan") -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_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCR-Runtime" ) - -## 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 ) -set ( CPACK_DEBIAN_BINARY_PACKAGE_CONTROL_EXTRA "DEBIAN/Binary/postinst;DEBIAN/Binary/prerm" ) - -# package dependencies -set( CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS "libdrm-amdgpu-amdgpu1 | libdrm-amdgpu1, libnuma1, libelf1") -set( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "libdrm-amdgpu-amdgpu1 | libdrm-amdgpu1, libnuma1, libelf1") -set( CPACK_DEBIAN_BINARY_PACKAGE_RECOMMENDS "libdrm-amdgpu-amdgpu1") -set ( CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "hsa-rocr, hsakmt-roct-dev" ) -if ( ROCM_DEP_ROCMCORE ) - string ( APPEND CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS ", rocm-core" ) - string ( APPEND CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ", rocm-core-asan" ) -endif() -if ( HSA_DEP_ROCPROFILER_REGISTER ) - string ( APPEND CPACK_DEBIAN_BINARY_PACKAGE_DEPENDS ", rocprofiler-register" ) -endif() -# Declare package relationships (hsa-ext-rocr-dev is a legacy package that we subsume) -set ( CPACK_DEBIAN_PACKAGE_BREAKS "hsa-ext-rocr-dev" ) -set ( CPACK_DEBIAN_PACKAGE_REPLACES "hsa-ext-rocr-dev" ) - -# RPM package specific variables -set ( EL7_DISTRO "FALSE" ) -checksetel7(EL7_DISTRO) -set ( CPACK_RPM_BINARY_PACKAGE_NAME "hsa-rocr" ) -set ( CPACK_RPM_DEV_PACKAGE_NAME "hsa-rocr-devel" ) -set ( CPACK_RPM_ASAN_PACKAGE_NAME "hsa-rocr-asan" ) -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() - -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_LICENSE "NCSA" ) - -## Process the Rpm install/remove scripts to update the CPACK variables -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 ) -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" ) - -# package dependencies -if (${EL7_DISTRO} STREQUAL "TRUE") - set ( CPACK_RPM_BINARY_PACKAGE_REQUIRES "libdrm-amdgpu, numactl-libs" ) - set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES "libdrm-amdgpu, numactl-libs" ) -else() - set ( CPACK_RPM_BINARY_PACKAGE_REQUIRES "(libdrm-amdgpu or libdrm or libdrm_amdgpu1), (libnuma1 or numactl-libs)" ) - set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES "(libdrm-amdgpu or libdrm or libdrm_amdgpu1), (libnuma1 or numactl-libs)" ) - set ( CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/hsa-rocr.spec.in" ) - set ( CPACK_RPM_PACKAGE_RECOMMENDS "libdrm-amdgpu" ) -endif() -set ( CPACK_RPM_DEV_PACKAGE_REQUIRES "hsa-rocr , hsakmt-roct-devel" ) -if ( ROCM_DEP_ROCMCORE ) - string ( APPEND CPACK_RPM_BINARY_PACKAGE_REQUIRES " rocm-core" ) - string ( APPEND CPACK_RPM_ASAN_PACKAGE_REQUIRES " rocm-core-asan" ) -endif() -if ( HSA_DEP_ROCPROFILER_REGISTER ) - string ( APPEND CPACK_RPM_BINARY_PACKAGE_REQUIRES " rocprofiler-register" ) -endif() -# Declare package relationships (hsa-ext-rocr-dev is a legacy package that we subsume) -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 ) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/README.md b/projects/rocr-runtime/runtime/hsa-runtime/README.md deleted file mode 100644 index 736e68f846..0000000000 --- a/projects/rocr-runtime/runtime/hsa-runtime/README.md +++ /dev/null @@ -1,239 +0,0 @@ -# Package Contents - -This directory contains the ROC Runtime source code based on the HSA Runtime -but modified to support AMD/ATI discrete GPUs. - -## Source & Include Directories - -`core` - Contains the source code for AMD's implementation of the core HSA - Runtime API's. - -`cmake_modules` - CMake support modules and files. - -`inc` - Contains the public and AMD specific header files exposing the HSA - Runtime`s interfaces. - -`libamdhsacode` - Code object definitions and interface. - -`loader` - Used to load code objects. - -`utils` - Utilities required to build the core runtime. - -## Build Environment - -CMake build framework is used to build the ROC runtime. The minimum version is -3.7. - -Obtain cmake infrastructure: - -Export cmake bin into your PATH - -## Package Dependencies - -The following support packages are required to successfully build the runtime: - -* `libelf-dev` -* `g++` - -## Building the Runtime - -To build the runtime a compatible version of the `libhsakmt` library and the -`hsakmt.h` header file must be available. The latest version of these files -can be obtained from the ROCT-Thunk-Interface repository, available here: - - - -As of ROCm release 3.7 `libhsakmt` development packages now include a CMake -package config file. The runtime will now locate `libhsakmt` via `find_package` -if `libhsakmt` is installed to a standard location. For installations that do -not use ROCm standard paths set CMake variables `CMAKE_PREFIX_PATH` or -`hsakmt_DIR` to override `find_package` search paths. - -As of ROCm release 3.7 the runtime includes an optional image support module -(previously `hsa-ext-rocr-dev`). By default this module is included in builds of -the runtime. The image module may be excluded the runtime by setting -CMake variable `IMAGE_SUPPORT` to `OFF`. - -When building the optional image module additional build dependencies are -required. An AMDGCN compatible clang and device library must be installed -to build the image module. The latest version of these requirements can be -obtained from the ROCm package repository -(see: -) -The latest source for these projects may be found here: - - - - - -Additionally `xxd` must be installed. - -The runtime optionally supports use of the cmake user package registry. By -default the registry is not modified. Set CMake variable -`EXPORT_TO_USER_PACKAGE_REGISTRY` to `ON` to enable updating the package -registry. - -For example, to build, install, and produce packages on a system with standard -ROCm packages installed, execute the following from `src/`: - -```bash -mkdir build -cd build -cmake -DCMAKE_INSTALL_PREFIX=/opt/rocm .. -make -make install -make package -``` - -Example with a custom installation path, build dependency path, and options: - -```bash -cmake -DIMAGE_SUPPORT=OFF \ - -DEXPORT_TO_USER_PACKAGE_REGISTRY=ON \ - -DCMAKE_VERBOSE_MAKEFILE=1 \ - -DCMAKE_PREFIX_PATH= \ - -DCMAKE_INSTALL_PATH= \ - .. -``` - -Alternately `ccmake` and `cmake-gui` are supported: - -```bash -mkdir build -cd build -ccmake .. -press c to configure -populate variables as desired -press c again -press g to generate and exit -make -``` - -## Building Against the Runtime - -The runtime provides a CMake package config file, installed by default to -`/opt/rocm/lib/cmake/hsa-runtime64`. The runtime exports CMake target -`hsa-runtime64` in namespace `hsa-runtime64`. A CMake project (`Foo`) using the -runtime may locate, include, and link the runtime with the following template: - -```cmake -# Add /opt/rocm to CMAKE_PREFIX_PATH. - -find_package(hsa-runtime64 1.0 REQUIRED) -... -add_library(Foo ...) -... -target_link_libraries(Foo PRIVATE hsa-runtime64::hsa-runtime64) -``` - -## Specs - - - -HSA Runtime Specification 1.1 - -HSA Programmer Reference Manual Specification 1.1 - -HSA Platform System Architecture Specification 1.1 - -## Runtime Design Overview - -The AMD ROC runtime consists of three primary layers: - -* C interface adaptors -* C++ interfaces classes and common functions -* AMD device specific implementations - -Additionally the runtime is dependent on a small utility library which provides -simple common functions, limited operating system and compiler abstraction, as -well as atomic operation interfaces. - -## C Interface Adaptors - -Files: - -* `hsa.h`(cpp) -* `hsa_ext_interface.h`(cpp) - -The C interface layer provides C99 APIs as defined in the HSA Runtime -Specification 1.1. The interfaces and default definitions for the standard -extensions are also provided. The interface functions simply forward to a -function pointer table defined here. The table is initialized to point to -default definitions, which simply return an appropriate error code. If -available the extension library is loaded as part of runtime initialization and -the table is updated to point into the extension library. - -## C++ Interfaces Classes & Common Functions - -Files: - -* `runtime.h`(cpp) -* `agent.h` -* `queue.h` -* `signal.h` -* `memory_region.h`(cpp) -* `checked.h` -* `memory_database.h`(cpp) -* `default_signal.h`(cpp) - -The C++ interface layer provides abstract interface classes encapsulating -commands to HSA Signals, Agents, and Queues. This layer also contains the -implementation of device independent commands, such as `hsa_init` and -`hsa_system_get_info`, and a default signal and queue implementation. - -## Device Specific Implementations - -Files: - -* `amd_cpu_agent.h`(cpp) -* `amd_gpu_agent.h`(cpp) -* `amd_hw_aql_command_processor.h`(cpp) -* `amd_memory_region.h`(cpp) -* `amd_memory_registration.h`(cpp) -* `amd_topology.h`(cpp) -* `host_queue.h`(cpp) -* `interrupt_signal.h`(cpp) -* `hsa_ext_private_amd.h`(cpp) - -The device specific layer contains implementations of the C++ interface classes -which implement HSA functionality for ROCm supported devices. - -## Implemented Functionality - -* The following queries are not implemented: - - * `hsa_code_symbol_get_info`: - * `HSA_CODE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION` - * `hsa_executable_symbol_get_info`: - * `HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_OBJECT` - * `HSA_EXECUTABLE_SYMBOL_INFO_INDIRECT_FUNCTION_CALL_CONVENTION` - -## Known Issues - -* `hsa_agent_get_exception_policies` is not implemented. -* `hsa_system_get_extension_table` is not implemented for - `HSA_EXTENSION_AMD_PROFILER`. - -## Disclaimer - -The information contained herein is for informational purposes only, and is -subject to change without notice. While every precaution has been taken in the -preparation of this document, it may contain technical inaccuracies, omissions -and typographical errors, and AMD is under no obligation to update or otherwise -correct this information. Advanced Micro Devices, Inc. makes no representations -or warranties with respect to the accuracy or completeness of the contents of -this document, and assumes no liability of any kind, including the implied -warranties of noninfringement, merchantability or fitness for particular -purposes, with respect to the operation or use of AMD hardware, software or -other products described herein. No license, including implied or arising by -estoppel, to any intellectual property rights is granted by this document. -Terms and limitations applicable to the purchase or use of AMD's products are -as set forth in a signed agreement between the parties or in AMD's Standard -Terms and Conditions of Sale. - -AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced -Micro Devices, Inc. Other product names used in this publication are for -identification purposes only and may be trademarks of their respective -companies. - -Copyright © 2014-2021 Advanced Micro Devices, Inc. All rights reserved. diff --git a/projects/rocr-runtime/runtime/hsa-runtime/cmake_modules/utils.cmake b/projects/rocr-runtime/runtime/hsa-runtime/cmake_modules/utils.cmake index 627f0b26c7..0e5b9df683 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/cmake_modules/utils.cmake +++ b/projects/rocr-runtime/runtime/hsa-runtime/cmake_modules/utils.cmake @@ -206,28 +206,4 @@ function ( get_version DEFAULT_VERSION_STRING ) endfunction() -## Collects subdirectory names and returns them in a list -function ( listsubdirs DIRPATH SUBDIRECTORIES ) - file( GLOB CONTENTS RELATIVE ${DIRPATH} "${DIRPATH}/*" ) - set ( FOLDERS, "" ) - foreach( ITEM IN LISTS CONTENTS) - if( IS_DIRECTORY "${DIRPATH}/${ITEM}" ) - list( APPEND FOLDERS ${ITEM} ) - endif() - endforeach() - set (${SUBDIRECTORIES} ${FOLDERS} PARENT_SCOPE) -endfunction() -## Sets el7 flag to be true -function ( Checksetel7 EL7_DISTRO ) -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 "") - if( "${EVAL_RESULT}" STREQUAL ".el7") - set (${EL7_DISTRO} TRUE PARENT_SCOPE) - endif() -endif() -endfunction()