aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorZenix <zenixls2@gmail.com>2023-05-20 23:58:31 +0900
committerGitHub <noreply@github.com>2023-05-20 17:58:31 +0300
commitb8ee340abe4a46143eb8cc4a135b976856c9136c (patch)
tree96fa62bfa353b939c1950b78906c139efcec263e /CMakeLists.txt
parent9ecb30f9594f222d8318fb1e803a4c363b0c39e5 (diff)
feature : support blis and other blas implementation (#1536)
* feature: add blis support * feature: allow all BLA_VENDOR to be assigned in cmake arguments. align with whisper.cpp pr 927 * fix: version detection for BLA_SIZEOF_INTEGER, recover min version of cmake * Fix typo in INTEGER Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> * Fix: blas changes on ci --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt39
1 files changed, 16 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48e3238..1c9afed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,8 @@ endif()
# 3rd party libs
option(LLAMA_ACCELERATE "llama: enable Accelerate framework" ON)
-option(LLAMA_OPENBLAS "llama: use OpenBLAS" OFF)
+option(LLAMA_BLAS "llama: use BLAS" OFF)
+option(LLAMA_BLAS_VENDOR "llama: BLA_VENDOR from https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors" Generic)
option(LLAMA_CUBLAS "llama: use cuBLAS" OFF)
option(LLAMA_CLBLAST "llama: use CLBlast" OFF)
@@ -145,36 +146,28 @@ if (APPLE AND LLAMA_ACCELERATE)
endif()
endif()
-if (LLAMA_OPENBLAS)
+if (LLAMA_BLAS)
if (LLAMA_STATIC)
set(BLA_STATIC ON)
endif()
-
- set(BLA_VENDOR OpenBLAS)
+ if ($(CMAKE_VERSION) VERSION_GREATER_EQUAL 3.22)
+ set(BLA_SIZEOF_INTEGER 8)
+ endif()
+ set(BLA_VENDOR ${LLAMA_BLAS_VENDOR})
find_package(BLAS)
if (BLAS_FOUND)
- message(STATUS "OpenBLAS found")
+ message(STATUS "BLAS found, Libraries: ${BLAS_LIBRARIES}")
+ add_compile_options(${BLAS_LINKER_FLAGS})
add_compile_definitions(GGML_USE_OPENBLAS)
- add_link_options(${BLAS_LIBRARIES})
- set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} openblas)
-
- # find header file
- set(OPENBLAS_INCLUDE_SEARCH_PATHS
- /usr/include
- /usr/include/openblas
- /usr/include/openblas-base
- /usr/local/include
- /usr/local/include/openblas
- /usr/local/include/openblas-base
- /opt/OpenBLAS/include
- $ENV{OpenBLAS_HOME}
- $ENV{OpenBLAS_HOME}/include
- )
- find_path(OPENBLAS_INC NAMES cblas.h PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
- add_compile_options(-I${OPENBLAS_INC})
+ set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${BLAS_LIBRARIES})
+
+ message("${BLAS_LIBRARIES} ${BLAS_INCLUDE_DIRS}")
+ include_directories(${BLAS_INCLUDE_DIRS})
else()
- message(WARNING "OpenBLAS not found")
+ message(WARNING "BLAS not found, please refer to "
+ "https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors"
+ " to set correct LLAMA_BLAS_VENDOR")
endif()
endif()