-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[X86] Emit Warnings for frontend options to enable knl/knm specific ISAs. #75580
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
Conversation
Since Knight Landing and Knight Mill microarchitectures are EOL, we would like to remove its support in LLVM 19. In LLVM 18, we will first emit a warning for the usage.
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang Author: Freddy Ye (FreddyLeaf) ChangesSince Knight Landing and Knight Mill microarchitectures are EOL, we Full diff: https://github.com/llvm/llvm-project/pull/75580.diff 7 Files Affected:
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 65a33f61a6948a..40841e9df547bc 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -349,6 +349,8 @@ def warn_invalid_feature_combination : Warning<
def warn_target_unrecognized_env : Warning<
"mismatch between architecture and environment in target triple '%0'; did you mean '%1'?">,
InGroup<InvalidCommandLineArgument>;
+def warn_knl_knm_target_supports_remove : Warning<
+ "KNL/KNM's feature support will be removed in LLVM 19.">;
// Source manager
def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index b97f88647fa49f..dc56524d378104 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -295,11 +295,13 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasAVX512BF16 = true;
} else if (Feature == "+avx512er") {
HasAVX512ER = true;
+ Diags.Report(diag::warn_knl_knm_target_supports_remove);
} else if (Feature == "+avx512fp16") {
HasAVX512FP16 = true;
HasLegalHalfType = true;
} else if (Feature == "+avx512pf") {
HasAVX512PF = true;
+ Diags.Report(diag::warn_knl_knm_target_supports_remove);
} else if (Feature == "+avx512dq") {
HasAVX512DQ = true;
} else if (Feature == "+avx512bitalg") {
@@ -358,6 +360,7 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasPREFETCHI = true;
} else if (Feature == "+prefetchwt1") {
HasPREFETCHWT1 = true;
+ Diags.Report(diag::warn_knl_knm_target_supports_remove);
} else if (Feature == "+clzero") {
HasCLZERO = true;
} else if (Feature == "+cldemote") {
diff --git a/clang/test/CodeGen/X86/avx512er-builtins.c b/clang/test/CodeGen/X86/avx512er-builtins.c
index ee31236a3c01aa..11ec6aabec1e3f 100644
--- a/clang/test/CodeGen/X86/avx512er-builtins.c
+++ b/clang/test/CodeGen/X86/avx512er-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512f -target-feature +avx512er -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512f -target-feature +avx512er -emit-llvm -o - -Wall | FileCheck %s
#include <immintrin.h>
diff --git a/clang/test/CodeGen/X86/avx512pf-builtins.c b/clang/test/CodeGen/X86/avx512pf-builtins.c
index 4ca70f5787968b..3a117ed6a9460e 100644
--- a/clang/test/CodeGen/X86/avx512pf-builtins.c
+++ b/clang/test/CodeGen/X86/avx512pf-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512pf -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512pf -emit-llvm -o - -Wall | FileCheck %s
#include <immintrin.h>
diff --git a/clang/test/Driver/cl-x86-flags.c b/clang/test/Driver/cl-x86-flags.c
index 51b16f0ce35463..ae35a312fe8a4b 100644
--- a/clang/test/Driver/cl-x86-flags.c
+++ b/clang/test/Driver/cl-x86-flags.c
@@ -69,7 +69,10 @@
// RUN: %clang_cl -m32 -arch:avx2 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2 %s
// avx2: invalid /arch: argument
-// RUN: %clang_cl -m32 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify -DTEST_32_ARCH_AVX512F -- %s
+// RUN: %clang_cl -m32 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify=KNL1 -DTEST_32_ARCH_AVX512F -- %s
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
#if defined(TEST_32_ARCH_AVX512F)
#if _M_IX86_FP != 2 || !__AVX__ || !__AVX2__ || !__AVX512F__ || __AVX512BW__
#error fail
@@ -109,7 +112,10 @@
// RUN: %clang_cl -m64 -arch:avx2 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx264 %s
// avx264: invalid /arch: argument
-// RUN: %clang_cl -m64 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify -DTEST_64_ARCH_AVX512F -- %s
+// RUN: %clang_cl -m64 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify=KNL2 -DTEST_64_ARCH_AVX512F -- %s
+// KNL2-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL2-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL2-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
#if defined(TEST_64_ARCH_AVX512F)
#if _M_IX86_FP || !__AVX__ || !__AVX2__ || !__AVX512F__ || __AVX512BW__
#error fail
diff --git a/clang/test/Frontend/x86-target-cpu.c b/clang/test/Frontend/x86-target-cpu.c
index 6c8502ac2c21ee..be57b3c0ec583b 100644
--- a/clang/test/Frontend/x86-target-cpu.c
+++ b/clang/test/Frontend/x86-target-cpu.c
@@ -15,8 +15,14 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu cannonlake -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-client -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-server -verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knm -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify=knl %s
+// knl-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// knl-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// knl-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knm -verify=knm %s
+// knm-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// knm-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// knm-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bonnell -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu silvermont -verify %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu k8 -verify %s
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index c587337da5933a..f580445b1f10b9 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (65):
+CHECK: Warnings without flags (66):
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_specialization_storage_class
@@ -56,6 +56,7 @@ CHECK-NEXT: warn_ignoring_ftabstop_value
CHECK-NEXT: warn_implements_nscopying
CHECK-NEXT: warn_incompatible_qualified_id
CHECK-NEXT: warn_invalid_asm_cast_lvalue
+CHECK-NEXT: warn_knl_knm_target_supports_remove
CHECK-NEXT: warn_maynot_respond
CHECK-NEXT: warn_method_param_redefinition
CHECK-NEXT: warn_missing_case_for_condition
|
Why do you want to remove these? We don't support any of the more exotic behaviors of Xeon Phi, but removing a x86 cpu just because its EOL doesn't make sense to me. |
Let me first paste reasons I listed before:
|
And here're two more reasons I collected from gcc:
|
One more reason I can think of is with KNL/KNM removal, we can simplify supporting widen 128/256-bit vector to 512-bit without AVX512VL feature since all reset targets support AVX512VL. The test cases can be simplified too. |
One more justification... The assembler support for some KNL instructions is buggy
If we deprecate KNL, the bug can go away. |
Can you give me a better idea of the stages you intend to follow with this. The patch title suggests removing all KNL/KNM handling but the patch itself looks to be just about the KNL/KNM specific features. Removing the (incomplete) KNL/KNM specific features (ER/PF/etc) I don't think will be any major cause for concern, ideally we'd keep support at the assembly level only (which has been suggested for MMX as well at some point). But even that might not be necessary. But what do you expect to happen if a KNL workstation attempts to use clang 19 with How can the test cases then can be simplified? Are you suggesting that we merge more of the AVX512 attributes in X86.td (e.g. AVX512VL always enables BW/DQ / VBMI2 enables VBMI etc?). |
It's a good idea to preserve the assembly level support. I think GCC's proposal just wants to deprecate GCC support rather than remove support from binutils too.
There're discussions in GCC mailing loop about
I think we can't make AVX512VL being implied by default, but can gradually relax a lot of From the developmental trend of HW design, I don't think we will fall back to support 512-bit only features in the future. So from my point of view, simplifying backend design and testing would be the major benefit we can achieve. |
I have created a draft PR to do removal in next release: #76383. Comments are welcome there. For this PR, I added warnings to features only but not cpuname, mainly to reduce efforts. Especially when using |
ping for review |
I think if we have an approach that allows people to emulate a very basic KNL/KNM implementation with the equivalent of "-march=x86-64-v3 -mavx512f -mavx512cd" then that would be sufficient. I do think we should be keeping -march/tune support though for the knl/knm cpu model names, but we shouldn't need to support the xeon phi specific ISAs. We should keep asm handling for avx512er/avx512pf/etc but no need for attributes/intrinsics handling for them - if somebody needs to write assembly for them we shouldn't prevent it. We should retain -march=native detection if we can, but not mandatory. I also think we need a policy regarding what test coverage we need for various avx512 features (when should we assume avx512vl etc.) Does that sound OK? |
Considering the new evolution in AVX10, we should switch testing model from
This will require compiler and tests continue to handle cases avx512f/avx512cd without avx512vl. It conflicts with my expectation for
+1 |
Keeping |
Making avx512f the only case where avx512vl can be disabled doesn't seem like too much of a stretch to me - we'd be merely making all avx512 extension features depend on avx512vl. |
Agreed. |
Sorry, we'd require both avx512f and avx512cd to work without avx512vl - but everything afterward (avx512bw, avx512dq, ....) we could assume avx512vl is enabled. |
@RKSimon @phoebewang Thanks comments! knm has AVX512_VPOPCNTDQ, I guess we also require it work without avx512vl? And we are going to keep -march/mtune/mcpu support for knl/knm, but removing some specific ISA's intrinsic and lowering supports? Did I get your point wrong? |
Thanks confirming! Modified the warning message and commit title. |
ping for review |
ping for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - please make sure you adjust the commit message (the patch summary doesn't refer to removing just the knl/knm specific ISAs)
Thank you all! |
…SAs. (llvm#75580) Since Knight Landing and Knight Mill microarchitectures are EOL, we would like to remove intrinsic supports for its specific ISA in LLVM 19. In LLVM 18, we will first emit a warning for the usage.
Clang 19 has removed support for the -mavx512pf and -mavx512er flags, for the Intel Xeon Phi (aka "Knights Landing"/knl or "Knights Mill"/knm) [1] [2]. This causes fatal errors during configuration of math/blis: Compiling obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o ('knl' CFLAGS for kernels) cc: fatal error: unknown argument '-mavx512pf'; did you mean '-mavx512f'? gmake: *** [Makefile:653: obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o] Error 1 Add an EXTRA_PATCHES entry to deal with this situation. Note that in the future, this may also have to be done for gcc 15 and later. In that case, the patch might be done unconditionally. [1] llvm/llvm-project#75580 [2] llvm/llvm-project#92883 PR: 280783 Approved by: maintainer timeout (2 weeks) MFH: 2024Q3
Clang 19 has removed support for the -mavx512pf and -mavx512er flags, for the Intel Xeon Phi (aka "Knights Landing"/knl or "Knights Mill"/knm) [1] [2]. This causes fatal errors during configuration of math/blis: Compiling obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o ('knl' CFLAGS for kernels) cc: fatal error: unknown argument '-mavx512pf'; did you mean '-mavx512f'? gmake: *** [Makefile:653: obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o] Error 1 Add an EXTRA_PATCHES entry to deal with this situation. Note that in the future, this may also have to be done for gcc 15 and later. In that case, the patch might be done unconditionally. [1] llvm/llvm-project#75580 [2] llvm/llvm-project#92883 PR: 280783 Approved by: maintainer timeout (2 weeks) MFH: 2024Q3 (cherry picked from commit 885ff9e)
Clang 19 has removed support for the -mavx512pf and -mavx512er flags, for the Intel Xeon Phi (aka "Knights Landing"/knl or "Knights Mill"/knm) [1] [2]. This causes fatal errors during configuration of math/blis: Compiling obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o ('knl' CFLAGS for kernels) cc: fatal error: unknown argument '-mavx512pf'; did you mean '-mavx512f'? gmake: *** [Makefile:653: obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o] Error 1 Add an EXTRA_PATCHES entry to deal with this situation. Note that in the future, this may also have to be done for gcc 15 and later. In that case, the patch might be done unconditionally. [1] llvm/llvm-project#75580 [2] llvm/llvm-project#92883 PR: 280783 Approved by: maintainer timeout (2 weeks) MFH: 2024Q3
Clang 19 has removed support for the -mavx512pf and -mavx512er flags, for the Intel Xeon Phi (aka "Knights Landing"/knl or "Knights Mill"/knm) [1] [2]. This causes fatal errors during configuration of math/blis: Compiling obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o ('knl' CFLAGS for kernels) cc: fatal error: unknown argument '-mavx512pf'; did you mean '-mavx512f'? gmake: *** [Makefile:653: obj/x86_64/kernels/knl/1m/bli_dpackm_knl_asm_24x8.o] Error 1 Add an EXTRA_PATCHES entry to deal with this situation. Note that in the future, this may also have to be done for gcc 15 and later. In that case, the patch might be done unconditionally. [1] llvm/llvm-project#75580 [2] llvm/llvm-project#92883 PR: 280783 Approved by: maintainer timeout (2 weeks) MFH: 2024Q3
Since Knight Landing and Knight Mill microarchitectures are EOL, we
would like to remove intrinsic supports for its specific ISA in LLVM 19.
In LLVM 18, we will first emit a warning for the usage.