Skip to content

Commit 1d0fba9

Browse files
committed
updated openblas config
1 parent 85e51b0 commit 1d0fba9

File tree

1 file changed

+7
-68
lines changed

1 file changed

+7
-68
lines changed

CMakeLists.txt

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ if (LLAMA_METAL)
261261
)
262262
endif()
263263
if (LLAMA_BLAS)
264+
message(STATUS "Building with OpenBLAS")
265+
264266
if (LLAMA_STATIC)
265267
set(BLA_STATIC ON)
266268
endif()
@@ -269,77 +271,14 @@ if (LLAMA_BLAS)
269271
endif()
270272

271273
set(BLA_VENDOR ${LLAMA_BLAS_VENDOR})
272-
find_package(BLAS)
273-
274-
if (BLAS_FOUND)
275-
message(STATUS "BLAS found, Libraries: ${BLAS_LIBRARIES}")
276-
277-
if ("${BLAS_INCLUDE_DIRS}" STREQUAL "")
278-
# BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake.
279-
# see https://gitlab.kitware.com/cmake/cmake/-/issues/20268
280-
find_package(PkgConfig REQUIRED)
281-
if (${LLAMA_BLAS_VENDOR} MATCHES "Generic")
282-
pkg_check_modules(DepBLAS REQUIRED blas)
283-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "OpenBLAS")
284-
# As of openblas v0.3.22, the 64-bit is named openblas64.pc
285-
pkg_check_modules(DepBLAS openblas64)
286-
if (NOT DepBLAS_FOUND)
287-
pkg_check_modules(DepBLAS REQUIRED openblas)
288-
endif()
289-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "FLAME")
290-
pkg_check_modules(DepBLAS REQUIRED blis)
291-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "ATLAS")
292-
pkg_check_modules(DepBLAS REQUIRED blas-atlas)
293-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "FlexiBLAS")
294-
pkg_check_modules(DepBLAS REQUIRED flexiblas_api)
295-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "Intel")
296-
# all Intel* libraries share the same include path
297-
pkg_check_modules(DepBLAS REQUIRED mkl-sdl)
298-
elseif (${LLAMA_BLAS_VENDOR} MATCHES "NVHPC")
299-
# this doesn't provide pkg-config
300-
# suggest to assign BLAS_INCLUDE_DIRS on your own
301-
if ("${NVHPC_VERSION}" STREQUAL "")
302-
message(WARNING "Better to set NVHPC_VERSION")
303-
else()
304-
set(DepBLAS_FOUND ON)
305-
set(DepBLAS_INCLUDE_DIRS "/opt/nvidia/hpc_sdk/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}/${NVHPC_VERSION}/math_libs/include")
306-
endif()
307-
endif()
308-
if (DepBLAS_FOUND)
309-
set(BLAS_INCLUDE_DIRS ${DepBLAS_INCLUDE_DIRS})
310-
else()
311-
message(WARNING "BLAS_INCLUDE_DIRS neither been provided nor been automatically"
312-
" detected by pkgconfig, trying to find cblas.h from possible paths...")
313-
find_path(BLAS_INCLUDE_DIRS
314-
NAMES cblas.h
315-
HINTS
316-
/usr/include
317-
/usr/local/include
318-
/usr/include/openblas
319-
/opt/homebrew/opt/openblas/include
320-
/usr/local/opt/openblas/include
321-
/usr/include/x86_64-linux-gnu/openblas/include
322-
)
323-
endif()
324-
endif()
274+
add_compile_options(${BLAS_LINKER_FLAGS})
325275

326-
message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}")
276+
add_compile_definitions(GGML_USE_OPENBLAS)
327277

328-
add_compile_options(${BLAS_LINKER_FLAGS})
278+
add_subdirectory(../OpenBLAS ${CMAKE_CURRENT_BINARY_DIR}/OpenBLAS)
329279

330-
add_compile_definitions(GGML_USE_OPENBLAS)
331-
332-
if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${LLAMA_BLAS_VENDOR} MATCHES "Generic" OR ${LLAMA_BLAS_VENDOR} MATCHES "Intel"))
333-
add_compile_definitions(GGML_BLAS_USE_MKL)
334-
endif()
335-
336-
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${BLAS_LIBRARIES})
337-
set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${BLAS_INCLUDE_DIRS})
338-
else()
339-
message(WARNING "BLAS not found, please refer to "
340-
"https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors"
341-
" to set correct LLAMA_BLAS_VENDOR")
342-
endif()
280+
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} openblas_static)
281+
set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ../OpenBLAS ${CMAKE_CURRENT_BINARY_DIR}/OpenBLAS)
343282
endif()
344283

345284
if (LLAMA_QKK_64)

0 commit comments

Comments
 (0)