-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix BLAS++ and LAPACK++ build #903
base: master
Are you sure you want to change the base?
Changes from all commits
e7f4bd3
0b9193a
0c31c63
ca6673b
38e5b08
b50109c
7f2c622
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
cmake_minimum_required(VERSION 3.11) | ||
# VERSION 3.11: FetchContent | ||
|
||
project(LAPACK) | ||
|
||
|
@@ -10,6 +11,19 @@ set( | |
${LAPACK_MAJOR_VERSION}.${LAPACK_MINOR_VERSION}.${LAPACK_PATCH_VERSION} | ||
) | ||
|
||
# Dependencies on other projects | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
blaspp | ||
GIT_REPOSITORY https://github.com/icl-utk-edu/blaspp | ||
GIT_TAG 3c47832f5162b5215b2164c21c4132544c65563d # v2023.11.05 | ||
) | ||
FetchContent_Declare( | ||
lapackpp | ||
GIT_REPOSITORY https://github.com/icl-utk-edu/lapackpp | ||
GIT_TAG e3aa0156b873d1e1349d083d7e5b66cfbdf9fb08 # v2023.11.05 | ||
) | ||
|
||
# Allow setting a prefix for the library names | ||
set(CMAKE_STATIC_LIBRARY_PREFIX "lib${LIBRARY_PREFIX}") | ||
set(CMAKE_SHARED_LIBRARY_PREFIX "lib${LIBRARY_PREFIX}") | ||
|
@@ -402,48 +416,113 @@ endif() | |
option(BLAS++ "Build BLAS++" OFF) | ||
option(LAPACK++ "Build LAPACK++" OFF) | ||
|
||
if (BLAS++ OR LAPACK++) | ||
message( STATUS "BLAS++ enabled; for support, email [email protected]" ) | ||
|
||
# Check if population has already been performed | ||
FetchContent_GetProperties(blaspp) | ||
if(NOT blaspp_POPULATED) | ||
# Fetch the content using previously declared details | ||
FetchContent_Populate(blaspp) | ||
endif() | ||
|
||
# Determine Fortran runtime library. | ||
# todo: CMake ought to know this already -- how to access? | ||
set( Fortran_LIB "" ) | ||
if (NOT BUILD_SHARED_LIBS) | ||
if (CMAKE_Fortran_COMPILER_ID MATCHES GNU) | ||
set( Fortran_LIB ";-lgfortran" ) | ||
else() | ||
# TODO: This is incomplete. Fill in the other cases. | ||
endif() | ||
endif() | ||
message( DEBUG "Fortran_LIB '${Fortran_LIB}'" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this when using Reference BLAS, is that why it checks When I tried to compile, linking with BTW, setting it to empty in the |
||
|
||
function(_display_cpp_implementation_msg name) | ||
string(TOLOWER ${name} name_lc) | ||
message(STATUS "${name}++ enable") | ||
message(STATUS "----------------") | ||
message(STATUS "Thank you for your interest in ${name}++, a newly developed C++ API for ${name} library") | ||
message(STATUS "The objective of ${name}++ is to provide a convenient, performance oriented API for development in the C++ language, that, for the most part, preserves established conventions, while, at the same time, takes advantages of modern C++ features, such as: namespaces, templates, exceptions, etc.") | ||
message(STATUS "For support ${name}++ related question, please email: [email protected]") | ||
message(STATUS "----------------") | ||
endfunction() | ||
if (BLAS++) | ||
_display_cpp_implementation_msg("BLAS") | ||
include(ExternalProject) | ||
ExternalProject_Add(blaspp | ||
URL https://bitbucket.org/icl/blaspp/downloads/blaspp-2020.10.02.tar.gz | ||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} ${PROJECT_BINARY_DIR}/blaspp-prefix/src/blaspp | ||
BUILD_COMMAND ${CMAKE_COMMAND} -E env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib LIB_SUFFIX="" ${CMAKE_COMMAND} --build . | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E env PREFIX=${PROJECT_BINARY_DIR} LIB_SUFFIX="" ${CMAKE_COMMAND} --install . | ||
) | ||
ExternalProject_Add_StepDependencies(blaspp build ${BLAS_LIBRARIES}) | ||
if (NOT BLAS_FOUND) | ||
# Link with Reference BLAS. | ||
set( BLAS_LIBS "$<TARGET_FILE:${BLASLIB}>${Fortran_LIB}" ) | ||
else() | ||
# Link with optimized BLAS. | ||
set( BLAS_LIBS "${BLAS_LIBRARIES}" ) | ||
endif() | ||
message( DEBUG "BLAS_LIBS '${BLAS_LIBS}'" ) | ||
|
||
if (NOT LATESTLAPACK_FOUND) | ||
# Link with Reference LAPACK. | ||
set( LAPACK_LIBS "$<TARGET_FILE:${LAPACKLIB}>${Fortran_LIB}" ) | ||
else() | ||
# Link with optimized BLAS. | ||
set( LAPACK_LIBS "${LAPACK_LIBRARIES}" ) | ||
endif() | ||
message( DEBUG "LAPACK_LIBS '${LAPACK_LIBS}'" ) | ||
|
||
# Adds target blaspp | ||
add_custom_target( blaspp ALL DEPENDS blaspp-cmd ) | ||
add_custom_command( OUTPUT blaspp-cmd | ||
WORKING_DIRECTORY "${blaspp_SOURCE_DIR}" | ||
COMMENT "Building BLAS++" ) | ||
|
||
# Set up information about the BLAS and LAPACK libraries | ||
add_custom_command( OUTPUT blaspp-cmd APPEND | ||
COMMAND ${CMAKE_COMMAND} | ||
-B "${blaspp_BINARY_DIR}" | ||
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}" | ||
-D BLAS_LIBRARIES="${BLAS_LIBS}" | ||
-D LAPACK_LIBRARIES="${LAPACK_LIBS}" | ||
-D build_tests=OFF | ||
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} | ||
|
||
COMMAND ${CMAKE_COMMAND} | ||
--build "${blaspp_BINARY_DIR}" | ||
--config ${CMAKE_BUILD_TYPE} | ||
--target install | ||
) | ||
|
||
# Set up dependencies | ||
if(NOT BLAS_FOUND) | ||
add_dependencies(blaspp ${BLASLIB}) | ||
endif() | ||
if(NOT LATESTLAPACK_FOUND) | ||
add_dependencies(blaspp ${LAPACKLIB}) | ||
endif() | ||
endif() | ||
|
||
if (LAPACK++) | ||
message (STATUS "linking lapack++ against ${LAPACK_LIBRARIES}") | ||
_display_cpp_implementation_msg("LAPACK") | ||
include(ExternalProject) | ||
if (BUILD_SHARED_LIBS) | ||
ExternalProject_Add(lapackpp | ||
URL https://bitbucket.org/icl/lapackpp/downloads/lapackpp-2020.10.02.tar.gz | ||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DCMAKE_INSTALL_LIBDIR=lib -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} ${PROJECT_BINARY_DIR}/lapackpp-prefix/src/lapackpp | ||
BUILD_COMMAND ${CMAKE_COMMAND} -E env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib LIB_SUFFIX="" ${CMAKE_COMMAND} --build . | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E env PREFIX=${PROJECT_BINARY_DIR} LIB_SUFFIX="" ${CMAKE_COMMAND} --install . | ||
) | ||
else () | ||
# FIXME this does not really work as the libraries list gets converted to a semicolon-separated list somewhere in the lapack++ build files | ||
ExternalProject_Add(lapackpp | ||
URL https://bitbucket.org/icl/lapackpp/downloads/lapackpp-2020.10.02.tar.gz | ||
CONFIGURE_COMMAND env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DCMAKE_INSTALL_LIBDIR=lib -DLAPACK_LIBRARIES="${PROJECT_BINARY_DIR}/lib/liblapack.a -lgfortran" -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} ${PROJECT_BINARY_DIR}/lapackpp-prefix/src/lapackpp | ||
BUILD_COMMAND env LIBRARY_PATH=$ENV{LIBRARY_PATH}:${PROJECT_BINARY_DIR}/lib LIB_SUFFIX="" ${CMAKE_COMMAND} --build . | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E env PREFIX=${PROJECT_BINARY_DIR} LIB_SUFFIX="" ${CMAKE_COMMAND} --install . | ||
) | ||
message( STATUS "LAPACK++ enabled; for support, email [email protected]" ) | ||
|
||
# Check if population has already been performed | ||
FetchContent_GetProperties(lapackpp) | ||
if(NOT lapackpp_POPULATED) | ||
# Fetch the content using previously declared details | ||
FetchContent_Populate(lapackpp) | ||
endif() | ||
ExternalProject_Add_StepDependencies(lapackpp build blaspp ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}) | ||
|
||
# Adds target lapackpp | ||
add_custom_target( lapackpp ALL DEPENDS lapackpp-cmd ) | ||
add_custom_command( OUTPUT lapackpp-cmd | ||
WORKING_DIRECTORY "${lapackpp_SOURCE_DIR}" | ||
COMMENT "Building LAPACK++" ) | ||
|
||
# Setup remaining configuration options and installation | ||
add_custom_command( OUTPUT lapackpp-cmd APPEND | ||
COMMAND ${CMAKE_COMMAND} | ||
-B "${lapackpp_BINARY_DIR}" | ||
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}" | ||
-D blaspp_DIR="${PROJECT_BINARY_DIR}/lib/cmake/blaspp" | ||
-D LAPACK_LIBRARIES="${LAPACK_LIBS}" | ||
-D build_tests=OFF | ||
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} | ||
|
||
COMMAND ${CMAKE_COMMAND} | ||
--build "${lapackpp_BINARY_DIR}" | ||
--config ${CMAKE_BUILD_TYPE} | ||
--target install | ||
) | ||
|
||
# Set up dependencies | ||
add_dependencies(lapackpp blaspp) | ||
endif() | ||
|
||
# -------------------------------------------------- | ||
|
@@ -551,47 +630,24 @@ install(FILES | |
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION} | ||
COMPONENT Development | ||
) | ||
|
||
if (LAPACK++) | ||
install( | ||
DIRECTORY "${LAPACK_BINARY_DIR}/lib/" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING REGEX "liblapackpp.(a|so)$" | ||
) | ||
install( | ||
DIRECTORY "${PROJECT_BINARY_DIR}/lapackpp-prefix/src/lapackpp/include/" | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
FILES_MATCHING REGEX "\\.(h|hh)$" | ||
DIRECTORY "${LAPACK_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING REGEX "lapackpp" | ||
) | ||
write_basic_package_version_file( | ||
"lapackppConfigVersion.cmake" | ||
VERSION 2020.10.02 | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
install( | ||
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/lapackpp/lapackppConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/lib/lapackpp/lapackppConfigVersion.cmake" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/" | ||
) | ||
|
||
endif() | ||
if (BLAS++) | ||
write_basic_package_version_file( | ||
"blasppConfigVersion.cmake" | ||
VERSION 2020.10.02 | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
install( | ||
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/blaspp/blasppConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/lib/blaspp/blasppConfigVersion.cmake" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/" | ||
) | ||
|
||
if (BLAS++ OR LAPACK++) | ||
install( | ||
DIRECTORY "${LAPACK_BINARY_DIR}/lib/" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING REGEX "libblaspp.(a|so)$" | ||
DIRECTORY "${LAPACK_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FILES_MATCHING REGEX "blaspp" | ||
) | ||
|
||
install( | ||
DIRECTORY "${PROJECT_BINARY_DIR}/blaspp-prefix/src/blaspp/include/" | ||
DIRECTORY "${LAPACK_BINARY_DIR}/include/" | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
FILES_MATCHING REGEX "\\.(h|hh)$" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want blaspp 91dd418fa910498cc03dee397826099914cc3185
and lapackpp 88088c33cd9467475e8f139f42d158620f11e64d
which have the fixes for Fortran strlen.
We will likely do a SLATE / BLAS++ / LAPACK++ bug fix release this month, but perhaps for that just update LAPACK right before the SC23 release.