[shark] 03/12: added support for generic cblas libraries

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 80b817ce6598cb7c5bf40f64cb3ac6c809f42c89
Author: Oswin Krause <oswin.krause at di.ku.dk>
Date:   Mon Nov 16 11:21:22 2015 +0100

    added support for generic cblas libraries
---
 CMakeLists.txt | 31 +++++++++++++++++++++++--------
 cBlasCheck.cpp |  9 +++++++++
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec1335d..d4f3997 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -253,18 +253,33 @@ if( ENABLE_CBLAS )
 			CLAPACK_LIBRARY
 			ATLAS_LIBRARY
 		)
-		if(${CBLAS_LIBRARY} AND ${CLAPACK_LIBRARY} AND ${ATLAS_LIBRARY} )
+		#find the cblas.h include path
+		if(CBLAS_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})
+			get_filename_component(CBLAS_INCLUDES ${CBLAS_INCLUDES} PATH )
+		endif()
+
+		if( CBLAS_LIBRARY AND CLAPACK_LIBRARY AND ATLAS_LIBRARY AND CBLAS_INCLUDES)
+			set(CBLAS_VENDOR "ATLAS")
+			set(CBLAS_LIBRARIES ${CLAPACK_LIBRARY} ${CBLAS_LIBRARY} ${ATLAS_LIBRARY})
+		elseif( CBLAS_LIBRARY AND CBLAS_INCLUDES)
+			#check that we can compile a basic program with the libraries we have found
+			#vendor versions might come with additional libraries which would be bad.
+			try_compile(CBLAS_COMPILE 
+				"${PROJECT_BINARY_DIR}/cBlasCheck"
+				"${CMAKE_SOURCE_DIR}/cBlasCheck.cpp"
+				CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CBLAS_INCLUDES}"
+				LINK_LIBRARIES ${CBLAS_LIBRARY}
+			)
+			if(CBLAS_COMPILE)
+				set(CBLAS_VENDOR "GENERIC")
+				set(CBLAS_LIBRARIES ${CBLAS_LIBRARY})
+			else()
+				message(WARNING "Unknown CBLAS. Can not use it")
 			endif()
 		endif()
 	endif()
@@ -276,7 +291,7 @@ if( ENABLE_CBLAS )
 		list(APPEND LINK_LIBRARIES ${CBLAS_LIBRARIES})
 		include_directories ( ${CBLAS_INCLUDES} )
 	else()
-		message(STATUS "No CBLAS Library found. No fast linear Algebra used.")
+		message(STATUS "No usable CBLAS Library found. No fast linear Algebra used.")
 	endif()
 	
 	#Special setup for ATLAS
diff --git a/cBlasCheck.cpp b/cBlasCheck.cpp
new file mode 100644
index 0000000..9ae81e2
--- /dev/null
+++ b/cBlasCheck.cpp
@@ -0,0 +1,9 @@
+extern "C"{
+#include <cblas.h>
+}
+int main(){
+	float* x;
+	float* y;
+	int N,strideX,strideY;
+	float r= cblas_sdot(N, x, strideX, y, strideY);
+}
\ No newline at end of file

-- 
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