prioritize Accelerate over OpenBLAS (#11812)
Summary:
might fix some binary build issues
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11812
Reviewed By: ezyang
Differential Revision: D9927309
Pulled By: soumith
fbshipit-source-id: 9ed6c2c6fedc2a1cffbf52bc0a795135d4239800
diff --git a/cmake/Modules/FindBLAS.cmake b/cmake/Modules/FindBLAS.cmake
index c51f17b..7f1761a 100644
--- a/cmake/Modules/FindBLAS.cmake
+++ b/cmake/Modules/FindBLAS.cmake
@@ -105,6 +105,34 @@
ENDIF(MKL_FOUND)
endif()
+# Apple BLAS library?
+if((NOT BLAS_LIBRARIES)
+ AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "accelerate")))
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "Accelerate")
+ if (BLAS_LIBRARIES)
+ set(BLAS_INFO "accelerate")
+ set(BLAS_IS_ACCELERATE 1)
+ endif (BLAS_LIBRARIES)
+endif()
+
+if((NOT BLAS_LIBRARIES)
+ AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "veclib")))
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "vecLib")
+ if (BLAS_LIBRARIES)
+ set(BLAS_INFO "veclib")
+ endif (BLAS_LIBRARIES)
+endif()
+
if((NOT BLAS_LIBRARIES)
AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "open")))
check_fortran_libraries(
@@ -183,34 +211,6 @@
endif (BLAS_LIBRARIES)
endif()
-# Apple BLAS library?
-if((NOT BLAS_LIBRARIES)
- AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "accelerate")))
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "Accelerate")
- if (BLAS_LIBRARIES)
- set(BLAS_INFO "accelerate")
- set(BLAS_IS_ACCELERATE 1)
- endif (BLAS_LIBRARIES)
-endif()
-
-if((NOT BLAS_LIBRARIES)
- AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "veclib")))
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "vecLib")
- if (BLAS_LIBRARIES)
- set(BLAS_INFO "veclib")
- endif (BLAS_LIBRARIES)
-endif()
-
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
if((NOT BLAS_LIBRARIES)
AND ((NOT WITH_BLAS) OR (WITH_BLAS STREQUAL "atlas")))
diff --git a/cmake/Modules/FindLAPACK.cmake b/cmake/Modules/FindLAPACK.cmake
index 9641c45..99c8d34 100644
--- a/cmake/Modules/FindLAPACK.cmake
+++ b/cmake/Modules/FindLAPACK.cmake
@@ -95,6 +95,28 @@
SET(LAPACK_INFO "mkl")
ENDIF()
+ # Accelerate
+ IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "accelerate"))
+ SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
+ check_function_exists("cheev_" ACCELERATE_LAPACK_WORKS)
+ if(ACCELERATE_LAPACK_WORKS)
+ SET(LAPACK_INFO "accelerate")
+ else()
+ message(STATUS "Strangely, this Accelerate library does not support Lapack?!")
+ endif()
+ endif()
+
+ # vecLib
+ IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "veclib"))
+ SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
+ check_function_exists("cheev_" VECLIB_LAPACK_WORKS)
+ if(VECLIB_LAPACK_WORKS)
+ SET(LAPACK_INFO "veclib")
+ else()
+ message(STATUS "Strangely, this vecLib library does not support Lapack?!")
+ endif()
+ endif()
+
# OpenBlas
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "open"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
@@ -128,28 +150,6 @@
endif()
endif()
- # Accelerate
- IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "accelerate"))
- SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
- check_function_exists("cheev_" ACCELERATE_LAPACK_WORKS)
- if(ACCELERATE_LAPACK_WORKS)
- SET(LAPACK_INFO "accelerate")
- else()
- message(STATUS "Strangely, this Accelerate library does not support Lapack?!")
- endif()
- endif()
-
- # vecLib
- IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "veclib"))
- SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
- check_function_exists("cheev_" VECLIB_LAPACK_WORKS)
- if(VECLIB_LAPACK_WORKS)
- SET(LAPACK_INFO "veclib")
- else()
- message(STATUS "Strangely, this vecLib library does not support Lapack?!")
- endif()
- endif()
-
# Generic LAPACK library?
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "generic"))
check_lapack_libraries(