]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ggml : fix buidling with Intel MKL but ask for "cblas.h" issue (#2104) (#2115)
authorclyang <redacted>
Sun, 9 Jul 2023 08:12:20 +0000 (16:12 +0800)
committerGitHub <redacted>
Sun, 9 Jul 2023 08:12:20 +0000 (11:12 +0300)
* Fix buidling with Intel MKL but ask for "cblas.h" issue

* Use angle brackets to indicate the system library

CMakeLists.txt
ggml.c

index a2404548f90d42f4266fbdb05fd1a13352dc0d00..eed7b1b7bed9ee2ee21b3b1983e4f37cc0cfb578 100644 (file)
@@ -217,6 +217,9 @@ if (LLAMA_BLAS)
         message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}")
         add_compile_options(${BLAS_LINKER_FLAGS})
         add_compile_definitions(GGML_USE_OPENBLAS)
+        if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${LLAMA_BLAS_VENDOR} MATCHES "Generic" OR ${LLAMA_BLAS_VENDOR} MATCHES "Intel"))
+            add_compile_definitions(GGML_BLAS_USE_MKL)
+        endif()
         set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${BLAS_LIBRARIES})
         set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${BLAS_INCLUDE_DIRS})
 
diff --git a/ggml.c b/ggml.c
index 55b0aff03bf166d6629eb46e9de07ef7d486ddfe..c10877a761dd821dd44b32b827e88863e4909fe4 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -247,7 +247,11 @@ inline static void* ggml_aligned_malloc(size_t size) {
 #include "ggml-opencl.h"
 #endif
 #elif defined(GGML_USE_OPENBLAS)
+#if defined(GGML_BLAS_USE_MKL)
+#include <mkl.h>
+#else
 #include <cblas.h>
+#endif
 #elif defined(GGML_USE_CUBLAS)
 #include "ggml-cuda.h"
 #elif defined(GGML_USE_CLBLAST)