Skip to content

Commit 7cc2d2c

Browse files
slarenggerganov
andauthored
ggml : move AMX to the CPU backend (ggml-org#10570)
* ggml : move AMX to the CPU backend --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
1 parent b782e5c commit 7cc2d2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+515
-802
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Checks: >
1717
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
1818
performance-*,
1919
portability-*,
20+
-portability-simd-intrinsics,
2021
misc-*,
2122
-misc-const-correctness,
2223
-misc-non-private-member-variables-in-classes,
2324
-misc-no-recursion,
25+
-misc-use-anonymous-namespace,
2426
FormatStyle: none

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,11 @@ jobs:
11211121
run: |
11221122
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
11231123
1124+
- name: Install ccache
1125+
uses: hendrikmuhs/ccache-action@v1.2
1126+
with:
1127+
key: ${{ github.job }}
1128+
11241129
- name: Build
11251130
id: cmake_build
11261131
run: |

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ endif
254254
# keep standard at C11 and C++11
255255
MK_CPPFLAGS = -Iggml/include -Iggml/src -Iinclude -Isrc -Icommon -DGGML_USE_CPU
256256
MK_CFLAGS = -std=c11 -fPIC
257-
MK_CXXFLAGS = -std=c++11 -fPIC
258-
MK_NVCCFLAGS = -std=c++11
257+
MK_CXXFLAGS = -std=c++17 -fPIC
258+
MK_NVCCFLAGS = -std=c++17
259259

260260
ifdef LLAMA_NO_CCACHE
261261
GGML_NO_CCACHE := 1
@@ -575,9 +575,12 @@ endif
575575

576576
ifndef GGML_NO_AMX
577577
MK_CPPFLAGS += -DGGML_USE_AMX
578-
OBJ_GGML_EXT += ggml/src/ggml-amx/ggml-amx.o ggml/src/ggml-amx/mmq.o
578+
OBJ_GGML_EXT += ggml/src/ggml-cpu/amx/amx.o ggml/src/ggml-cpu/amx/mmq.o
579579
endif
580580

581+
# only necessary for the CPU backend files
582+
MK_CPPFLAGS += -Iggml/src/ggml-cpu
583+
581584
ifdef GGML_RPC
582585
MK_CPPFLAGS += -DGGML_USE_RPC
583586
OBJ_GGML_EXT += ggml/src/ggml-rpc.o

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ var cSettings: [CSetting] = [
2828
.unsafeFlags(["-Wno-shorten-64-to-32", "-O3", "-DNDEBUG"]),
2929
.unsafeFlags(["-fno-objc-arc"]),
3030
.headerSearchPath("ggml/src"),
31+
.headerSearchPath("ggml/src/ggml-cpu"),
3132
// NOTE: NEW_LAPACK will required iOS version 16.4+
3233
// We should consider add this in the future when we drop support for iOS 14
3334
// (ref: ref: https://developer.apple.com/documentation/accelerate/1513264-cblas_sgemm?language=objc)
3435
// .define("ACCELERATE_NEW_LAPACK"),
3536
// .define("ACCELERATE_LAPACK_ILP64")
37+
.define("GGML_USE_CPU"),
3638
]
3739

40+
3841
#if canImport(Darwin)
3942
sources.append("ggml/src/ggml-common.h")
4043
sources.append("ggml/src/ggml-metal/ggml-metal.m")
@@ -44,7 +47,6 @@ cSettings.append(
4447
contentsOf: [
4548
.define("GGML_USE_ACCELERATE"),
4649
.define("GGML_USE_METAL"),
47-
.define("GGML_USE_CPU")
4850
]
4951
)
5052
#endif

common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ if (LLAMA_CURL)
8888
endif ()
8989

9090
target_include_directories(${TARGET} PUBLIC .)
91-
target_compile_features (${TARGET} PUBLIC cxx_std_11)
91+
target_compile_features (${TARGET} PUBLIC cxx_std_17)
9292
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)

common/common.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,17 @@ bool fs_validate_filename(const std::string & filename) {
652652

653653
std::u32string filename_utf32;
654654
try {
655+
#if defined(__clang__)
656+
// disable C++17 deprecation warning for std::codecvt_utf8
657+
# pragma clang diagnostic push
658+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
659+
#endif
655660
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
661+
662+
#if defined(__clang__)
663+
# pragma clang diagnostic pop
664+
#endif
665+
656666
filename_utf32 = converter.from_bytes(filename);
657667

658668
// If the reverse conversion mismatches, it means overlong UTF-8 sequences were used,

examples/batched-bench/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ set(TARGET llama-batched-bench)
22
add_executable(${TARGET} batched-bench.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
5-
target_compile_features(${TARGET} PRIVATE cxx_std_11)
5+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

examples/batched/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ set(TARGET llama-batched)
22
add_executable(${TARGET} batched.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
5-
target_compile_features(${TARGET} PRIVATE cxx_std_11)
5+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

examples/convert-llama2c-to-ggml/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ set(TARGET llama-convert-llama2c-to-ggml)
22
add_executable(${TARGET} convert-llama2c-to-ggml.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
5-
target_compile_features(${TARGET} PRIVATE cxx_std_11)
5+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

examples/cvector-generator/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ set(TARGET llama-cvector-generator)
22
add_executable(${TARGET} cvector-generator.cpp pca.hpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
5-
target_compile_features(${TARGET} PRIVATE cxx_std_11)
5+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

0 commit comments

Comments
 (0)