Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-blas/CMakeLists.txt # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-blas / CMakeLists.txt` 108 lines ยท 4590 bytes Raw Blame History 1 if (GGML_STATIC) 2 set(BLA_STATIC ON) 3 endif() 4 #if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) 5 # set(BLA_SIZEOF_INTEGER 8) 6 #endif() 7 8 set(BLA_VENDOR ${GGML_BLAS_VENDOR}) 9 find_package(BLAS) 10 11 if (BLAS_FOUND) 12 message(STATUS "BLAS found, Libraries: ${BLAS_LIBRARIES}") 13 14 ggml_add_backend_library(ggml-blas 15 ggml-blas.cpp 16 ) 17 18 if (${GGML_BLAS_VENDOR} MATCHES "Apple") 19 add_compile_definitions(ACCELERATE_NEW_LAPACK) 20 add_compile_definitions(ACCELERATE_LAPACK_ILP64) 21 add_compile_definitions(GGML_BLAS_USE_ACCELERATE) 22 elseif ("${BLAS_INCLUDE_DIRS}" STREQUAL "") 23 # BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake. 24 # see https://gitlab.kitware.com/cmake/cmake/-/issues/20268 25 find_package(PkgConfig REQUIRED) 26 if (${GGML_BLAS_VENDOR} MATCHES "Generic") 27 pkg_check_modules(DepBLAS blas) 28 elseif (${GGML_BLAS_VENDOR} MATCHES "OpenBLAS") 29 # As of openblas v0.3.22, the 64-bit is named openblas64.pc 30 pkg_check_modules(DepBLAS openblas64) 31 if (NOT DepBLAS_FOUND) 32 pkg_check_modules(DepBLAS openblas) 33 endif() 34 elseif (${GGML_BLAS_VENDOR} MATCHES "FLAME") 35 pkg_check_modules(DepBLAS blis) 36 elseif (${GGML_BLAS_VENDOR} MATCHES "ATLAS") 37 pkg_check_modules(DepBLAS blas-atlas) 38 elseif (${GGML_BLAS_VENDOR} MATCHES "FlexiBLAS") 39 pkg_check_modules(DepBLAS flexiblas_api) 40 elseif (${GGML_BLAS_VENDOR} MATCHES "Intel") 41 # all Intel* libraries share the same include path 42 pkg_check_modules(DepBLAS mkl-sdl) 43 elseif (${GGML_BLAS_VENDOR} MATCHES "NVHPC") 44 # this doesn't provide pkg-config 45 # suggest to assign BLAS_INCLUDE_DIRS on your own 46 if ("${NVHPC_VERSION}" STREQUAL "") 47 message(WARNING "Better to set NVHPC_VERSION") 48 else() 49 set(DepBLAS_FOUND ON) 50 set(DepBLAS_INCLUDE_DIRS "/opt/nvidia/hpc_sdk/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}/${NVHPC_VERSION}/math_libs/include") 51 endif() 52 endif() 53 if (DepBLAS_FOUND) 54 set(BLAS_INCLUDE_DIRS ${DepBLAS_INCLUDE_DIRS}) 55 else() 56 message(WARNING "BLAS_INCLUDE_DIRS neither been provided nor been automatically" 57 " detected by pkgconfig, trying to find cblas.h from possible paths...") 58 find_path(BLAS_INCLUDE_DIRS 59 NAMES cblas.h 60 HINTS 61 /usr/include 62 /usr/local/include 63 /usr/include/openblas 64 /opt/homebrew/opt/openblas/include 65 /usr/local/opt/openblas/include 66 /usr/include/x86_64-linux-gnu/openblas/include 67 ) 68 endif() 69 endif() 70 71 message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}") 72 73 target_compile_options(ggml-blas PRIVATE ${BLAS_LINKER_FLAGS}) 74 75 if ("${GGML_BLAS_VENDOR}" STREQUAL "") 76 message(WARNING "GGML_BLAS_VENDOR is not set; some methods may not link properly.") 77 endif() 78 79 if ("${GGML_BLAS_VENDOR}" MATCHES "Intel" OR ("${BLAS_INCLUDE_DIRS}" MATCHES "mkl" AND "${GGML_BLAS_VENDOR}" MATCHES "Generic")) 80 add_compile_definitions(GGML_BLAS_USE_MKL) 81 endif() 82 83 if ("${GGML_BLAS_VENDOR}" MATCHES "OpenBLAS") 84 add_compile_definitions(GGML_BLAS_USE_OPENBLAS) 85 endif() 86 87 # Vendors with the BLIS API take GGML_BLAS_USE_BLIS (blis.h, bli_thread_set_num_threads). 88 # AOCL also takes GGML_BLAS_USE_AOCL so its device label is AOCL-BLAS, not BLIS. 89 # Neither flag selects the linked library; FindBLAS does that from GGML_BLAS_VENDOR. 90 if ("${GGML_BLAS_VENDOR}" MATCHES "FLAME" OR "${GGML_BLAS_VENDOR}" MATCHES "AOCL" OR "${GGML_BLAS_VENDOR}" MATCHES "AOCL_mt") 91 add_compile_definitions(GGML_BLAS_USE_BLIS) 92 endif() 93 94 if ("${GGML_BLAS_VENDOR}" MATCHES "AOCL" OR "${GGML_BLAS_VENDOR}" MATCHES "AOCL_mt") 95 add_compile_definitions(GGML_BLAS_USE_AOCL) 96 endif() 97 98 if ("${GGML_BLAS_VENDOR}" MATCHES "NVPL") 99 add_compile_definitions(GGML_BLAS_USE_NVPL) 100 endif() 101 102 target_link_libraries (ggml-blas PRIVATE ${BLAS_LIBRARIES}) 103 target_include_directories(ggml-blas SYSTEM PRIVATE ${BLAS_INCLUDE_DIRS}) 104 else() 105 message(FATAL_ERROR "BLAS not found, please refer to " 106 "https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors" 107 " to set correct GGML_BLAS_VENDOR") 108 endif()