[shark] 02/12: restructured finding ATLAS/Accelerate a little to make it easier to add future CBLAS packages

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Dec 10 19:48:13 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository shark.

commit 74ec2bfa0758374ce97bb56d919fe027b92658ca
Author: Oswin Krause <oswin.krause at di.ku.dk>
Date:   Mon Nov 9 12:54:51 2015 +0100

    restructured finding ATLAS/Accelerate a little to make it easier to add future CBLAS packages
---
 CMakeLists.txt | 90 ++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 50 insertions(+), 40 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5ab6fc..ec1335d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -228,59 +228,69 @@ endif()
 #           ATLAS configuration
 #####################################################################
 
-if (APPLE)
-	option( ENABLE_ACCELERATE "Use Accelerate as Linear Algebra Library" ON )
-	if ( ENABLE_ACCELERATE )
-		set( SHARK_USE_CBLAS 1)          # most linear algebra routines
-		message(STATUS "Using the Accelerate framework")
-		list(APPEND LINK_LIBRARIES "-framework Accelerate" )
-	endif()
-else()
-	option(ENABLE_ATLAS "Use ATLAS as Linear Algebra Library" ON)
-	option(ATLAS_FULL_LAPACK "Signalizes whether ATLAS comes with the full LAPACK package" OFF)
 
-	if(ENABLE_ATLAS)
+option( ENABLE_CBLAS "Use Installed Linear Algebra Library" ON )
+
+if( ENABLE_CBLAS )
+	set(CBLAS_VENDOR FALSE)
+	if( APPLE )
+		set(CBLAS_VENDOR "Accelerate")
+		set(CBLAS_INCLUDES "")
+		set(CBLAS_LIBRARIES "-framework Accelerate" )
+	else()
+		#todo: do a propper vendor check
 		find_library(CBLAS_LIBRARY cblas
-			HINTS ${ATLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
+			HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
 		)
-
 		find_library(CLAPACK_LIBRARY lapack
-			HINTS ${ATLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
+			HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
 		)
-
 		find_library(ATLAS_LIBRARY atlas
-			HINTS ${ATLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
+			HINTS ${ATLAS_ROOT}/lib ${CBLAS_ROOT}/lib /opt/local/lib /usr/lib64/atlas/
 		)
-
-		get_filename_component(ATLAS_PATH ${CBLAS_LIBRARY} PATH )
-		set(ATLAS_PATH ${ATLAS_PATH}/..)
 		mark_as_advanced(
 			CBLAS_LIBRARY
 			CLAPACK_LIBRARY
 			ATLAS_LIBRARY
 		)
-
-		if(CBLAS_LIBRARY)
-			message(STATUS "ATLAS found.")
-			list(APPEND LINK_LIBRARIES ${CLAPACK_LIBRARY} ${CBLAS_LIBRARY} ${ATLAS_LIBRARY})
-			set( SHARK_USE_CBLAS 1)
-			set( SHARK_USE_ATLAS_LAPACK 1)
-			if( ATLAS_FULL_LAPACK )
-				set( SHARK_USE_LAPACK 1)
-			endif()
-			if( ATLAS_ROOT )
-				message(STATUS "ATLAS root: " ${ATLAS_ROOT})
-				list(APPEND EXTRA_INCLUDE_DIRECTORIES ${ATLAS_ROOT}/include/)
-				list(APPEND EXTRA_INCLUDE_DIRECTORIES ${ATLAS_ROOT}/include/atlas/)
-				include_directories ( ${ATLAS_ROOT}/include/ ${ATLAS_ROOT}/include/atlas/ )
-			else()
-				message(STATUS "ATLAS path: " ${ATLAS_PATH})
-				list(APPEND EXTRA_INCLUDE_DIRECTORIES ${ATLAS_PATH}/include/atlas/)
-				list(APPEND EXTRA_INCLUDE_DIRECTORIES ${ATLAS_PATH}/include/atlas/)
-				include_directories ( ${ATLAS_PATH}/include/ ${ATLAS_PATH}/include/atlas/ )
+		if(${CBLAS_LIBRARY} AND ${CLAPACK_LIBRARY} AND ${ATLAS_LIBRARY} )
+			get_filename_component(CBLAS_LIB_PATH ${CBLAS_LIBRARY} PATH )
+			
+			#find the cblas.h include path
+			find_file(CBLAS_INCLUDES cblas.h 
+				PATHS ${CBLAS_LIB_PATH} ${CBLAS_LIB_PATH}../include ${CBLAS_LIB_PATH}../include/atlas
+			)
+			
+			if(CBLAS_INCLUDES)
+				get_filename_component(CBLAS_INCLUDES ${CBLAS_INCLUDES} PATH )
+				set(CBLAS_VENDOR "ATLAS")
+				set(CBLAS_LIBRARIES ${CLAPACK_LIBRARY} ${CBLAS_LIBRARY} ${ATLAS_LIBRARY})
 			endif()
-		else()
-			message(STATUS "ATLAS not found, no fast linear algebra used.")
+		endif()
+	endif()
+	
+	if(CBLAS_VENDOR)
+		message(STATUS "CBLAS FOUND: " ${CBLAS_VENDOR} " with include directory " ${CBLAS_INCLUDES} )
+		set(SHARK_USE_CBLAS 1)
+		list(APPEND EXTRA_INCLUDE_DIRECTORIES ${CBLAS_INCLUDES} )
+		list(APPEND LINK_LIBRARIES ${CBLAS_LIBRARIES})
+		include_directories ( ${CBLAS_INCLUDES} )
+	else()
+		message(STATUS "No CBLAS Library found. No fast linear Algebra used.")
+	endif()
+	
+	#Special setup for ATLAS
+	if( CBLAS_VENDOR MATCHES "ATLAS" )
+		set( SHARK_USE_ATLAS_LAPACK 1) # ATLAS always contains some LAPACK methods that we can use
+		
+		#check for full lapack
+		set(CMAKE_REQUIRE_QUIET 1)
+		set(CMAKE_REQUIRED_LIBRARIES ${CBLAS_LIBRARIES})
+		check_function_exists(dsyev_ ATLAS_FULL_LAPACK)
+		
+		if( ATLAS_FULL_LAPACK )
+			set( SHARK_USE_LAPACK 1)
+			message(STATUS "Detected ATLAS with full LAPACK package. Using it!")
 		endif()
 	endif()
 endif()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/shark.git



More information about the debian-science-commits mailing list