Skip to content

fix: AVX2 intrinsics, const correctness, and SIMD headers #12186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.14) # for add_link_options and implicit target directories.
project("llama.cpp" C CXX)


if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
add_compile_options(-mfma -mavx2)
endif()

Comment on lines +3 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove that, as we already support dynamic backend loading based on detected CPU features at runtime.

include(CheckIncludeFileCXX)

#set(CMAKE_WARN_DEPRECATED YES)
Expand Down
6 changes: 3 additions & 3 deletions ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static inline __m512 __avx512_repeat_f32cx16_load(__m128i x) {
return _mm512_loadu_ps(tmp);
}
#endif
static inline __m256 __avx_f32cx8_load(ggml_fp16_t *x) {
static inline __m256 __avx_f32cx8_load(const ggml_fp16_t *x) {
float tmp[8];

for (int i = 0; i < 8; i++) {
Expand All @@ -123,7 +123,7 @@ static inline __m256 __avx_f32cx8_load(ggml_fp16_t *x) {

return _mm256_loadu_ps(tmp);
}
static inline __m256 __avx_repeat_f32cx8_load(ggml_fp16_t *x) {
static inline __m256 __avx_repeat_f32cx8_load(const ggml_fp16_t *x) {
float tmp[8];

for (int i = 0; i < 4; i++) {
Expand All @@ -133,7 +133,7 @@ static inline __m256 __avx_repeat_f32cx8_load(ggml_fp16_t *x) {

return _mm256_loadu_ps(tmp);
}
static inline __m256 __avx_rearranged_f32cx8_load(ggml_fp16_t *x, __m128i arrangeMask) {
static inline __m256 __avx_rearranged_f32cx8_load(const ggml_fp16_t *x, __m128i arrangeMask) {
uint16_t tmphalf[8];
float tmp[8];

Expand Down
1 change: 1 addition & 0 deletions ggml/src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _USE_MATH_DEFINES // For M_PI on MSVC

#include "ggml-backend.h"
#include <immintrin.h>
#include "ggml-impl.h"
#include "ggml-threading.h"
#include "ggml.h"
Expand Down