From df17b9ce41cd94fa0e8a37fc96325c4f21c62f70 Mon Sep 17 00:00:00 2001 From: berenger-bramas <berenger-bramas@2616d619-271b-44dc-8df4-d4a8f33a7222> Date: Thu, 2 Feb 2012 15:04:04 +0000 Subject: [PATCH] Update the cmake (and the blas file) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@342 2616d619-271b-44dc-8df4-d4a8f33a7222 --- CMakeLists.txt | 5 ++-- Src/CMakeLists.txt | 8 +++++- Src/Utils/FBlas.hpp | 67 +++++++++++++++++++++++++------------------- Tests/CMakeLists.txt | 2 +- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0989aac20..8b5bf385e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) # check if compiling into source directories STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource) @@ -13,7 +13,6 @@ project(scalfmm) # ----------------------- ENABLE_LANGUAGE(CXX ) - # Options OPTION( SCALFMM_USE_CBLAS "Set to ON to build ScaFMM with BLAS" OFF ) OPTION( SCALFMM_USE_MPI "Set to ON to build ScaFMM with MPI" OFF ) @@ -62,7 +61,7 @@ if( SCALFMM_USE_CBLAS ) SET(CBLAS_LIBRARIES "-L$ENV{MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core") else() FIND_PACKAGE(BLAS) - SET(CBLAS_LIBRARIES "-lcblas") + SET(BLAS_LIBRARIES "-lcblas") endif() endif() diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 9cc75ad7a..b49a8ec79 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) # check if compiling into source directories STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource) @@ -25,6 +25,12 @@ add_library( ${source_lib_files} ) +# Add blas library (even if it is set to off) +target_link_libraries( + scalfmm + ${BLAS_LIBRARIES} +) + # Adding the entire project dir as an include dir INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/Src diff --git a/Src/Utils/FBlas.hpp b/Src/Utils/FBlas.hpp index 18cda8a36..e316b7ab3 100644 --- a/Src/Utils/FBlas.hpp +++ b/Src/Utils/FBlas.hpp @@ -12,6 +12,8 @@ #include "FGlobal.hpp" + + #ifdef SCALFMM_USE_CBLAS #ifdef SCALFMM_USE_MKL_AS_BLAS @@ -19,24 +21,43 @@ #else #include <cblas.h> #endif +#else + enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102}; + enum CBLAS_TRANSPOSE {CblasNoTrans, CblasTrans, CblasConjTrans}; +#endif + +template <typename T> +void cblas_gemv(const CBLAS_ORDER order , + const CBLAS_TRANSPOSE TransA , const int M , const int N , + const void *alpha , const void *A , const int lda , + const void *X , const int incX , const void *beta , + void *Y , const int incY){ +} +template <typename T> +void cblas_dotu_sub( const int N , const void *X , const int incX , + const void *Y , const int incY , void *dotu){ +} +#ifdef SCALFMM_USE_CBLAS /////////////////////////////////////////////////////// // GEMV /////////////////////////////////////////////////////// - void cblas_gemv(const CBLAS_ORDER order , - const CBLAS_TRANSPOSE TransA , const int M , const int N , - const double *alpha , const double *A , const int lda , - const double *X , const int incX , const double *beta , - double *Y , const int incY){ + template <> + void cblas_gemv<double>(const CBLAS_ORDER order , + const CBLAS_TRANSPOSE TransA , const int M , const int N , + const void *alpha , const void *A , const int lda , + const void *X , const int incX , const void *beta , + void *Y , const int incY){ cblas_zgemv(order,TransA,M,N,alpha,A,lda,X,incX,beta,Y,incY); } - void cblas_gemv(const CBLAS_ORDER order , - const CBLAS_TRANSPOSE TransA , const int M , const int N , - const float *alpha , const float *A , const int lda , - const float *X , const int incX , const float *beta , - float *Y , const int incY){ + template <> + void cblas_gemv<float>(const CBLAS_ORDER order , + const CBLAS_TRANSPOSE TransA , const int M , const int N , + const void *alpha , const void *A , const int lda , + const void *X , const int incX , const void *beta , + void *Y , const int incY){ cblas_cgemv(order,TransA,M,N,alpha,A,lda,X,incX,beta,Y,incY); } @@ -45,33 +66,21 @@ // Dotu /////////////////////////////////////////////////////// - void cblas_dotu_sub(const int N , const double *X , const int incX , - const double *Y , const int incY , double *dotu){ + template <> + void cblas_dotu_sub<double>(const int N , const void *X , const int incX , + const void *Y , const int incY , void *dotu){ cblas_zdotu_sub(N,X,incX,Y,incY,dotu); } - void cblas_dotu_sub(const int N , const float *X , const int incX , - const float *Y , const int incY , float *dotu){ + template <> + void cblas_dotu_sub<float>(const int N , const void *X , const int incX , + const void *Y , const int incY , void *dotu){ cblas_cdotu_sub(N,X,incX,Y,incY,dotu); } -#else - enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102}; - enum CBLAS_TRANSPOSE {CblasNoTrans, CblasTrans, CblasConjTrans}; +#endif //SCALFMM_USE_CBLAS - template <typename T> - void cblas_gemv(const CBLAS_ORDER order , - const CBLAS_TRANSPOSE TransA , const int M , const int N , - const void *alpha , const void *A , const int lda , - const void *X , const int incX , const void *beta , - void *Y , const int incY){ - } - template <typename T> - void cblas_dotu_sub( const int N , const void *X , const int incX , - const void *Y , const int incY , void *dotu){ - } -#endif //SCALFMM_USE_CBLAS #endif //FBLAS_HPP diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e63988a31..40bfd675a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) # check if compiling into source directories STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource) -- GitLab