FindBLAS does not work with Intel MKL libraries
In FindBLAS.cmake, the macro check_fortran_function_exists() is used to check if BLAS library supports sgemm()
. The problem is this would not work with Intel MKL libraries.
in https://github.com/Kitware/CMake/blob/master/Modules/CheckFortranFunctionExists.cmake:
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f " program TESTFortran external ${FUNCTION} call ${FUNCTION}() end program TESTFortran " ) try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT )
under my setting, this is equivalent to
`
/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort testFortranCompiler.f ${MKLROOT}/lib/intel64/libmkl_blas95_ilp64.a `
where in testFortranCompiler.f
program TESTFortran external sgemm call sgemm() end program TESTFortran
which fails for two reasons:
-
ifort
recognize suffix.f
as fixed source form which the program is in free source form. Changing suffix to.f90
fixes this. - the correct linking given by https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor is:
`
/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort testFortranCompiler.f ${MKLROOT}/lib/intel64/libmkl_blas95_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl `
and this indeed compiles.
To resolve the second issue, it is needed to temporarily disable check_fortran_function_exists()
for BLA_VENDOR
is Intel*