diff --git a/CMakeLists.txt b/CMakeLists.txt index 0989aac209b1a55254adf6e3c5249749c81f550e..8b5bf385e9572f8c9ed5eecf869fdf270ce44b52 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 9cc75ad7adade6ef9a766e08c27906335d79be61..b49a8ec79aaf0b67ac73d105768862dd942f11f5 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 18cda8a36f0f10aed0802b87a8082b23e7c0991c..e316b7ab3ec7651761eb008a8490775d7a7ecf3f 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 e63988a310fc7afa17c5ff11d8093341c0844b3b..40bfd675ac375573ecd3db3ccd46ec64408e742a 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)