From 2b760848e6851f19eb688951480edb1c4352f056 Mon Sep 17 00:00:00 2001 From: bobqianic <129547291+bobqianic@users.noreply.github.com> Date: Wed, 26 Jul 2023 00:15:08 +0800 Subject: [PATCH] cmake : enable OpenBLAS on Windows (#1128) Fixed the issue of not being able to find OpenBLAS on the Windows platform. Even though the name of the previously released binary file was whisper-blas-bin-x64.zip, BLAS was actually not enabled. After enabling, the inference speed can increase by 3-4 times. --- CMakeLists.txt | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c955d7427e1..b837d7a4259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,22 +136,33 @@ if (WHISPER_OPENBLAS) endif() if (WHISPER_BLAS) - set(BLA_STATIC 1) - set(BLA_VENDOR ${WHISPER_BLAS_VENDOR}) -# set(BLA_PREFER_PKGCONFIG 1) - set(BLA_SIZEOF_INTEGER 8) - find_package(BLAS) - - if(BLAS_FOUND) - message(STATUS "BLAS compatible library found") - message(STATUS "Libraries ${BLAS_LIBRARIES}") - set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS) - - include_directories(${BLAS_INCLUDE_DIRS}) - set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES}) - else() - message(WARNING "BLAS library was not found") - endif() + if (WIN32) + if(DEFINED ENV{OPENBLAS_PATH}) + set(BLAS_LIBRARIES $ENV{OPENBLAS_PATH}/lib/libopenblas.dll.a) + message(STATUS "Libraries ${BLAS_LIBRARIES}") + set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS) + include_directories($ENV{OPENBLAS_PATH}/include) + set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES}) + else () + message(WARNING "BLAS library was not found. Environment variable OPENBLAS_PATH not defined.") + endif () + else () + set(BLA_STATIC 1) + set(BLA_VENDOR ${WHISPER_BLAS_VENDOR}) + # set(BLA_PREFER_PKGCONFIG 1) + set(BLA_SIZEOF_INTEGER 8) + find_package(BLAS) + + if(BLAS_FOUND) + message(STATUS "BLAS compatible library found") + message(STATUS "Libraries ${BLAS_LIBRARIES}") + set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS) + include_directories(${BLAS_INCLUDE_DIRS}) + set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES}) + else() + message(WARNING "BLAS library was not found") + endif() + endif () endif () if (WHISPER_CUBLAS)