From: bobqianic Date: Tue, 25 Jul 2023 16:15:08 +0000 (+0800) Subject: cmake : enable OpenBLAS on Windows (#1128) X-Git-Tag: upstream/1.7.4~1371 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a195bf899a9f5cb58316d76f99ff7ccbea4586dc;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c955d742..b837d7a4 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)