Skip to content

Commit 8b7af65

Browse files
cyyeverfacebook-github-bot
authored andcommitted
More accurate AVX detection (#4941)
Summary: X-link: facebookresearch/FBGEMM#1968 This PR separates MSVC AVX options from GNU ones. The purpose is to avoid some versions of MSVC succeeding with a `unknown option` warning. I observed this invalid behaviour on PyTorch CI. Pull Request resolved: #4941 Reviewed By: cthi Differential Revision: D83512683 Pulled By: q10 fbshipit-source-id: 92114b13b0582e278a6533e19d84e9586f253867
1 parent 00f3f2e commit 8b7af65

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmake/modules/FindAVX.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ ENDMACRO()
101101
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
102102
foreach(lang C;CXX)
103103
if(lang IN_LIST languages)
104-
CHECK_SSE(${lang} "AVX" "-mavx;/arch:AVX")
105-
CHECK_SSE(${lang} "AVX2" "-mavx2 -mfma -mf16c;/arch:AVX2")
106-
CHECK_SSE(${lang} "AVX512" "-mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma;/arch:AVX512")
104+
if(MSVC)
105+
CHECK_SSE(${lang} "AVX" "/arch:AVX;")
106+
CHECK_SSE(${lang} "AVX2" "/arch:AVX2;")
107+
CHECK_SSE(${lang} "AVX512" "/arch:AVX512;")
108+
else()
109+
CHECK_SSE(${lang} "AVX" "-mavx;")
110+
CHECK_SSE(${lang} "AVX2" "-mavx2 -mfma -mf16c;")
111+
CHECK_SSE(${lang} "AVX512" "-mavx512f -mavx512dq -mavx512vl -mavx512bw -mfma;")
112+
endif()
107113
endif()
108114
endforeach()
109115

0 commit comments

Comments
 (0)