Update runtime CMakeLists.txt and utility files to support top level CMakeLists.txt build.

Change-Id: I4a0eb512af82908a24f2d1964b201c28023ccae5


[ROCm/ROCR-Runtime commit: 809356e0b5]
This commit is contained in:
James Edwards
2016-09-27 10:11:55 -05:00
committed by JamesAdrian Edwards
parent 3ebe9fab51
commit b9b6f69860
9 changed files with 177 additions and 87 deletions
@@ -42,29 +42,81 @@
cmake_minimum_required(VERSION 2.8)
project(hsa-runtime)
## Set core runtime module name and project name.
set ( CORE_RUNTIME_NAME "hsa-runtime" )
set ( CORE_RUNTIME_COMPONENT "lib${CORE_RUNTIME_NAME}" )
set ( CORE_RUNTIME_TARGET "${CORE_RUNTIME_NAME}64" )
project( ${CORE_RUNTIME_TARGET} )
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
add_definitions (-D HSA_DEPRECATED=)
add_definitions ( -D HSA_DEPRECATED= )
include(utils)
include(hsa_common)
include ( utils )
include ( hsa_common )
if(NOT DEFINED VERSION_STRING)
set (VERSION_STRING "1")
## Parse the package version
if( NOT DEFINED VERSION_STRING )
set ( VERSION_STRING "1.0.0" )
endif()
parse_version(${VERSION_STRING})
## Parse the package version
parse_version ( ${VERSION_STRING} )
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libamdhsacode)
include_directories(${HSATHK_BUILD_INC_PATH})
set ( PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} )
set ( PACKAGE_VERSION_MINOR ${VERSION_MINOR} )
set ( PACKAGE_VERSION_PATCH ${VERSION_PATCH} )
link_directories (${HSATHK_BUILD_LIB_PATH})
## Parse the library version
if( NOT DEFINED RUNTIME_VERSION_STRING )
set ( RUNTIME_VERSION_STRING "1" )
endif()
add_subdirectory(libamdhsacode)
add_subdirectory(loader)
add_subdirectory(core)
parse_version ( ${RUNTIME_VERSION_STRING} )
set ( RUNTIME_VERSION_MAJOR ${VERSION_MAJOR} )
set ( RUNTIME_VERSION_MINOR ${VERSION_MINOR} )
set ( RUNTIME_VERSION_PATCH ${VERSION_PATCH} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/inc )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/core/inc )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/libamdhsacode )
include_directories ( ${HSAKMT_BUILD_INC_PATH})
link_directories ( ${HSAKMT_BUILD_LIB_PATH} )
add_subdirectory ( libamdhsacode )
add_subdirectory ( loader )
add_subdirectory ( core )
## Set install information
install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
## Packaging directives
set ( CPACK_PACKAGE_NAME "hsa-rocr-dev" )
set ( CPACK_PACKAGE_VENDOR "AMD" )
set ( CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION_MAJOR} )
set ( CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION_MINOR} )
set ( CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION_PATCH} )
set ( CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc." )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "AMD Heterogeneous System Architecture HSA - Linux HSA Runtime for Boltzmann (ROCm) platforms" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" )
## Set dependency strings
set ( HSAKMT_ROCT_DEV_DEPS "" )
if ( DEFINED HSAKMT_VERSION_STRING )
set ( HSAKMT_ROCT_DEV_DEPS " (=${HSAKMT_VERSION_STRING})" )
endif ()
# Debian package specific variables
set ( CPACK_DEBIAN_PACKAGE_DEPENDS "hsakmt-roct-dev${HSAKMT_ROCT_DEV_DEPS}" )
set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCR-Runtime" )
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm" )
## RPM package specific variables
set ( CPACK_RPM_PACKAGE_DEPENDS "hsakmt-roct-dev${HSAKMT_ROCT_DEV_DEPS}" )
set ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post" )
set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun" )
## Include packaging
include ( CPack )
@@ -0,0 +1,19 @@
#/bin/bash
set -e
do_ldconfig() {
echo /opt/rocm/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig
}
case "$1" in
configure)
do_ldconfig
;;
abort-upgrade|abort-remove|abort-deconfigure)
echo "$1"
;;
*)
exit 0
;;
esac
@@ -0,0 +1,19 @@
#!/bin/bash
set -e
rm_ldconfig() {
rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig
}
case "$1" in
remove)
rm_ldconfig
;;
purge)
;;
*)
exit 0
;;
esac
@@ -0,0 +1,39 @@
ROCR-Runtime LICENSE
The University of Illinois/NCSA
Open Source License (NCSA)
Copyright (c) 2014-2016, 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.
@@ -1,7 +1,7 @@
### Package Contents
This directory contains the HSA Runtime source code for the Boltzmann release. It has been modified to support
AMD/ATI discrete GPUs.
This directory contains the ROC Runtime source code based on the HSA Runtime
but modified to support AMD/ATI discrete GPUs.
#### Source & Include directories
@@ -11,7 +11,7 @@ cmake_modules - CMake support modules and files.
inc - Contains the public and AMD specific header files exposing the HSA Runtimes interfaces.
libamdhsacode - HSAIL/Finalizer runtime interface.
libamdhsacode - Code object definitions and interface.
loader - Used to load code objects.
@@ -19,12 +19,11 @@ utils - Utilities required to build the core runtime.
#### Build environment
CMake build framework is used to build the HSA runtime. The minimum version is 2.8.
CMake build framework is used to build the ROC runtime. The minimum version is 2.8.
Obtain cmake infrastructure: http://www.cmake.org/download/
Export cmake bin into your PATH
HSA Runtime CMake build file CMakeLists.txt is located in runtime/core folder.
#### Package Dependencies
@@ -36,26 +35,26 @@ The following support packages are requried to succesfully build the runtime:
#### Building the runtime
To build the runtime a compatible version of the libhsakmt library and the
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:
https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface
Specify the directory containing libhsakmt.so.1 and hsakmt.h using the following
Specify the directory containing libhsakmt.so.1 and hsakmt.h using the following
cmake variables:
HSATHK_BUILD_INC_PATH - Set to the dirctory containing hsakmt.h.
HSAKMT_BUILD_INC_PATH - Set to the dirctory containing hsakmt.h.
HSATHK_BUILD_LIB_PATH - Set to the directory containing libhsakmt.so.1
HSAKMT_BUILD_LIB_PATH - Set to the directory containing libhsakmt.so.1
For example, from the top level ROCR repository execute:
mkdir build
cd build
cmake -D HSATHK_BUILD_INC_PATH=<location of hsakmt.h> \
-D HSATHK_BUILD_LIB_PATH=<location of libhsakmt.so> \
../src
cmake -D HSAKMT_BUILD_INC_PATH=<location of hsakmt.h> \
-D HSAKMT_BUILD_LIB_PATH=<location of libhsakmt.so> \
..
make
The name of the core hsa runtime is libhsa-runtime64.so.1.
@@ -64,15 +63,15 @@ The name of the core hsa runtime is libhsa-runtime64.so.1.
http://www.hsafoundation.com/standards/
HSA Runtime Specification 1.0
HSA Runtime Specification 1.1
HSA Programmer Reference Manual Specification 1.0
HSA Programmer Reference Manual Specification 1.1
HSA Platform System Architecture Specification 1.0
HSA Platform System Architecture Specification 1.1
#### Runtime Design overview
The AMD HSA runtime consists of three primary layers:
The AMD ROC runtime consists of three primary layers:
C interface adaptors
C++ interfaces classes and common functions
@@ -87,7 +86,7 @@ hsa.h(cpp)
hsa_ext_interface.h(cpp)
The C interface layer provides C99 APIs as defined in the HSA Runtime Specification 1.0. 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. In this release the standard extensions (image support and finalizer) are implemented in a separate libraries (not open sourced), and can be obtained from the HSA-Runtime-AMD git repository.
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. In this release the standard extensions (image support and finalizer) are implemented in a separate libraries (not open sourced), and can be obtained from the HSA-Runtime-AMD git repository.
#### C++ interfaces classes and common functions
@@ -133,7 +132,7 @@ 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 AMD Kaveri & Carrizo APUs.
The device specific layer contains implementations of the C++ interface classes which implement HSA functionality for ROCm supported devices.
#### Implemented functionality
@@ -0,0 +1 @@
echo /opt/rocm/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig
@@ -0,0 +1 @@
rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig
@@ -47,58 +47,28 @@ if ( WIN32 )
MESSAGE ( FATAL_ERROR "Windows build is not supported." )
endif ()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules")
## Process environment variables.
if ( DEFINED HSATHK_BUILD_TARGET_BITS AND "${HSATHK_BUILD_TARGET_BITS}" STREQUAL 32 )
set ( ONLY64STR "" )
set ( IS64BIT 0 )
else ()
set ( ONLY64STR "64" )
set ( IS64BIT 1 )
endif ()
if ( NOT EXISTS ${HSATHK_BUILD_INC_PATH}/hsakmt.h )
MESSAGE ( FATAL_ERROR "Environment variable HSATHK_BUILD_INC_PATH is not set to point to the location where KFD Thunk header file hsakmt.h (and rest of the thunk headers) could be found." )
endif ()
if ( NOT EXISTS ${HSATHK_BUILD_LIB_PATH}/libhsakmt.so.1 )
MESSAGE ( FATAL_ERROR "Environment variable HSATHK_BUILD_LIB_PATH is not set to point to the location where KFD Thunk library libhsakmt.so.1 could be found." )
endif ()
MESSAGE ( ------IS64BIT: ${IS64BIT} )
MESSAGE ( ------Compiler: ${CMAKE_CXX_COMPILER} )
MESSAGE ( ------Version: ${CMAKE_CXX_COMPILER_VERSION} )
## Set core runtime module name and project name.
set ( CORE_RUNTIME_NAME "hsa-runtime" )
set ( CORE_RUNTIME_COMPONENT "lib${CORE_RUNTIME_NAME}" )
set ( CORE_RUNTIME_TARGET "${CORE_RUNTIME_NAME}${ONLY64STR}" )
project ( ${CORE_RUNTIME_TARGET} )
## Verbose output.
set ( CMAKE_VERBOSE_MAKEFILE on )
## Compiler preproc definitions.
add_definitions ( -D__linux__ )
add_definitions ( -D__linux__ )
add_definitions ( -DHSA_EXPORT=1 )
add_definitions ( -DHSA_EXPORT_FINALIZER=1 )
add_definitions ( -DHSA_EXPORT_IMAGES=1 )
if ( DEFINED BUILDID )
add_definitions ( -DROCR_BUILD_ID=${BUILDID})
else ( NOT DEFINED BUILDID)
add_definitions ( -DROCR_BUILD_ID=${BUILDID} )
else ( NOT DEFINED BUILDID )
## get date information based on UTC - full date
execute_process(COMMAND date --utc +%F WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND date --utc +%F WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE )
## get commit information
execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE )
## check dirty tree status
execute_process(COMMAND git diff --shortstat COMMAND wc -l WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_DIRTY_TREE OUTPUT_STRIP_TRAILING_WHITESPACE)
set ( BUILD_ID "${ROCR_BUILD_COMMIT}.${ROCR_BUILD_TIME}.${ROCR_DIRTY_TREE}")
add_definitions ( -DROCR_BUILD_ID=${BUILD_ID})
execute_process(COMMAND git diff --shortstat COMMAND wc -l WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_DIRTY_TREE OUTPUT_STRIP_TRAILING_WHITESPACE )
set ( BUILD_ID "${ROCR_BUILD_COMMIT}.${ROCR_BUILD_TIME}.${ROCR_DIRTY_TREE}" )
add_definitions ( -DROCR_BUILD_ID=${BUILD_ID} )
endif ()
## ------------------------- Linux Compiler and Linker options -------------------------
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=unused-function" )
@@ -108,7 +78,7 @@ set ( LNKSCR "${CMAKE_CURRENT_SOURCE_DIR}/hsacore.so.link" )
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bdynamic -Wl,-z,noexecstack -Wl,${LNKSCR} -Wl,--version-script=${DRVDEF}" )
set ( CMAKE_SKIP_BUILD_RPATH TRUE)
set ( CMAKE_SKIP_BUILD_RPATH TRUE )
## ------------------------- End Compiler and Linker options ----------------------------
@@ -139,23 +109,14 @@ set ( CORE_SRCS ${CORE_SRCS} runtime/cache.cpp )
set ( CORE_SRCS ${CORE_SRCS} common/shared.cpp )
set ( CORE_SRCS ${CORE_SRCS} common/hsa_table_interface.cpp )
## Include path(s).
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/../inc )
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/inc )
include_directories ( ${HSATHK_BUILD_INC_PATH} )
## Library path(s).
link_directories ( ${HSATHK_BUILD_LIB_PATH} )
add_library ( ${CORE_RUNTIME_TARGET} SHARED ${CORE_SRCS} )
## Set the VERSION and SOVERSION values
if ( DEFINED VERSION_STRING )
set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY VERSION "${VERSION_STRING}" )
set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY VERSION "${RUNTIME_VERSION_STRING}" )
endif ()
set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY SOVERSION "${VERSION_MAJOR}" )
set_property ( TARGET ${CORE_RUNTIME_TARGET} PROPERTY SOVERSION "${RUNTIME_VERSION_MAJOR}" )
target_link_libraries ( ${CORE_RUNTIME_TARGET}
PRIVATE amdhsaloader
@@ -169,5 +130,4 @@ if ( "${CMAKE_BUILD_TYPE}" STREQUAL Release )
add_custom_command ( TARGET ${CORE_RUNTIME_TARGET} POST_BUILD COMMAND ${CMAKE_STRIP} *.so )
endif ()
## Set install information
install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION lib COMPONENT ${CORE_RUNTIME_COMPONENT})
install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION lib COMPONENT ${CORE_RUNTIME_COMPONENT} )
View File