Repository navigation
Fix MSVC build by disabling AVX-512-BF16 in non-latest MSVC versions. - #15589
Conversation
| check_cxx_compiler_flag("${IREE_UK_COPTS_X86_64_AVX512_BF16}" IREE_UK_BUILD_X86_64_AVX512_BF16) | ||
| endif() | ||
|
|
||
| if (MSVC_VERSION AND ("${MSVC_VERSION}" VERSION_LESS 1937)) |
There was a problem hiding this comment.
I see see errors building the iree_builtins_ukernel_arch_x86_64_x86_64_avx512_bf16 target with this change.
CMake debugging... I'm not sure unset is doing what we want here 🤔
[cmake] -- MSVC_VERSION: 1931
[cmake] -- IREE_UK_BUILD_X86_64_AVX512_BF16: 1
[cmake] -- missing _mm512_cvtpbh_ps, calling unset
[cmake] -- IREE_UK_BUILD_X86_64_AVX512_BF16: 1
[cmake] -- IREE_UK_BUILD_X86_64_AVX512_BF16, adding x86_64_avx512_bf16
There was a problem hiding this comment.
Aaaaaah
- https://cmake.org/cmake/help/latest/module/CheckCXXCompilerFlag.html
Stores the result in an internal cache entry named <var>. - https://cmake.org/cmake/help/latest/command/unset.html
If CACHE is present, then a cache variable is removed instead of a normal variable.
There was a problem hiding this comment.
Okay nice, unset(IREE_UK_BUILD_X86_64_AVX512_BF16 CACHE) did the trick.
Is this the right cache behavior as written, or should we do this?
if ((CMAKE_C_COMPILER_ID STREQUAL GNU) AND
(CMAKE_C_COMPILER_VERSION VERSION_LESS 12))
# Old GCC versions have incompatible x86 intrinsics. Supporting them
# is not considered worth it. By not defining these tokens, we leave these
# code paths out. At least GCC 9 is known to be problematic, while GCC 12 is
# known working, so the current test is based on that.
else()
check_cxx_compiler_flag("${IREE_UK_COPTS_X86_64_AVX2_FMA}" IREE_UK_BUILD_X86_64_AVX2_FMA)
check_cxx_compiler_flag("${IREE_UK_COPTS_X86_64_AVX512_BASE}" IREE_UK_BUILD_X86_64_AVX512_BASE)
check_cxx_compiler_flag("${IREE_UK_COPTS_X86_64_AVX512_VNNI}" IREE_UK_BUILD_X86_64_AVX512_VNNI)
if (MSVC_VERSION AND ("${MSVC_VERSION}" VERSION_LESS 1937))
# Missing _mm512_cvtpbh_ps intrinsic at _MSC_VER=1930.
unset(IREE_UK_BUILD_X86_64_AVX512_BF16 CACHE)
else()
check_cxx_compiler_flag("${IREE_UK_COPTS_X86_64_AVX512_BF16}" IREE_UK_BUILD_X86_64_AVX512_BF16)
endif()
endif()(with some formatting)
There was a problem hiding this comment.
Ah, thanks for debugging that! is the new commit here what's needed?
There was a problem hiding this comment.
Is this the right cache behavior as written, or should we do this?
Yeah I thought about that but i like how the current way it's written avoids nesting, and it should not make a difference in practice as the compiler can't be simultaneously GNU and MSVC, and the non-nested for keeps things more orthogonal.
There was a problem hiding this comment.
If I'm understanding the CMake cache correctly, check_cxx_compiler_flag will run a check and write the result to the cache, but then unset will clear the result of the check, so future configures will run the check_cxx_compiler_flag check again. If we add nesting then the check won't happen at all (first configure and future configures)
// first configure
check_cxx_compiler_flag --> 1
unset
// second configure
check_cxx_compiler_flag --> 1
unset
when we could have
// first configure
unset
// second configure
unset
There was a problem hiding this comment.
Hmm... yeah, I see this each time I configure:
[cmake] -- Performing Test IREE_UK_BUILD_X86_64_AVX512_BF16
[cmake] -- Performing Test IREE_UK_BUILD_X86_64_AVX512_BF16 - Success
Adds a bit of log noise and configure time overhead if we always end up ignoring the result on this compiler version.
There was a problem hiding this comment.
Note, since we are now skipping the configure-check and not unset-ing anything, you will need to wipe your IREE_UK_BUILD_* cached variables from CMakeCache.txt before rerunning.
…iree-org#15589) As reported by @ScottTodd in iree-org#15543 (comment) At least this MSVC version, identified by `_MSC_VER=1930`, lacks the `_mm512_cvtpbh_ps` intrinsic. On the other hand, the CI builders are doing OK, and they have `_MSC_VER=1937`.
As reported by @ScottTodd in #15543 (comment)
At least this MSVC version, identified by
_MSC_VER=1930, lacks the_mm512_cvtpbh_psintrinsic. On the other hand, the CI builders are doing OK, and they have_MSC_VER=1937.