mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 14:53:03 +00:00 
			
		
		
		
	Use OpenBLAS instead of BLAS if available. OpenBLAS is an optimized BLAS
library.
This commit is contained in:
		| @@ -562,9 +562,10 @@ endif(DOXYGEN_FOUND) | |||||||
| ################################################################################ | ################################################################################ | ||||||
|  |  | ||||||
| if(OS_IS_LINUX) | if(OS_IS_LINUX) | ||||||
|     ############################################# |     ############################################################################# | ||||||
|     # Check that LAPACK is found in the system  |     # Check that LAPACK is found in the system  | ||||||
|     ############################################# |     # LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse. | ||||||
|  |     ############################################################################# | ||||||
|     find_library(LAPACK lapack) |     find_library(LAPACK lapack) | ||||||
|     if(NOT LAPACK) |     if(NOT LAPACK) | ||||||
|         message(" The LAPACK library has not been found.") |         message(" The LAPACK library has not been found.") | ||||||
| @@ -578,9 +579,11 @@ if(OS_IS_LINUX) | |||||||
|         endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") |         endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") | ||||||
|         message(FATAL_ERROR "LAPACK is required to build gnss-sdr") |         message(FATAL_ERROR "LAPACK is required to build gnss-sdr") | ||||||
|     endif(NOT LAPACK) |     endif(NOT LAPACK) | ||||||
|     ############################################# |     ############################################################################# | ||||||
|     # Check that BLAS is found in the system |     # Check that BLAS is found in the system | ||||||
|     ############################################# |     # BLAS is used for matrix multiplication. | ||||||
|  |     #<23>Without BLAS, matrix multiplication will still work, but might be slower. | ||||||
|  |     ############################################################################# | ||||||
|     find_library(BLAS blas) |     find_library(BLAS blas) | ||||||
|     if(NOT BLAS) |     if(NOT BLAS) | ||||||
|         message(" The BLAS library has not been found.") |         message(" The BLAS library has not been found.") | ||||||
| @@ -668,7 +671,11 @@ if(NOT ARMADILLO_FOUND) | |||||||
| "12c12 | "12c12 | ||||||
| < // #define ARMA_USE_LAPACK | < // #define ARMA_USE_LAPACK | ||||||
| --- | --- | ||||||
| >    #define ARMA_USE_LAPACK  | >    #define ARMA_USE_LAPACK | ||||||
|  | 19c19 | ||||||
|  | < // #define ARMA_USE_BLAS | ||||||
|  | --- | ||||||
|  | >    #define ARMA_USE_BLAS | ||||||
| ")  | ")  | ||||||
|      endif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/download/armadillo-${armadillo_RELEASE}/armadillo-${armadillo_RELEASE}.tar.gz) |      endif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/download/armadillo-${armadillo_RELEASE}/armadillo-${armadillo_RELEASE}.tar.gz) | ||||||
|      ExternalProject_Add( |      ExternalProject_Add( | ||||||
| @@ -689,7 +696,11 @@ if(NOT ARMADILLO_FOUND) | |||||||
|      ExternalProject_Get_Property(armadillo-${armadillo_RELEASE} binary_dir) |      ExternalProject_Get_Property(armadillo-${armadillo_RELEASE} binary_dir) | ||||||
|      set(ARMADILLO_INCLUDE_DIRS ${binary_dir}/include )      |      set(ARMADILLO_INCLUDE_DIRS ${binary_dir}/include )      | ||||||
|      find_library(LAPACK NAMES lapack HINTS /usr/lib /usr/local/lib /usr/lib64) |      find_library(LAPACK NAMES lapack HINTS /usr/lib /usr/local/lib /usr/lib64) | ||||||
|      set(ARMADILLO_LIBRARIES ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo.a) |      find_package(OpenBLAS) | ||||||
|  |      if(OPENBLAS_FOUND) | ||||||
|  |          set(BLAS OPENBLAS) | ||||||
|  |      endif(OPENBLAS_FOUND) | ||||||
|  |      set(ARMADILLO_LIBRARIES ${BLAS} ${LAPACK} ${GFORTRAN} ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo.a) | ||||||
|      set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE) |      set(LOCAL_ARMADILLO true CACHE STRING "Armadillo downloaded and built automatically" FORCE) | ||||||
|      # Save a copy at the thirdparty folder |      # Save a copy at the thirdparty folder | ||||||
|      file(COPY ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} |      file(COPY ${CMAKE_CURRENT_BINARY_DIR}/armadillo-${armadillo_RELEASE} | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								cmake/Modules/FindOpenBLAS.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								cmake/Modules/FindOpenBLAS.cmake
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | |||||||
|  | # - Try to find OpenBLAS library (not headers!) | ||||||
|  | # | ||||||
|  | # The following environment variable is optionally searched  | ||||||
|  | # OPENBLAS_HOME: Base directory where all OpenBlas components are found | ||||||
|  |  | ||||||
|  | SET(OPEN_BLAS_SEARCH_PATHS  /lib/  | ||||||
|  |                             /lib64/   | ||||||
|  |                             /usr/lib  | ||||||
|  |                             /usr/lib64  | ||||||
|  |                             /usr/local/lib  | ||||||
|  |                             /usr/local/lib64  | ||||||
|  |                             /opt/OpenBLAS/lib  | ||||||
|  |                             /opt/local/lib  | ||||||
|  |                             /usr/lib/openblas-base  | ||||||
|  |                             $ENV{OPENBLAS_HOME}/lib  | ||||||
|  |                             ) | ||||||
|  |                              | ||||||
|  | FIND_LIBRARY(OPENBLAS NAMES openblas PATHS ${OPEN_BLAS_SEARCH_PATHS}) | ||||||
|  |  | ||||||
|  | IF (OPENBLAS) | ||||||
|  |     SET(OPENBLAS_FOUND ON) | ||||||
|  |     MESSAGE(STATUS "Found OpenBLAS") | ||||||
|  | ENDIF (OPENBLAS) | ||||||
|  |  | ||||||
|  | MARK_AS_ADVANCED(OPENBLAS) | ||||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez