diff --git a/cmake/arm64-windows-llvm.cmake b/cmake/arm64-windows-llvm.cmake index a93bf4fb4a..ed932a4585 100644 --- a/cmake/arm64-windows-llvm.cmake +++ b/cmake/arm64-windows-llvm.cmake @@ -12,5 +12,21 @@ set( CMAKE_CXX_COMPILER_TARGET ${target} ) set( arch_c_flags "-march=armv8.7-a -Xclang -target-feature -Xclang +fullfp16 -fvectorize -ffp-model=fast -fno-finite-math-only" ) set( warn_c_flags "-Wno-format -Wno-unused-variable -Wno-unused-function -Wno-gnu-zero-variadic-macro-arguments" ) -set( CMAKE_C_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" ) -set( CMAKE_CXX_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" ) +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "") + +set(base_flags "${arch_c_flags} ${warn_c_flags}") +# Disable CodeView generation as it causes crashes when cross compiling with +# clang-cl; instead rely solely on DWARF debug information. +set(debug_flags "-g -gdwarf-4 -Xclang -gno-codeview") + +set(CMAKE_C_FLAGS_INIT "${base_flags}") +set(CMAKE_CXX_FLAGS_INIT "${base_flags}") + +set(CMAKE_C_FLAGS_DEBUG_INIT "${debug_flags}") +set(CMAKE_CXX_FLAGS_DEBUG_INIT "${debug_flags}") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -DNDEBUG ${debug_flags}") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -DNDEBUG ${debug_flags}") +set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") diff --git a/examples/quantize-stats/quantize-stats.cpp b/examples/quantize-stats/quantize-stats.cpp index 02cfb25d33..25ec15868b 100644 --- a/examples/quantize-stats/quantize-stats.cpp +++ b/examples/quantize-stats/quantize-stats.cpp @@ -34,15 +34,24 @@ #if defined(_MSC_VER) #pragma warning(disable: 4244 4267) // possible loss of data #include +#if defined(_M_X64) || defined(_M_IX86) #include #include #include +#endif #include -inline int popcount(uint8_t x) { return __popcnt(x); } +#if defined(_M_X64) || defined(_M_IX86) +inline int popcount(uint8_t x) { return __popcnt(x); } inline int popcount(uint16_t x) { return __popcnt(x); } inline int popcount(uint32_t x) { return __popcnt(x); } inline int popcount(uint64_t x) { return _mm_popcnt_u64(x); } #else +inline int popcount(uint8_t x) { return __builtin_popcount(x); } +inline int popcount(uint16_t x) { return __builtin_popcount(x); } +inline int popcount(uint32_t x) { return __builtin_popcount(x); } +inline int popcount(uint64_t x) { return __builtin_popcountll(x); } +#endif +#else constexpr int popcount(uint8_t x) { return __builtin_popcount(x); } constexpr int popcount(uint16_t x) { return __builtin_popcount(x); } constexpr int popcount(uint32_t x) { return __builtin_popcount(x); } diff --git a/ggml/src/ggml-impl.h b/ggml/src/ggml-impl.h index e4e3686088..213ce0b0e8 100644 --- a/ggml/src/ggml-impl.h +++ b/ggml/src/ggml-impl.h @@ -445,7 +445,7 @@ static inline ggml_fp16_t ggml_compute_fp32_to_fp16(float f) { #include #else #if defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__) || defined(__SSSE3__) || defined(__SSE3__) || defined(__SSE__) -#if !defined(__riscv) +#if !defined(__riscv) && !defined(__aarch64__) #include #endif #endif diff --git a/ggml/src/iqk/iqk_quantize.cpp b/ggml/src/iqk/iqk_quantize.cpp index ece0b7346e..1325fd0280 100644 --- a/ggml/src/iqk/iqk_quantize.cpp +++ b/ggml/src/iqk/iqk_quantize.cpp @@ -34,15 +34,24 @@ #if defined(_MSC_VER) #pragma warning(disable: 4244 4267) // possible loss of data #include +#if defined(_M_X64) || defined(_M_IX86) #include #include #include +#endif #include -inline int popcount(uint8_t x) { return __popcnt(x); } +#if defined(_M_X64) || defined(_M_IX86) +inline int popcount(uint8_t x) { return __popcnt(x); } inline int popcount(uint16_t x) { return __popcnt(x); } inline int popcount(uint32_t x) { return __popcnt(x); } inline int popcount(uint64_t x) { return _mm_popcnt_u64(x); } #else +inline int popcount(uint8_t x) { return __builtin_popcount(x); } +inline int popcount(uint16_t x) { return __builtin_popcount(x); } +inline int popcount(uint32_t x) { return __builtin_popcount(x); } +inline int popcount(uint64_t x) { return __builtin_popcountll(x); } +#endif +#else constexpr int popcount(uint8_t x) { return __builtin_popcount(x); } constexpr int popcount(uint16_t x) { return __builtin_popcount(x); } constexpr int popcount(uint32_t x) { return __builtin_popcount(x); }