Skip to content

Commit

Permalink
Merge pull request #97 from kknox/linux-packaging
Browse files Browse the repository at this point in the history
Linux packaging enhancememnts
  • Loading branch information
Kent Knox authored May 2, 2017
2 parents 54e6f7d + a6f7eab commit fe767b4
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 99 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ if( BUILD_LIBRARY )
-DTensile_PRINT_DEBUG=${Tensile_PRINT_DEBUG}
-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()

if (Tensile_FOUND)
set( LIBRARY_CMAKE_ARGS ${LIBRARY_CMAKE_ARGS} -DTensile_FOUND=${Tensile_FOUND})
else()
Expand Down
45 changes: 17 additions & 28 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ properties([buildDiscarder(logRotator(
artifactNumToKeepStr: '',
daysToKeepStr: '',
numToKeepStr: '10')),
disableConcurrentBuilds()])
disableConcurrentBuilds(),
[$class: 'CopyArtifactPermissionProperty', projectNames: '*']
])

def build_type="Debug"
def build_type_postfix="-d"
// def build_type="Debug"
// def build_type_postfix="-d"
def build_type="Release"
def build_type_postfix=""

// Currently, YADP (yet-another-docker-plugin v0.1.0-rc30) does not load balance between clouds with the same label
// They recommend to use docker swarm, but not yet work with docker 1.12 'swarm mode'
Expand Down Expand Up @@ -67,40 +71,25 @@ node('rocm-1.5 && fiji')
stage("configure clang release") {
sh """#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install python-yaml
cmake -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_PREFIX_PATH=/opt/boost/clang-3.8 -DBUILD_LIBRARY=ON -DBUILD_WITH_TENSILE=ON \
-DBUILD_CLIENTS=ON -DBUILD_CLIENTS_SAMPLES=ON -DBUILD_CLIENTS_TESTS=ON ${scm_dir}
sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y rpm
cmake -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_PREFIX_PATH=/opt/boost/clang-3.8 -DBUILD_SHARED_LIBS=ON -DBUILD_LIBRARY=ON -DBUILD_WITH_TENSILE=ON \
-DBUILD_CLIENTS=ON -DBUILD_CLIENTS_SAMPLES=ON -DBUILD_CLIENTS_TESTS=ON -DCPACK_PACKAGING_INSTALL_PREFIX=/opt/rocm/rocblas ${scm_dir}
"""
}

stage("Build")
{
if (env.NODE_LABELS ==~ /.*fiji.*/)
{
sh 'echo Target Fiji ISA'
withEnv(['HCC_AMDGPU_TARGET=gfx803'])
{
sh '''#!/usr/bin/env bash
make -j 8
'''
}
}
else if (env.NODE_LABELS ==~ /.*hawaii.*/)
{
sh 'echo Target Hawaii ISA'
withEnv(['HCC_AMDGPU_TARGET=gfx701'])
{
sh '''#!/usr/bin/env bash
make -j 8
'''
}
}
sh '''#!/usr/bin/env bash
make -j $(nproc)
'''
}

stage("Package Debian") {
sh 'cd library-build; make package'
archive includes: 'library-build/*.deb'
}
archiveArtifacts artifacts: 'library-build/*.deb', fingerprint: true
archiveArtifacts artifacts: 'library-build/*.rpm', fingerprint: true
sh "sudo dpkg -c library-build/*.deb"
}

// Cap the maximum amount of testing to be a few hours; assume failure if the time limit is hit
timeout(time: 1, unit: 'HOURS')
Expand Down
4 changes: 2 additions & 2 deletions cmake/build-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro( project_version )
endif( )
if( POLICY CMP0048 )
cmake_policy( SET CMP0048 NEW )
project( ${PV_NAME} VERSION 0.3.0.0 LANGUAGES ${PV_LANGUAGES} )
project( ${PV_NAME} VERSION 0.4.0.0 LANGUAGES ${PV_LANGUAGES} )

else( )
project( ${PV_NAME} ${PV_LANGUAGES} )
Expand All @@ -29,7 +29,7 @@ macro( project_version )
endif( )

if( NOT DEFINED ${PV_NAME}_VERSION_MINOR )
set( ${PV_NAME}_VERSION_MINOR 3 )
set( ${PV_NAME}_VERSION_MINOR 4 )
endif( )

if( NOT DEFINED ${PV_NAME}_VERSION_PATCH )
Expand Down
63 changes: 63 additions & 0 deletions cmake/package-functions.cmake
Original file line number Diff line number Diff line change
@@ -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( )
82 changes: 43 additions & 39 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required( VERSION 2.8.12 )

# MACOSX_RPATH is enabled by default policy
if( POLICY CMP0042 )
cmake_policy( SET CMP0042 NEW )
cmake_policy( SET CMP0042 NEW )
endif( )

# CMP0063: Honor visibility properties for all target types [cmake 3.3]
Expand All @@ -17,12 +17,12 @@ if( POLICY CMP0063 )
endif( )

if( CMAKE_GENERATOR MATCHES "NMake" )
option( NMAKE_COMPILE_VERBOSE "Print VERBOSE compile/link msgs to the console" OFF )
if( NMAKE_COMPILE_VERBOSE )
set( CMAKE_START_TEMP_FILE "" )
set( CMAKE_END_TEMP_FILE "" )
set( CMAKE_VERBOSE_MAKEFILE 1 )
endif( )
option( NMAKE_COMPILE_VERBOSE "Print VERBOSE compile/link msgs to the console" OFF )
if( NMAKE_COMPILE_VERBOSE )
set( CMAKE_START_TEMP_FILE "" )
set( CMAKE_END_TEMP_FILE "" )
set( CMAKE_VERBOSE_MAKEFILE 1 )
endif( )
endif( )

# This has to be initialized before the project() command appears
Expand All @@ -49,18 +49,18 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
# On windows, it's convenient to change the default install prefix such that it does NOT point to 'program files'
# Need to check out CMAKE_RUNTIME_OUTPUT_DIRECTORY variable, and see if that eliminates the need to modify install path
if( WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE )
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" FORCE )
endif( )

# Set common compile and link options
if( MSVC )
# Following options for nMake
message( STATUS "Detected MSVS Ver: " ${MSVC_VERSION} )
# Following options for nMake
message( STATUS "Detected MSVS Ver: " ${MSVC_VERSION} )

# CMake uses huge stack frames for windows, we would like to remove.
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" )
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" )
# CMake uses huge stack frames for windows, we would like to remove.
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" )
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )
string( REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" )
endif( )

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic")
Expand All @@ -74,50 +74,40 @@ message( STATUS "CMAKE_CXX_COMPILER release flags: " ${CMAKE_CXX_FLAGS_RELEASE}
message( STATUS "CMAKE_CXX_COMPILER relwithdebinfo flags: " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
message( STATUS "CMAKE_EXE_LINKER link flags: " ${CMAKE_EXE_LINKER_FLAGS} )

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/rocblas-version.h.in" "${PROJECT_BINARY_DIR}/include/rocblas-version.h" )

set( rocblas_headers_public
include/rocblas.h
# include/rocblas.hpp
include/rocblas_types.h
include/rocblas_auxiliary.h
include/rocblas_functions.h
include/rocblas-types.h
include/rocblas-auxiliary.h
include/rocblas-functions.h
${PROJECT_BINARY_DIR}/include/rocblas-version.h
)

source_group( "Header Files\\Public" FILES ${rocblas_headers_public} )

# Build into subdirectories
add_subdirectory( src )
include( GNUInstallDirs )

install( FILES
${rocblas_headers_public}
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR} )
set( BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} )
set( LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} )
set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} )

# 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( )
# Build into subdirectories
add_subdirectory( src )

# The following code is setting variables to control the behavior of CPack to generate our
if( WIN32 )
set( CPACK_SOURCE_GENERATOR "ZIP" )
set( CPACK_GENERATOR "ZIP" )
set( CPACK_SOURCE_GENERATOR "ZIP" )
set( CPACK_GENERATOR "ZIP" )
else( )
set( CPACK_SOURCE_GENERATOR "TGZ" )

set( CPACK_GENERATOR "DEB" )
set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" )
set( CPACK_DEBIAN_COMPRESSION_TYPE "xz" )
# set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
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_SHLIBDEPS ON )
endif( )

# Package agnostic CPACK vars
set( CPACK_PACKAGE_CONTACT "Kent Knox <[email protected]>" )
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute BLAS library")
set( CPACK_PACKAGE_VERSION_MAJOR ${rocblas_VERSION_MAJOR} )
Expand All @@ -126,7 +116,21 @@ set( CPACK_PACKAGE_VERSION_PATCH ${rocblas_VERSION_PATCH} )
set( CPACK_PACKAGE_VERSION_TWEAK ${rocblas_VERSION_TWEAK} )
set( CPACK_PACKAGE_VERSION ${rocblas_VERSION} )
set( CPACK_PACKAGE_VENDOR "AMD")
set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE.md" )
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} "rocblas" "librocblas-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 )
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#define _ROCBLAS_AUXILIARY_H_

#include <hip/hip_runtime_api.h>
#include "rocblas_types.h"
#include "rocblas-types.h"

/*!\file
* \brief rocblas_auxiliary.h provides auxilary functions in rocblas
* \brief rocblas-auxiliary.h provides auxilary functions in rocblas
*/


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef _ROCBLAS_FUNCTIONS_H_
#define _ROCBLAS_FUNCTIONS_H_

#include "rocblas_types.h"
#include "rocblas-types.h"


/*!\file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ************************************************************************ */

/*! \file
* \brief rocblas_types.h defines data types used by rocblas
* \brief rocblas-types.h defines data types used by rocblas
*/

#pragma once
Expand Down
6 changes: 3 additions & 3 deletions library/include/rocblas.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
/* library headers */
#include "rocblas-export.h"
#include "rocblas-version.h"
#include "rocblas_types.h"
#include "rocblas_auxiliary.h"
#include "rocblas_functions.h"
#include "rocblas-types.h"
#include "rocblas-auxiliary.h"
#include "rocblas-functions.h"

#endif // _ROCBLAS_H_
Loading

0 comments on commit fe767b4

Please sign in to comment.