@@ -10,7 +10,7 @@ endif()
10
10
11
11
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /bin)
12
12
13
- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
13
+ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
14
14
set (LLAMA_STANDALONE ON )
15
15
16
16
# configure project version
@@ -94,46 +94,12 @@ option(LLAMA_CLBLAST "llama: use CLBlast"
94
94
option (LLAMA_METAL "llama: use Metal" ${LLAMA_METAL_DEFAULT} )
95
95
option (LLAMA_METAL_NDEBUG "llama: disable Metal debugging" OFF )
96
96
option (LLAMA_MPI "llama: use MPI" OFF )
97
- option (LLAMA_K_QUANTS "llama: use k-quants" ON )
98
97
option (LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF )
99
98
100
99
option (LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE} )
101
100
option (LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE} )
102
101
option (LLAMA_BUILD_SERVER "llama: build server example" ON )
103
102
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
-
137
103
#
138
104
# Compile flags
139
105
#
@@ -278,13 +244,8 @@ if (LLAMA_BLAS)
278
244
endif ()
279
245
endif ()
280
246
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)
288
249
endif ()
289
250
290
251
if (LLAMA_CUBLAS)
@@ -497,6 +458,15 @@ if (LLAMA_LTO)
497
458
endif ()
498
459
endif ()
499
460
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
+
500
470
# Architecture specific
501
471
# TODO: probably these flags need to be tweaked on some architectures
502
472
# 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
549
519
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GENERATOR_PLATFORM_LWR} " MATCHES "^(x86_64|i686|amd64|x64)$" )
550
520
message (STATUS "x86 detected" )
551
521
if (MSVC )
522
+ # instruction set detection for MSVC only
523
+ if (LLAMA_NATIVE)
524
+ include (cmake/FindSIMD.cmake)
525
+ endif ()
552
526
if (LLAMA_AVX512)
553
527
add_compile_options ($<$<COMPILE_LANGUAGE:C>:/arch:AVX512>)
554
528
add_compile_options ($<$<COMPILE_LANGUAGE:CXX>:/arch:AVX512>)
@@ -600,8 +574,12 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(x86_64|i686|AMD64)$" OR "${CMAKE_GE
600
574
endif ()
601
575
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64" )
602
576
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 ()
605
583
else ()
606
584
message (STATUS "Unknown architecture" )
607
585
endif ()
@@ -673,6 +651,8 @@ add_library(ggml OBJECT
673
651
ggml-alloc.h
674
652
ggml-backend.c
675
653
ggml-backend.h
654
+ ggml-quants.c
655
+ ggml-quants.h
676
656
${GGML_SOURCES_CUDA} ${GGML_HEADERS_CUDA}
677
657
${GGML_SOURCES_OPENCL} ${GGML_HEADERS_OPENCL}
678
658
${GGML_SOURCES_METAL} ${GGML_HEADERS_METAL}
0 commit comments