Skip to content

Compilation of LAPACKE possibly independent from Fortran #834

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,34 @@ jobs:
echo "Coverage"
cmake --build build --target coverage
bash <(curl -s https://codecov.io/bash) -X gcov

test-install-cblas-lapacke-without-fortran-compiler:
runs-on: ubuntu-latest
steps:
- name: Checkout LAPACK
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0 # v3

- name: Install basics
run: |
sudo apt update
sudo apt install -y cmake liblapack-dev libblas-dev
sudo apt purge gfortran

- name: Configure CMake
run: >
cmake -B build -G Ninja
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/lapack_install
-D CBLAS:BOOL=ON
-D LAPACKE:BOOL=ON
-D USE_OPTIMIZED_BLAS:BOOL=ON
-D USE_OPTIMIZED_LAPACK:BOOL=ON
-D BUILD_TESTING:BOOL=OFF
-D LAPACKE_WITH_TMG:BOOL=OFF
-D BUILD_SHARED_LIBS:BOOL=ON

- name: Install
run: cmake --build build --target install -j2
6 changes: 6 additions & 0 deletions BLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
enable_language(Fortran)

# Check for any necessary platform specific compiler flags
include(CheckLAPACKCompilerFlags)
CheckLAPACKCompilerFlags()

add_subdirectory(SRC)
if(BUILD_TESTING)
add_subdirectory(TESTING)
Expand Down
19 changes: 12 additions & 7 deletions CBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
message(STATUS "CBLAS enable")
message(STATUS "CBLAS enabled")
enable_language(C)

set(LAPACK_INSTALL_EXPORT_NAME ${CBLASLIB}-targets)

# Create a header file cblas.h for the routines called in my C programs
include(FortranCInterface)
## Ensure that the fortran compiler and c compiler specified are compatible
FortranCInterface_VERIFY()
FortranCInterface_HEADER(${LAPACK_BINARY_DIR}/include/cblas_mangling.h
MACRO_NAMESPACE "F77_"
SYMBOL_NAMESPACE "F77_")
include(CheckLanguage)
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
include(FortranCInterface)
## Ensure that the fortran compiler and c compiler specified are compatible
FortranCInterface_VERIFY()
FortranCInterface_HEADER(${LAPACK_BINARY_DIR}/include/cblas_mangling.h
MACRO_NAMESPACE "F77_"
SYMBOL_NAMESPACE "F77_")
endif()
if(NOT FortranCInterface_GLOBAL_FOUND OR NOT FortranCInterface_MODULE_FOUND)
message(WARNING "Reverting to pre-defined include/cblas_mangling.h")
configure_file(include/cblas_mangling_with_flags.h.in
Expand Down
80 changes: 80 additions & 0 deletions CMAKE/CheckLAPACKCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,26 @@ if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]")
set( FPE_EXIT TRUE )
endif()
if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-frecursive") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -frecursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

# Intel Fortran
elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "[-/]fpe(-all=|)0" )
set( FPE_EXIT TRUE )
endif()

if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-recursive") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-fp-model[ \t]strict") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict")
endif()

# SunPro F95
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
if( ("${CMAKE_Fortran_FLAGS}" MATCHES "-ftrap=") AND
Expand All @@ -74,13 +87,33 @@ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
CACHE STRING "Flags for Fortran compiler." FORCE )
endif()

if(UNIX)
# Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler.
# This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin
string(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
endif()

# IBM XL Fortran
elseif( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6
(CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8
if( "${CMAKE_Fortran_FLAGS}" MATCHES "-qflttrap=[a-zA-Z:]:enable" )
set( FPE_EXIT TRUE )
endif()

if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qrecur") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qrecur"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qnosave") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave")
endif()


if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qstrict") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qstrict")
endif()

# HP Fortran
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "HP" )
if( "${CMAKE_Fortran_FLAGS}" MATCHES "\\+fp_exception" )
Expand Down Expand Up @@ -138,6 +171,11 @@ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=unused")
endif()

if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-recursive") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

# Suppress compiler banner and summary
check_fortran_compiler_flag("-quiet" _quiet)
if( _quiet AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]quiet") )
Expand All @@ -155,7 +193,49 @@ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Kieee")
endif()

if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-Mrecursive") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

# Flang Fortran
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Flang" )
if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-Mrecursive") )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive"
CACHE STRING "Recursive flag must be set" FORCE)
endif()

# Compaq Fortran
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq")
if(WIN32)
if(CMAKE_GENERATOR STREQUAL "NMake Makefiles")
get_filename_component(CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE)
message(STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM}")
set(cmd ${CMAKE_Fortran_COMPILER_CMDNAM})
string(TOLOWER "${cmd}" cmdlc)
if(cmdlc STREQUAL "df")
message(STATUS "Assume the Compaq Visual Fortran Compiler is being used")
set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1)
#This is a workaround that is needed to avoid forward-slashes in the
#filenames listed in response files from incorrectly being interpreted as
#introducing compiler command options
if(${BUILD_SHARED_LIBS})
message(FATAL_ERROR "Making of shared libraries with CVF has not been tested.")
endif()
set(str "NMake version 9 or later should be used. NMake version 6.0 which is\n")
set(str "${str} included with the CVF distribution fails to build Lapack because\n")
set(str "${str} the number of source files exceeds the limit for NMake v6.0\n")
message(STATUS ${str})
set(CMAKE_Fortran_LINK_EXECUTABLE "LINK /out:<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>")
endif()
endif()
endif()

else()
message(WARNING "Fortran local arrays should be allocated on the stack."
" Please use a compiler which guarantees that feature."
" See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein.")
endif()

if( "${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "O[3-9]" )
Expand Down
Loading