diff --git a/cmake/cblas.cmake b/cmake/cblas.cmake index bb084192f86b92683cc3e331390264b356e0ac7b..913f711afff3b8f9f77b8da978a3b9e7165d0077 100644 --- a/cmake/cblas.cmake +++ b/cmake/cblas.cmake @@ -110,6 +110,7 @@ if(OPENBLAS_LAPACKE_INC_DIR AND OPENBLAS_INC_DIR AND OPENBLAS_LIB) set(CBLAS_INC_DIR ${OPENBLAS_INC_DIR} ${OPENBLAS_LAPACKE_INC_DIR}) set(CBLAS_LIBRARIES ${OPENBLAS_LIB}) + add_definitions(-DPADDLE_USE_OPENBLAS) add_definitions(-DLAPACK_FOUND) message(STATUS "Found OpenBLAS (include: ${OPENBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") @@ -146,6 +147,6 @@ if (REFERENCE_CBLAS_INCLUDE_DIR AND REFERENCE_CBLAS_LIBRARY) set(CBLAS_PROVIDER REFERENCE) set(CBLAS_INC_DIR ${REFERENCE_CBLAS_INCLUDE_DIR}) set(CBLAS_LIBRARIES ${REFERENCE_CBLAS_LIBRARY}) - + add_definitions(-DPADDLE_USE_REFERENCE_CBLAS) message(STATUS "Found reference-cblas (include: ${CBLAS_INC_DIR}, library: ${CBLAS_LIBRARIES})") endif() diff --git a/cmake/external/openblas.cmake b/cmake/external/openblas.cmake index 5b042fec01288a1cdfb2bb4400d9c99f41fc6ac2..18ac74aa6f7531c4001fe91960f8332619c99342 100644 --- a/cmake/external/openblas.cmake +++ b/cmake/external/openblas.cmake @@ -36,7 +36,7 @@ IF(NOT ${CBLAS_FOUND}) INSTALL_DIR ${CBLAS_INSTALL_DIR} BUILD_IN_SOURCE 1 BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} FC=${CMAKE_Fortran_COMPILER} CC=${CMAKE_C_COMPILER} HOSTCC=${CMAKE_C_COMPILER} NO_LAPACK=1 DYNAMIC_ARCH=1 NO_SHARED=1 libs netlib - INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install NO_SHARED=1 PREFIX= + INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install NO_SHARED=1 NO_LAPACK=1 PREFIX= UPDATE_COMMAND "" CONFIGURE_COMMAND "" ) diff --git a/paddle/math/MathFunctions.h b/paddle/math/MathFunctions.h index c8559eefd8378450fc18c2ba821c65b39c8cc046..c1d233b6cbd9189e92192c3b4ad15823d58298cb 100644 --- a/paddle/math/MathFunctions.h +++ b/paddle/math/MathFunctions.h @@ -18,17 +18,36 @@ limitations under the License. */ #ifdef PADDLE_USE_MKL #include #include -#else -extern "C" { -#include -} +#endif + #ifdef PADDLE_USE_ATLAS extern "C" { +#include #include } -#else +#endif + +#ifdef PADDLE_USE_OPENBLAS +#include #include #endif + +#ifdef PADDLE_USE_REFERENCE_CBLAS +extern "C" { +#include +} +#endif + +#ifndef LAPACK_FOUND +extern "C" { +int LAPACKE_sgetrf(int matrix_layout, int m, int n, +int LAPACKE_dgetrf(int matrix_layout, int m, int n, + double* a, int lda, int* ipiv); +int LAPACKE_sgetri(int matrix_layout, int n, float* a, + int lda, const int* ipiv); +int LAPACKE_dgetri(int matrix_layout, int n, double* a, + int lda, const int* ipiv); +} #endif #include diff --git a/paddle/math/tests/test_matrixCompare.cpp b/paddle/math/tests/test_matrixCompare.cpp index 2bdcab4d8665cba9a81ddbf0081ccf81f09db8f8..5a0dffe086c4e265d17c79dba435b66c0873e3c7 100644 --- a/paddle/math/tests/test_matrixCompare.cpp +++ b/paddle/math/tests/test_matrixCompare.cpp @@ -247,7 +247,7 @@ TEST(Matrix, unary) { << "1. Simply issue `sudo apt-get install liblapacke-dev` to " "avoid re-build source code. \n" << "2. Install MKL/Openblas/ATLAS and re-build PaddlePaddle " - "source code." + "source code."; #endif } }