Skip to content
Snippets Groups Projects
Commit 64cf828f authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed linking to a BLAS library on Centos systems

parent c11b5805
No related branches found
No related tags found
1 merge request!47Linear solvers
......@@ -5,16 +5,28 @@ else()
add_executable( tnl-benchmark-blas tnl-benchmark-blas.cpp )
endif()
find_library( CBLAS_LIBRARY NAMES cblas
PATHS /usr/lib
/usr/lib64
/usr/lib/x86_64-linux-gnu
/usr/local/lib
/usr/local/lib64 )
find_library( CBLAS_LIBRARY NAMES cblas )
# fallback for Centos 7.5 - libcblas.so does not exist, link to libtatlas.so or libsatlas.so
# https://forums.centos.org/viewtopic.php?t=48543
find_library( TATLAS_LIBRARY NAMES tatlas
PATH_SUFFIXES atlas )
find_library( SATLAS_LIBRARY NAMES satlas
PATH_SUFFIXES atlas )
if( CBLAS_LIBRARY )
target_compile_definitions( tnl-benchmark-blas PUBLIC "-DHAVE_BLAS" )
target_link_libraries( tnl-benchmark-blas ${CBLAS_LIBRARY} )
elseif( TATLAS_LIBRARY )
target_compile_definitions( tnl-benchmark-blas PUBLIC "-DHAVE_BLAS" )
target_link_libraries( tnl-benchmark-blas ${TATLAS_LIBRARY} )
elseif( SATLAS_LIBRARY )
target_compile_definitions( tnl-benchmark-blas PUBLIC "-DHAVE_BLAS" )
target_link_libraries( tnl-benchmark-blas ${SATLAS_LIBRARY} )
else()
# FIXME: We require the CBLAS interface, but CMake's FindBLAS cannot detect that,
# so this fails unless the BLAS implementation includes it in the same
# shared library file as the Fortran implementation (e.g. OpenBLAS does that).
find_package( BLAS )
if( BLAS_FOUND )
target_compile_definitions( tnl-benchmark-blas PUBLIC "-DHAVE_BLAS" )
......
......@@ -2,7 +2,13 @@
#ifdef HAVE_BLAS
// HOTFIX: cblas.h from the atlas-devel package (version 3.10.1-12.el7) on CentOS 7
// does not declare the functions as `extern "C"`, which breaks name mangling.
// Note that nested `extern "C"` is valid and correct:
// https://stackoverflow.com/questions/48099828/what-happens-if-you-nest-extern-c
extern "C" {
#include <cblas.h>
}
inline int blasIgamax( int n, const float *x, int incx )
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment