Skip to content
Open
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
18 changes: 12 additions & 6 deletions FindLAPACK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ if( "ilp64" IN_LIST LAPACK_FIND_COMPONENTS AND "lp64" IN_LIST LAPACK_FIND_COMPON
message( FATAL_ERROR "LAPACK cannot link to both ILP64 and LP64 interfaces" )
endif()

# List of functions to check for valid LAPACK - overridable
if( NOT LAPACK_TEST_FUNCTIONS )
# use dpstrf to check for full LAPACK API ... some implementations are incomplete (e.g. older OpenBLAS)
# also need to handle several corner cases:
# - OpenBLAS needs libgfortran only for some functions, dpstrf is not one of them, so check for dgesvd
set( LAPACK_TEST_FUNCTIONS "dpstrf;dgesvd" )
endif()


# Get list of required / optional components
foreach( _comp ${LAPACK_FIND_COMPONENTS} )
Expand Down Expand Up @@ -50,10 +58,8 @@ if( NOT LAPACK_LIBRARIES )
set( LAPACK_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS} )
set( LAPACK_COMPILE_DEFINITIONS ${BLAS_COMPILE_DEFINITIONS} )

# use dpstrf to check for full LAPACK API ... some implementations are incomplete (e.g. older OpenBLAS)
# also need to handle several corner cases:
# - OpenBLAS needs libgfortran only for some functions, dpstrf is not one of them, so check for dgesvd
check_fortran_functions_exist( "dpstrf;dgesvd" LAPACK LAPACK_LIBRARIES
# Check for required LAPACK functions
check_fortran_functions_exist( "${LAPACK_TEST_FUNCTIONS}" LAPACK LAPACK_LIBRARIES
BLAS_HAS_LAPACK LAPACK_Fortran_LOWER LAPACK_Fortran_UNDERSCORE
)

Expand Down Expand Up @@ -123,8 +129,8 @@ endif()
if( BLAS_HAS_LAPACK )
set( LAPACK_LINK_OK TRUE )
else()
# see notes above the first invocation of check_fortran_functions_exist
check_fortran_functions_exist( "dpstrf;dgesvd" LAPACK LAPACK_LIBRARIES
# Check for required LAPACK functions
check_fortran_functions_exist( "${LAPACK_TEST_FUNCTIONS}" LAPACK LAPACK_LIBRARIES
LAPACK_LINK_OK LAPACK_Fortran_LOWER LAPACK_Fortran_UNDERSCORE
)
endif()
Expand Down
32 changes: 17 additions & 15 deletions FindOpenBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ find_library( OpenBLAS_LIBRARIES
)

find_path( OpenBLAS_INCLUDE_DIR
NAMES openblas_config.h
NAMES openblas/openblas_config.h openblas_config.h
HINTS ${OpenBLAS_PREFIX}
PATHS ${OpenBLAS_INCLUDE_DIR}
PATH_SUFFIXES include
DOC "OpenBLAS header"
)

#if( OpenBLAS_LIBRARY AND OpenBLAS_PREFERS_STATIC )
# include( CMakeFindDependency )
# find_package( Threads QUIET )
# set( OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY} Threads::Threads "m")
#endif()
if( OpenBLAS_LIBRARY AND OpenBLAS_PREFERS_STATIC )
include( CMakeFindDependency )
find_package( Threads QUIET )
set( OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY} Threads::Threads "m")
endif()

# check ILP64
if( OpenBLAS_INCLUDE_DIR )
Expand All @@ -42,6 +42,8 @@ if( OpenBLAS_INCLUDE_DIR )
COMPILE_OUTPUT_VARIABLE _openblas_idx_compile_output
RUN_OUTPUT_VARIABLE _openblas_idx_run_output
)
message( STATUS ${_openblas_idx_compile_output} )
message( STATUS ${_openblas_idx_run_output} )

if( ${OpenBLAS_USES_LP64} EQUAL 0 )
set( OpenBLAS_USES_LP64 TRUE )
Expand All @@ -67,12 +69,12 @@ find_package_handle_standard_args( OpenBLAS
HANDLE_COMPONENTS
)

#if( OpenBLAS_FOUND AND NOT TARGET OpenBLAS::OpenBLAS )
#
# add_library( OpenBLAS::OpenBLAS INTERFACE IMPORTED )
# set_target_properties( OpenBLAS::OpenBLAS PROPERTIES
# INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}"
# INTERFACE_LINK_LIBRARIES "${OpenBLAS_LIBRARIES}"
# )
#
#endif()
if( OpenBLAS_FOUND AND NOT TARGET OpenBLAS::OpenBLAS )

add_library( OpenBLAS::OpenBLAS INTERFACE IMPORTED )
set_target_properties( OpenBLAS::OpenBLAS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OpenBLAS_LIBRARIES}"
)

endif()
6 changes: 5 additions & 1 deletion util/openblas_int_size.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#if __has_include(<openblas_config.h>)
#include <openblas_config.h>
#else
#include <openblas/openblas_config.h>
#endif

int main() {
int main(int argc, char** argv) {
int blis_int_size = sizeof(blasint)*8;
if( blis_int_size == 32 ) return 0;
else return 1;
Expand Down