diff --git a/CMakeLists.txt b/CMakeLists.txt index f58c5d1ad..af467def1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,10 @@ if( BUILD_LIBRARY ) -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ) + if( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) + list( APPEND LIBRARY_CMAKE_ARGS -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_PACKAGING_INSTALL_PREFIX} ) + endif() + # Build the library as an external project ExternalProject_Add( hipblas DEPENDS ${hipblas_dependencies} diff --git a/Jenkinsfile b/Jenkinsfile index 2b8497119..178c8c33b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -82,7 +82,7 @@ def docker_build_inside_image( def build_image, String build_config, String work { stage("build ${build_config}") { - String install_prefix = "/opt/rocm" + String install_prefix = "/opt/rocm/hipblas" // Copy our rocBLAS dependency // Commented out because we need to compile static rocblas with fpic enabled @@ -96,6 +96,7 @@ def docker_build_inside_image( def build_image, String build_config, String work cd ${build_dir_rel} cmake -B${build_dir_abs} \ -DCMAKE_INSTALL_PREFIX=${install_prefix} \ + -DCPACK_PACKAGING_INSTALL_PREFIX=${install_prefix} \ -DCMAKE_BUILD_TYPE=${build_config} \ -DCMAKE_PREFIX_PATH='/opt/rocm;/usr/local/src/rocBLAS/build/library-package' \ -DBUILD_LIBRARY=ON \ @@ -152,22 +153,41 @@ def docker_upload_artifactory( String build_config, String workspace_dir_abs ) } //////////////////////////////////////////////////////////////////////// -// This routines defines the build flow of the project -// Calls helper routines to do the work and stitches them together -def hipblas_build_pipeline( String build_type ) +// Checkout the desired source code and update the version number +def checkout_and_version( String workspace_dir_abs ) { - // Convenience variables for common paths used in building - String workspace_dir_abs = pwd() - dir("${workspace_dir_abs}") { stage("github clone") { deleteDir( ) checkout scm + + if( fileExists( 'cmake/build-version.cmake' ) ) + { + def cmake_version_file = readFile( 'cmake/build-version.cmake' ).trim() + //echo "cmake_version_file:\n${cmake_version_file}" + + cmake_version_file = cmake_version_file.replaceAll(/(\d+\.)(\d+\.)(\d+\.)\d+/, "\$1\$2\$3${env.BUILD_ID}") + cmake_version_file = cmake_version_file.replaceAll(/VERSION_TWEAK\s+\d+/, "VERSION_TWEAK ${env.BUILD_ID}") + //echo "cmake_version_file:\n${cmake_version_file}" + writeFile( file: 'cmake/build-version.cmake', text: cmake_version_file ) + } } } +} + +//////////////////////////////////////////////////////////////////////// +// This routines defines the build flow of the project +// Calls helper routines to do the work and stitches them together +def hipblas_build_pipeline( String build_type ) +{ + // Convenience variables for common paths used in building + String workspace_dir_abs = pwd() + + checkout_and_version( "${workspace_dir_abs}" ) + // Create/reuse a docker image that represents the hipblas build environment def hipblas_build_image = docker_build_image( ) @@ -182,7 +202,6 @@ def hipblas_build_pipeline( String build_type ) //////////////////////////////////////////////////////////////////////// // -- MAIN // This following are build nodes; start of build pipeline -//node('rocmtest') node('docker && rocm') { hipblas_build_pipeline( 'Release' ) diff --git a/cmake/package-functions.cmake b/cmake/package-functions.cmake new file mode 100644 index 000000000..1f99bc774 --- /dev/null +++ b/cmake/package-functions.cmake @@ -0,0 +1,63 @@ +# ######################################################################## +# A helper function to generate packaging scripts to register libraries with system +# ######################################################################## +function( write_rocm_package_script_files scripts_write_dir library_name library_link_name ) + +set( ld_conf_file "/etc/ld.so.conf.d/${library_name}-dev.conf" ) + +file( WRITE ${scripts_write_dir}/postinst +"#!/bin/bash + +set -e + +do_ldconfig() { + echo ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR} > ${ld_conf_file} && ldconfig +} + +do_softlinks() { + ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR} ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name} + ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${library_link_name}.1 ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name} + ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/${library_name} ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name} +} + +case \"\$1\" in + configure) + do_ldconfig + do_softlinks + ;; + abort-upgrade|abort-remove|abort-deconfigure) + echo \"\$1\" + ;; + *) + exit 0 + ;; +esac +" ) + +file( WRITE ${scripts_write_dir}/prerm +"#!/bin/bash + +set -e + +rm_ldconfig() { + rm -f ${ld_conf_file} && ldconfig +} + +rm_softlinks() { + rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name} + rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name} + rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name} +} + +case \"\$1\" in + remove|purge) + rm_ldconfig + rm_softlinks + ;; + *) + exit 0 + ;; +esac +" ) + +endfunction( ) diff --git a/docker/dockerfile-build-ubuntu-16.04 b/docker/dockerfile-build-ubuntu-16.04 index 216610b0a..7cfb22115 100644 --- a/docker/dockerfile-build-ubuntu-16.04 +++ b/docker/dockerfile-build-ubuntu-16.04 @@ -9,14 +9,15 @@ ARG build_type=Release # echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \ # apt update && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl && \ - echo 'deb [arch=amd64] http://compute-artifactory.amd.com/artifactory/rocm-release-1.5-deb xenial main' | tee /etc/apt/sources.list.d/rocm.list && \ - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y --allow-unauthenticated \ + curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \ + echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ sudo \ file \ software-properties-common \ build-essential \ - git \ rpm \ + git \ cmake \ clang \ hsakmt-roct-dev \ @@ -26,8 +27,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-instal hcc \ hip_base \ hip_hcc \ - hip_doc \ - hip_samples \ python-yaml \ && \ apt-get clean && \ diff --git a/docker/dockerfile-hipblas-ubuntu-16.04 b/docker/dockerfile-hipblas-ubuntu-16.04 index 5aae0f0e4..143b156a8 100644 --- a/docker/dockerfile-hipblas-ubuntu-16.04 +++ b/docker/dockerfile-hipblas-ubuntu-16.04 @@ -2,7 +2,24 @@ FROM ubuntu:16.04 MAINTAINER Kent Knox # Initialize the image we are working with -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ - && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl && \ + curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \ + echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + rocm-dev \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy the debian package of hcc-lc into the container from host +COPY *.deb /tmp/ + +# Install the debian package, and print out contents of expected changed locations +RUN dpkg -i /tmp/*.deb && \ + rm -f /tmp/*.deb && \ + printf "cat /etc/ld.so.conf.d/hipblas-dev.conf\n" && cat /etc/ld.so.conf.d/hipblas-dev.conf && \ + printf "ls -la /opt/rocm/include\n" && ls -la /opt/rocm/include && \ + printf "ls -la /opt/rocm/lib \n" && ls -la /opt/rocm/lib && \ + printf "ls -la /opt/rocm/lib/cmake\n" && ls -la /opt/rocm/lib/cmake && \ + printf "ls -la /opt/rocm/hipblas/include\n" && ls -la /opt/rocm/hipblas/include && \ + printf "ls -la /opt/rocm/hipblas/lib\n" && ls -la /opt/rocm/hipblas/lib \ No newline at end of file diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index c9f128afc..5c1a02b42 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -72,8 +72,6 @@ message( STATUS "CMAKE_CXX_COMPILER debug flags : ${CMAKE_CXX_FLAGS_DEBU message( STATUS "CMAKE_CXX_COMPILER release flags : ${CMAKE_CXX_FLAGS_RELEASE} " ) message( STATUS "CMAKE_CXX_COMPILER relwithdebinfo flags: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " ) -include( GNUInstallDirs ) - # configure a header file to pass the CMake version settings to the source, and package the header files in the output archive configure_file( "${PROJECT_SOURCE_DIR}/include/hipblas-version.h.in" "${PROJECT_BINARY_DIR}/include/hipblas-version.h" ) @@ -84,16 +82,15 @@ set( hipblas_headers_public source_group( "Header Files\\Public" FILES ${hipblas_headers_public} ) +include( GNUInstallDirs ) + +set( BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} ) +set( LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} ) +set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} ) + # Build into subdirectories add_subdirectory( src ) -# # Depending on whether we are building for 64 or 32 bit, construct common paths and names that subdirectories can reference for their use -# if( BUILD_64 ) -# set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-amd64" ) -# else( ) -# set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-i686" ) -# endif( ) - # The following code is setting variables to control the behavior of CPack to generate our if( WIN32 ) set( CPACK_SOURCE_GENERATOR "ZIP" ) @@ -102,10 +99,6 @@ else( ) set( CPACK_SOURCE_GENERATOR "TGZ" ) set( CPACK_GENERATOR "DEB;RPM" CACHE STRING "cpack list: 7Z, DEB, IFW, NSIS, NSIS64, RPM, STGZ, TBZ2, TGZ, TXZ, TZ, ZIP" ) - # set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" ) - # set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm" ) - # set( CPACK_DEBIAN_PACKAGE_DEPENDS "" ) - # set( CPACK_DEBIAN_COMPRESSION_TYPE "xz" ) # set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON ) endif( ) @@ -120,5 +113,18 @@ set( CPACK_PACKAGE_VENDOR "AMD") set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE" ) set( CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" ) +# Package specific CPACK vars +set( CPACK_DEBIAN_PACKAGE_DEPENDS "hip_hcc (>= 1.0.17174)" ) +set( CPACK_RPM_PACKAGE_REQUIRES "hip_hcc >= 1.0.17174" ) + +if( "${CPACK_PACKAGING_INSTALL_PREFIX}" MATCHES "^/opt/rocm.*$") + include( package-functions ) + write_rocm_package_script_files( ${PROJECT_BINARY_DIR} "hipblas" "libhipblas-hcc.so" ) + + set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") + set( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst" ) + set( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm" ) +endif( ) + # Define all variables that influence CPack before including CPack, such as install targets include( CPack )