Skip to content
Closed
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
2 changes: 1 addition & 1 deletion ggml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ option(GGML_SANITIZE_ADDRESS "ggml: enable address sanitizer" OFF)
option(GGML_SANITIZE_UNDEFINED "ggml: enable undefined sanitizer" OFF)

# instruction set specific
if (GGML_NATIVE OR NOT GGML_NATIVE_DEFAULT)
if (NOT MSVC AND (GGML_NATIVE OR NOT GGML_NATIVE_DEFAULT))
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand why the NOT MSVC check is necessary here. Can you clarify further and maybe an example of when it makes a difference?

Also, are you utilizing the CMAKE_CROSSCOMPILING variable in your builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using:
cmake -S . -B build/win-x64 -A x64 (for building x64 Windows version with MSVC) without options in env variables (except the path for msvc, etc).

This will produce:
CMAKE_CROSSCOMPILING: FALSE
GGML_NATIVE_DEFAULT: ON
GGML_NATIVE: ON
INS_ENV: OFF

Before checking the usage of AVX and setting it to false only if it is not available on the machine (without setting it to true otherwise):
image

The above configuration would produce an AVX-enabled library on AVX-enabled host.

After adding that check, the default will now be OFF.
It's not a problem for me being only the default and still will be able to override it, but I don't think it is expected for others.

I was trying to allow all of this:

  • building AVX-enabled library on AVX-enabled host

  • building NotAVX-enabled library on AVX-enabled host

  • building NotAVX-enabled library on NotAVX-enabled host

  • Building AVX-enabled library by default on AVX-Enabled Host

  • Building NotAVX-enabled library by default on NotAVX-Enabled Host

if removing that default check, the 4th will be true:

  • Building NotAVX-enabled library by default on AVX-Enabled Host

Your call on this one, I can change the default however you say.

set(INS_ENB OFF)
else()
set(INS_ENB ON)
Expand Down
35 changes: 18 additions & 17 deletions ggml/cmake/FindSIMD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,25 @@ macro(check_sse type flags)
endmacro()

# flags are for MSVC only!
check_sse("AVX" " ;/arch:AVX")
if (NOT ${AVX_FOUND})
set(GGML_AVX OFF)
else()
set(GGML_AVX ON)
# Only perform checks if the options are enabled, otherwise the params won't be respected
if (GGML_AVX)
check_sse("AVX" " ;/arch:AVX")
if (NOT AVX_FOUND)
set(GGML_AVX OFF)
endif()
endif()

check_sse("AVX2" " ;/arch:AVX2")
check_sse("FMA" " ;/arch:AVX2")
if ((NOT ${AVX2_FOUND}) OR (NOT ${FMA_FOUND}))
set(GGML_AVX2 OFF)
else()
set(GGML_AVX2 ON)
if (GGML_AVX2)
check_sse("AVX2" " ;/arch:AVX2")
check_sse("FMA" " ;/arch:AVX2")
if (NOT AVX2_FOUND OR NOT FMA_FOUND)
set(GGML_AVX2 OFF)
endif()
endif()

check_sse("AVX512" " ;/arch:AVX512")
if (NOT ${AVX512_FOUND})
set(GGML_AVX512 OFF)
else()
set(GGML_AVX512 ON)
endif()
if (GGML_AVX512)
check_sse("AVX512" " ;/arch:AVX512")
if (NOT AVX512_FOUND)
set(GGML_AVX512 OFF)
endif()
endif()
Loading