@@ -10,7 +10,7 @@ endif()
1010
1111set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
1212
13- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
13+ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
1414 set (LLAMA_STANDALONE ON )
1515
1616 # configure project version
@@ -94,46 +94,12 @@ option(LLAMA_CLBLAST "llama: use CLBlast"
9494option (LLAMA_METAL "llama: use Metal" ${LLAMA_METAL_DEFAULT} )
9595option (LLAMA_METAL_NDEBUG "llama: disable Metal debugging" OFF )
9696option (LLAMA_MPI "llama: use MPI" OFF )
97- option (LLAMA_K_QUANTS "llama: use k-quants" ON )
9897option (LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF )
9998
10099option (LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE} )
101100option (LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE} )
102101option (LLAMA_BUILD_SERVER "llama: build server example" ON )
103102
104- #
105- # Build info header
106- #
107-
108- # Generate initial build-info.h
109- include (${CMAKE_CURRENT_SOURCE_DIR} /scripts/build -info.cmake)
110-
111- if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /.git" )
112- set (GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /.git" )
113-
114- # Is git submodule
115- if (NOT IS_DIRECTORY "${GIT_DIR} " )
116- file (READ ${GIT_DIR} REAL_GIT_DIR_LINK)
117- string (REGEX REPLACE "gitdir: (.*)\n $" "\\ 1" REAL_GIT_DIR ${REAL_GIT_DIR_LINK} )
118- set (GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${REAL_GIT_DIR} " )
119- endif ()
120-
121- # Add a custom target for build-info.h
122- add_custom_target (BUILD_INFO ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /build-info.h" )
123-
124- # Add a custom command to rebuild build-info.h when .git/index changes
125- add_custom_command (
126- OUTPUT "${CMAKE_CURRENT_SOURCE_DIR} /build-info.h"
127- COMMENT "Generating build details from Git"
128- COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMAKE_VS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -P "${CMAKE_CURRENT_SOURCE_DIR} /scripts/build-info.cmake"
129- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
130- DEPENDS "${GIT_DIR} /index"
131- VERBATIM
132- )
133- else ()
134- message (WARNING "Git repository not found; to enable automatic generation of build info, make sure Git is installed and the project is a Git repository." )
135- endif ()
136-
137103#
138104# Compile flags
139105#
@@ -278,13 +244,8 @@ if (LLAMA_BLAS)
278244 endif ()
279245endif ()
280246
281- if (LLAMA_K_QUANTS)
282- set (GGML_HEADERS_EXTRA k_quants.h)
283- set (GGML_SOURCES_EXTRA k_quants.c)
284- add_compile_definitions (GGML_USE_K_QUANTS)
285- if (LLAMA_QKK_64)
286- add_compile_definitions (GGML_QKK_64)
287- endif ()
247+ if (LLAMA_QKK_64)
248+ add_compile_definitions (GGML_QKK_64)
288249endif ()
289250
290251if (LLAMA_CUBLAS)
@@ -497,6 +458,15 @@ if (LLAMA_LTO)
497458 endif ()
498459endif ()
499460
461+ # this version of Apple ld64 is buggy
462+ execute_process (
463+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -Wl,-v
464+ ERROR_VARIABLE output
465+ )
466+ if (output MATCHES "dyld-1015\. 7" )
467+ add_compile_definitions (HAVE_BUGGY_APPLE_LINKER)
468+ endif ()
469+
500470# Architecture specific
501471# TODO: probably these flags need to be tweaked on some architectures
502472# feel free to update the Makefile for your architecture and send a pull request or issue
@@ -549,6 +519,10 @@ if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") OR (${CMAKE_SYSTEM_PROCESSOR} MATC
549519elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GENERATOR_PLATFORM_LWR} " MATCHES "^(x86_64|i686|amd64|x64)$" )
550520 message (STATUS "x86 detected" )
551521 if (MSVC )
522+ # instruction set detection for MSVC only
523+ if (LLAMA_NATIVE)
524+ include (cmake/FindSIMD.cmake)
525+ endif ()
552526 if (LLAMA_AVX512)
553527 add_compile_options ($<$<COMPILE_LANGUAGE:C>:/arch:AVX512>)
554528 add_compile_options ($<$<COMPILE_LANGUAGE:CXX>:/arch:AVX512>)
@@ -600,8 +574,12 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GE
600574 endif ()
601575elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64" )
602576 message (STATUS "PowerPC detected" )
603- add_compile_options (-mcpu=native -mtune=native)
604- #TODO: Add targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
577+ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le" )
578+ add_compile_options (-mcpu=powerpc64le)
579+ else ()
580+ add_compile_options (-mcpu=native -mtune=native)
581+ #TODO: Add targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
582+ endif ()
605583else ()
606584 message (STATUS "Unknown architecture" )
607585endif ()
@@ -673,6 +651,8 @@ add_library(ggml OBJECT
673651 ggml-alloc.h
674652 ggml-backend.c
675653 ggml-backend.h
654+ ggml-quants.c
655+ ggml-quants.h
676656 ${GGML_SOURCES_CUDA} ${GGML_HEADERS_CUDA}
677657 ${GGML_SOURCES_OPENCL} ${GGML_HEADERS_OPENCL}
678658 ${GGML_SOURCES_METAL} ${GGML_HEADERS_METAL}
0 commit comments