Skip to content

Commit

Permalink
Fix sles build (#34)
Browse files Browse the repository at this point in the history
* enable SLES build
* enable SLES build update
* enable SLES build update
  • Loading branch information
jzuniga-amd committed Dec 13, 2019
1 parent 74eb710 commit 7983da3
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 32 deletions.
22 changes: 9 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ set( CMAKE_CXX_STANDARD 14 )
# Without this line, it will add -std=gnu++14 instead, which has some issues.
set( CMAKE_CXX_EXTENSIONS OFF )

# Consider removing this in the future
# This should appear before the project command, because it does not use FORCE
if( WIN32 )
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" )
else( )
set( CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "Install path prefix, prepended onto install directories" )
endif( )

# This has to be initialized before the project() command appears
# Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE
if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE )
Expand Down Expand Up @@ -107,7 +99,7 @@ endif( )
# This finds the rocm-cmake project, and installs it if not found
# rocm-cmake contains common cmake code for rocm projects to help setup and install
set( PROJECT_EXTERN_DIR ${CMAKE_CURRENT_BINARY_DIR}/extern )
find_package( ROCM CONFIG QUIET PATHS /opt/rocm )
find_package( ROCM CONFIG QUIET PATHS ${ROCM_PATH} /opt/rocm )
if( NOT ROCM_FOUND )
set( rocm_cmake_tag "master" CACHE STRING "rocm-cmake tag to download" )
file( DOWNLOAD https://github.com/RadeonOpenCompute/rocm-cmake/archive/${rocm_cmake_tag}.zip
Expand Down Expand Up @@ -139,6 +131,10 @@ include( ROCMInstallTargets )
include( ROCMPackageConfigHelpers )
include( ROCMInstallSymlinks )

include (cmake/os-detection.cmake)
get_os_id(OS_ID)
message (STATUS "OS detected is ${OS_ID}")

# Versioning via rocm-cmake
set ( VERSION_STRING "2.7.0" )
rocm_setup_version( VERSION ${VERSION_STRING} )
Expand All @@ -148,7 +144,7 @@ rocm_setup_version( VERSION ${VERSION_STRING} )
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake )

# NOTE: workaround until hcc & hip cmake modules fixes symlink logic in their config files; remove when fixed
list( APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc /opt/rocm/hip )
list( APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hcc ${ROCM_PATH}/hip /opt/rocm/hcc /opt/rocm/hip )

option( BUILD_VERBOSE "Output additional build information" OFF )

Expand All @@ -162,12 +158,12 @@ set(CMAKE_INSTALL_LIBDIR "lib" CACHE INTERNAL "Installation directory for librar

# Find HCC/HIP dependencies
if( CMAKE_CXX_COMPILER MATCHES ".*/hcc$" )
find_package( hcc REQUIRED CONFIG PATHS /opt/rocm )
find_package( hip REQUIRED CONFIG PATHS /opt/rocm )
find_package( hcc REQUIRED CONFIG PATHS ${ROCM_PATH} /opt/rocm )
find_package( hip REQUIRED CONFIG PATHS ${ROCM_PATH} /opt/rocm )
endif( )


find_package( rocblas REQUIRED CONFIG PATHS /opt/rocm )
find_package( rocblas REQUIRED CONFIG PATHS ${ROCM_PATH} /opt/rocm )
include_directories( ${rocblas_INCLUDE_DIR} )


Expand Down
17 changes: 5 additions & 12 deletions clients/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
# The ROCm platform requires Ubuntu 16.04 or Fedora 24, which has cmake 3.5
cmake_minimum_required( VERSION 3.5 )

# Consider removing this in the future
# This should appear before the project command, because it does not use FORCE
if( WIN32 )
set( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/package" CACHE PATH "Install path prefix, prepended onto install directories" )
else( )
set( CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "Install path prefix, prepended onto install directories" )
endif( )

# This has to be initialized before the project() command appears
# Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE
if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE )
Expand All @@ -22,12 +14,13 @@ endif()
# This project may compile dependencies for clients
project( rocsolver-clients LANGUAGES CXX )

if(EXISTS /etc/redhat-release)
if(OS_ID_rhel OR OS_ID_centos OR OS_ID_sles)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp=libgomp -pthread")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread")
endif()


set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

Expand All @@ -40,12 +33,12 @@ include( build-options )
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )

if( NOT TARGET rocsolver )
find_package( rocsolver REQUIRED CONFIG PATHS /opt/rocm/rocsolver )
find_package( rocsolver REQUIRED CONFIG PATHS ${ROCM_PATH}/rocsolver /opt/rocm/rocsolver )
endif( )

# Hip headers required of all clients; clients use hip to allocate device memory
list( APPEND CMAKE_PREFIX_PATH /opt/rocm )
find_package( hip REQUIRED CONFIG PATHS ${CMAKE_PREFIX_PATH} )
list( APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} /opt/rocm )
find_package( hip REQUIRED CONFIG PATHS ${ROCM_PATH} )

# Quietly look for CUDA, but if not found it's not an error
# The presense of hip is not sufficient to determine if we want a rocm or cuda backend
Expand Down
13 changes: 9 additions & 4 deletions clients/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ if( OS_ID_rhel OR OS_ID_centos OR OS_ID_sles)
set( OPENMP_LIBRARY /usr/lib64/gcc/x86_64-suse-linux/7/libgomp.so )
endif()

if(EXISTS /opt/rocm/hcc/lib/clang/10.0.0/include/immintrin.h)
message(STATUS "RocmPath: ${ROCM_PATH}")
if(EXISTS "${ROCM_PATH}/hcc/lib/clang/10.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR ${ROCM_PATH}/hcc/lib/clang/10.0.0/include )
elseif (EXISTS "${ROCM_PATH}/hcc/lib/clang/9.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR ${ROCM_PATH}/hcc/lib/clang/9.0.0/include )
elseif (EXISTS "/opt/rocm/hcc/lib/clang/10.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR /opt/rocm/hcc/lib/clang/10.0.0/include )
elseif (EXISTS /opt/rocm/hcc/lib/clang/9.0.0/include/immintrin.h)
elseif (EXISTS "/opt/rocm/hcc/lib/clang/9.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR /opt/rocm/hcc/lib/clang/9.0.0/include )
else()
error("cannot find immintrin.h")
endif()


# External header includes included as system files
target_include_directories( rocsolver-bench
SYSTEM PRIVATE
Expand Down Expand Up @@ -112,7 +116,8 @@ else()
target_link_libraries( rocsolver-bench PRIVATE ${Boost_LIBRARIES} cblas lapack roc::rocsolver )
endif()

target_link_libraries( rocsolver-bench PRIVATE /opt/rocm/rocblas/lib/librocblas.so ) #${ROCBLAS_LIBRARY})
#target_link_libraries( rocsolver-bench PRIVATE /opt/rocm/rocblas/lib/librocblas.so ) #${ROCBLAS_LIBRARY})
target_link_libraries( rocsolver-bench PRIVATE roc::rocblas ) #${ROCBLAS_LIBRARY})


get_target_property( HIPHCC_LOCATION hip::hip_hcc IMPORTED_LOCATION_RELEASE )
Expand Down
12 changes: 9 additions & 3 deletions clients/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ if( OS_ID_rhel OR OS_ID_centos OR OS_ID_sles)
set( OPENMP_LIBRARY /usr/lib64/gcc/x86_64-suse-linux/7/libgomp.so )
endif()

if(EXISTS /opt/rocm/hcc/lib/clang/10.0.0/include/immintrin.h)
message(STATUS "RocmPath: ${ROCM_PATH}")
if(EXISTS "${ROCM_PATH}/hcc/lib/clang/10.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR ${ROCM_PATH}/hcc/lib/clang/10.0.0/include )
elseif (EXISTS "${ROCM_PATH}/hcc/lib/clang/9.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR ${ROCM_PATH}/hcc/lib/clang/9.0.0/include )
elseif (EXISTS "/opt/rocm/hcc/lib/clang/10.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR /opt/rocm/hcc/lib/clang/10.0.0/include )
elseif (EXISTS /opt/rocm/hcc/lib/clang/9.0.0/include/immintrin.h)
elseif (EXISTS "/opt/rocm/hcc/lib/clang/9.0.0/include/immintrin.h")
set( CLANG_INCLUDE_DIR /opt/rocm/hcc/lib/clang/9.0.0/include )
else()
error("cannot find immintrin.h")
Expand Down Expand Up @@ -129,7 +134,8 @@ else()
target_link_libraries( rocsolver-test PRIVATE ${GTEST_LIBRARIES} ${Boost_LIBRARIES} cblas lapack roc::rocsolver )
endif()

target_link_libraries( rocsolver-test PRIVATE /opt/rocm/rocblas/lib/librocblas.so ) #${ROCBLAS_LIBRARY})
target_link_libraries( rocsolver-test PRIVATE roc::rocblas ) #${ROCBLAS_LIBRARY})
#target_link_libraries( rocsolver-test PRIVATE /opt/rocm/rocblas/lib/librocblas.so ) #${ROCBLAS_LIBRARY})


get_target_property( HIPHCC_LOCATION hip::hip_hcc IMPORTED_LOCATION_RELEASE )
Expand Down
31 changes: 31 additions & 0 deletions cmake/os-detection.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ########################################################################
# Copyright 2019 Advanced Micro Devices, Inc.
# ########################################################################

function (get_os_id OS_ID)
set(_os_id "unknown")

if (EXISTS "/etc/os-release")
read_key("ID" _os_id)
endif()

if (_os_id STREQUAL "opensuse-leap")
set(_os_id "sles")
endif()

set(${OS_ID} ${_os_id} PARENT_SCOPE)
set(${OS_ID}_${_os_id} TRUE PARENT_SCOPE)
endfunction()


function (read_key KEYVALUE OUTPUT)
#finds the line with the keyvalue
file (STRINGS /etc/os-release _keyvalue_line REGEX "^${KEYVALUE}=")

#remove keyvalue=
string (REGEX REPLACE "^${KEYVALUE}=\"?(.*)" "\\1" _output "${_keyvalue_line}")

#remove trailing quote
string (REGEX REPLACE "\"$" "" _output "${_output}")
set(${OUTPUT} ${_output} PARENT_SCOPE)
endfunction ()

0 comments on commit 7983da3

Please sign in to comment.