char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
0802d4cfb
char/aliceai-t5-moe
1if ( GGML_STATIC) 2set ( BLA_STATIC ON ) 3endif () 4#if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) 5# set(BLA_SIZEOF_INTEGER 8) 6#endif() 7 8set ( BLA_VENDOR ${ GGML_BLAS_VENDOR }) 9find_package ( BLAS ) 10 11if ( BLAS_FOUND) 12message ( STATUS "BLAS found, Libraries: ${ BLAS_LIBRARIES } " ) 13 14ggml_add_backend_library ( ggml-blas 15ggml-blas.cpp 16) 17 18if (${ GGML_BLAS_VENDOR } MATCHES "Apple" ) 19add_compile_definitions ( ACCELERATE_NEW_LAPACK ) 20add_compile_definitions ( ACCELERATE_LAPACK_ILP64 ) 21add_compile_definitions ( GGML_BLAS_USE_ACCELERATE ) 22elseif ( " ${ BLAS_INCLUDE_DIRS } " STREQUAL "" ) 23# BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake. 24# see https://gitlab.kitware.com/cmake/cmake/-/issues/20268 25find_package ( PkgConfig REQUIRED ) 26if (${ GGML_BLAS_VENDOR } MATCHES "Generic" ) 27pkg_check_modules ( DepBLAS blas ) 28elseif (${ GGML_BLAS_VENDOR } MATCHES "OpenBLAS" ) 29# As of openblas v0.3.22, the 64-bit is named openblas64.pc 30pkg_check_modules ( DepBLAS openblas64 ) 31if ( NOT DepBLAS_FOUND) 32pkg_check_modules ( DepBLAS openblas ) 33endif () 34elseif (${ GGML_BLAS_VENDOR } MATCHES "FLAME" ) 35pkg_check_modules ( DepBLAS blis ) 36elseif (${ GGML_BLAS_VENDOR } MATCHES "ATLAS" ) 37pkg_check_modules ( DepBLAS blas-atlas ) 38elseif (${ GGML_BLAS_VENDOR } MATCHES "FlexiBLAS" ) 39pkg_check_modules ( DepBLAS flexiblas_api ) 40elseif (${ GGML_BLAS_VENDOR } MATCHES "Intel" ) 41# all Intel* libraries share the same include path 42pkg_check_modules ( DepBLAS mkl-sdl ) 43elseif (${ GGML_BLAS_VENDOR } MATCHES "NVHPC" ) 44# this doesn't provide pkg-config 45# suggest to assign BLAS_INCLUDE_DIRS on your own 46if ( " ${ NVHPC_VERSION } " STREQUAL "" ) 47message ( WARNING "Better to set NVHPC_VERSION" ) 48else () 49set ( DepBLAS_FOUND ON ) 50set ( DepBLAS_INCLUDE_DIRS "/opt/nvidia/hpc_sdk/ ${ CMAKE_SYSTEM_NAME } _ ${ CMAKE_SYSTEM_PROCESSOR } / ${ NVHPC_VERSION } /math_libs/include" ) 51endif () 52endif () 53if ( DepBLAS_FOUND) 54set ( BLAS_INCLUDE_DIRS ${ DepBLAS_INCLUDE_DIRS }) 55else () 56message ( WARNING "BLAS_INCLUDE_DIRS neither been provided nor been automatically" 57" detected by pkgconfig, trying to find cblas.h from possible paths..." ) 58find_path ( BLAS_INCLUDE_DIRS 59NAMES cblas.h 60HINTS 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) 68endif () 69endif () 70 71message ( STATUS "BLAS found, Includes: ${ BLAS_INCLUDE_DIRS } " ) 72 73target_compile_options ( ggml-blas PRIVATE ${ BLAS_LINKER_FLAGS }) 74 75if ( " ${ GGML_BLAS_VENDOR } " STREQUAL "" ) 76message ( WARNING "GGML_BLAS_VENDOR is not set; some methods may not link properly." ) 77endif () 78 79if ( " ${ GGML_BLAS_VENDOR } " MATCHES "Intel" OR ( " ${ BLAS_INCLUDE_DIRS } " MATCHES "mkl" AND " ${ GGML_BLAS_VENDOR } " MATCHES "Generic" )) 80add_compile_definitions ( GGML_BLAS_USE_MKL ) 81endif () 82 83if ( " ${ GGML_BLAS_VENDOR } " MATCHES "OpenBLAS" ) 84add_compile_definitions ( GGML_BLAS_USE_OPENBLAS ) 85endif () 86 87if ( " ${ GGML_BLAS_VENDOR } " MATCHES "FLAME" OR " ${ GGML_BLAS_VENDOR } " MATCHES "AOCL" OR " ${ GGML_BLAS_VENDOR } " MATCHES "AOCL_mt" ) 88add_compile_definitions ( GGML_BLAS_USE_BLIS ) 89endif () 90 91if ( " ${ GGML_BLAS_VENDOR } " MATCHES "NVPL" ) 92add_compile_definitions ( GGML_BLAS_USE_NVPL ) 93endif () 94 95target_link_libraries ( ggml-blas PRIVATE ${ BLAS_LIBRARIES }) 96target_include_directories ( ggml-blas SYSTEM PRIVATE ${ BLAS_INCLUDE_DIRS }) 97else () 98message ( FATAL_ERROR "BLAS not found, please refer to " 99"https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors" 100" to set correct GGML_BLAS_VENDOR" ) 101endif ()