Initial Granite Rapids D Support
Checks
Commit Message
Hi all,
This patch is to add initial support for Granite Rapids D for GCC.
The link of related information is listed below:
https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html
Also, the patch of removing AMX-COMPLEX from Granite Rapids will be backported
to GCC13.
This has been tested on x86_64-pc-linux-gnu. Is this ok for trunk? Thank you.
Sincerely,
Zewei Mo
gcc/ChangeLog:
* common/config/i386/cpuinfo.h
(get_intel_cpu): Handle Granite Rapids D.
* common/config/i386/i386-common.cc:
(processor_alias_table): Add graniterapids-d.
* common/config/i386/i386-cpuinfo.h
(enum processor_subtypes): Add INTEL_COREI7_GRANITERAPIDS_D.
* config.gcc: Add -march=graniterapids-d.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Handle graniterapids-d.
* gcc/config/i386/i386.h: (PTA_GRANITERAPIDS_D): New.
* doc/extend.texi: Add graniterapids-d.
* doc/invoke.texi: Ditto.
gcc/testsuite/ChangeLog:
* g++.target/i386/mv16.C: Add graniterapids-d.
* gcc.target/i386/funcspec-56.inc: Handle new march.
---
gcc/common/config/i386/cpuinfo.h | 9 ++++++++-
gcc/common/config/i386/i386-common.cc | 2 ++
gcc/common/config/i386/i386-cpuinfo.h | 1 +
gcc/config.gcc | 2 +-
gcc/config/i386/driver-i386.cc | 3 +++
gcc/config/i386/i386.h | 4 +++-
gcc/doc/extend.texi | 3 +++
gcc/doc/invoke.texi | 11 +++++++++++
gcc/testsuite/g++.target/i386/mv16.C | 6 ++++++
gcc/testsuite/gcc.target/i386/funcspec-56.inc | 1 +
10 files changed, 39 insertions(+), 3 deletions(-)
Comments
> -----Original Message-----
> From: Mo, Zewei <zewei.mo@intel.com>
> Sent: Wednesday, July 12, 2023 1:56 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Liu, Hongtao <hongtao.liu@intel.com>; ubizjak@gmail.com
> Subject: [PATCH] Initial Granite Rapids D Support
>
> Hi all,
>
> This patch is to add initial support for Granite Rapids D for GCC.
>
> The link of related information is listed below:
> https://www.intel.com/content/www/us/en/develop/download/intel-
> architecture-instruction-set-extensions-programming-reference.html
>
> Also, the patch of removing AMX-COMPLEX from Granite Rapids will be
> backported to GCC13.
>
> This has been tested on x86_64-pc-linux-gnu. Is this ok for trunk? Thank you.
Ok.
>
> Sincerely,
> Zewei Mo
>
> gcc/ChangeLog:
>
> * common/config/i386/cpuinfo.h
> (get_intel_cpu): Handle Granite Rapids D.
> * common/config/i386/i386-common.cc:
> (processor_alias_table): Add graniterapids-d.
> * common/config/i386/i386-cpuinfo.h
> (enum processor_subtypes): Add INTEL_COREI7_GRANITERAPIDS_D.
> * config.gcc: Add -march=graniterapids-d.
> * config/i386/driver-i386.cc (host_detect_local_cpu):
> Handle graniterapids-d.
> * gcc/config/i386/i386.h: (PTA_GRANITERAPIDS_D): New.
> * doc/extend.texi: Add graniterapids-d.
> * doc/invoke.texi: Ditto.
>
> gcc/testsuite/ChangeLog:
>
> * g++.target/i386/mv16.C: Add graniterapids-d.
> * gcc.target/i386/funcspec-56.inc: Handle new march.
> ---
> gcc/common/config/i386/cpuinfo.h | 9 ++++++++-
> gcc/common/config/i386/i386-common.cc | 2 ++
> gcc/common/config/i386/i386-cpuinfo.h | 1 +
> gcc/config.gcc | 2 +-
> gcc/config/i386/driver-i386.cc | 3 +++
> gcc/config/i386/i386.h | 4 +++-
> gcc/doc/extend.texi | 3 +++
> gcc/doc/invoke.texi | 11 +++++++++++
> gcc/testsuite/g++.target/i386/mv16.C | 6 ++++++
> gcc/testsuite/gcc.target/i386/funcspec-56.inc | 1 +
> 10 files changed, 39 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/common/config/i386/cpuinfo.h
> b/gcc/common/config/i386/cpuinfo.h
> index ae48bc17771..7c2565c1d93 100644
> --- a/gcc/common/config/i386/cpuinfo.h
> +++ b/gcc/common/config/i386/cpuinfo.h
> @@ -565,7 +565,6 @@ get_intel_cpu (struct __processor_model
> *cpu_model,
> cpu_model->__cpu_type = INTEL_SIERRAFOREST;
> break;
> case 0xad:
> - case 0xae:
> /* Granite Rapids. */
> cpu = "graniterapids";
> CHECK___builtin_cpu_is ("corei7"); @@ -573,6 +572,14 @@
> get_intel_cpu (struct __processor_model *cpu_model,
> cpu_model->__cpu_type = INTEL_COREI7;
> cpu_model->__cpu_subtype = INTEL_COREI7_GRANITERAPIDS;
> break;
> + case 0xae:
> + /* Granite Rapids D. */
> + cpu = "graniterapids-d";
> + CHECK___builtin_cpu_is ("corei7");
> + CHECK___builtin_cpu_is ("graniterapids-d");
> + cpu_model->__cpu_type = INTEL_COREI7;
> + cpu_model->__cpu_subtype = INTEL_COREI7_GRANITERAPIDS_D;
> + break;
> case 0xb6:
> /* Grand Ridge. */
> cpu = "grandridge";
> diff --git a/gcc/common/config/i386/i386-common.cc
> b/gcc/common/config/i386/i386-common.cc
> index bf126f14073..8cea3669239 100644
> --- a/gcc/common/config/i386/i386-common.cc
> +++ b/gcc/common/config/i386/i386-common.cc
> @@ -2094,6 +2094,8 @@ const pta processor_alias_table[] =
> M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2},
> {"graniterapids", PROCESSOR_GRANITERAPIDS, CPU_HASWELL,
> PTA_GRANITERAPIDS,
> M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS), P_PROC_AVX512F},
> + {"graniterapids-d", PROCESSOR_GRANITERAPIDS, CPU_HASWELL,
> PTA_GRANITERAPIDS_D,
> + M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS_D),
> P_PROC_AVX512F},
> {"bonnell", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL,
> M_CPU_TYPE (INTEL_BONNELL), P_PROC_SSSE3},
> {"atom", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL, diff --git
> a/gcc/common/config/i386/i386-cpuinfo.h b/gcc/common/config/i386/i386-
> cpuinfo.h
> index 2dafbb25a49..254dfec70e5 100644
> --- a/gcc/common/config/i386/i386-cpuinfo.h
> +++ b/gcc/common/config/i386/i386-cpuinfo.h
> @@ -98,6 +98,7 @@ enum processor_subtypes
> ZHAOXIN_FAM7H_LUJIAZUI,
> AMDFAM19H_ZNVER4,
> INTEL_COREI7_GRANITERAPIDS,
> + INTEL_COREI7_GRANITERAPIDS_D,
> CPU_SUBTYPE_MAX
> };
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc index d88071773c9..1446eb2b3ca
> 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -682,7 +682,7 @@ silvermont knl knm skylake-avx512 cannonlake
> icelake-client icelake-server \ skylake goldmont goldmont-plus tremont
> cascadelake tigerlake cooperlake \ sapphirerapids alderlake rocketlake
> eden-x2 nano nano-1000 nano-2000 nano-3000 \
> nano-x2 eden-x4 nano-x4 lujiazui x86-64 x86-64-v2 x86-64-v3 x86-64-v4 \ -
> sierraforest graniterapids grandridge native"
> +sierraforest graniterapids graniterapids-d grandridge native"
>
> # Additional x86 processors supported by --with-cpu=. Each processor #
> MUST be separated by exactly one space.
> diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc
> index 54c019a7fa3..4c362ffcfa3 100644
> --- a/gcc/config/i386/driver-i386.cc
> +++ b/gcc/config/i386/driver-i386.cc
> @@ -594,6 +594,9 @@ const char *host_detect_local_cpu (int argc, const
> char **argv)
> /* Assume Grand Ridge. */
> if (has_feature (FEATURE_RAOINT))
> cpu = "grandridge";
> + /* Assume Granite Rapids D. */
> + else if (has_feature (FEATURE_AMX_COMPLEX))
> + cpu = "graniterapids-d";
> /* Assume Granite Rapids. */
> else if (has_feature (FEATURE_AMX_FP16))
> cpu = "graniterapids";
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index
> 5ac9c78d3ba..efb2414f766 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -2343,7 +2343,9 @@ constexpr wide_int_bitmask PTA_ALDERLAKE =
> PTA_TREMONT | PTA_ADX | PTA_AVX constexpr wide_int_bitmask
> PTA_SIERRAFOREST = PTA_ALDERLAKE | PTA_AVXIFMA
> | PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD;
> constexpr wide_int_bitmask PTA_GRANITERAPIDS = PTA_SAPPHIRERAPIDS |
> PTA_AMX_FP16
> - | PTA_PREFETCHI | PTA_AMX_COMPLEX;
> + | PTA_PREFETCHI;
> +constexpr wide_int_bitmask PTA_GRANITERAPIDS_D =
> PTA_GRANITERAPIDS
> + | PTA_AMX_COMPLEX;
> constexpr wide_int_bitmask PTA_GRANDRIDGE = PTA_SIERRAFOREST |
> PTA_RAOINT; constexpr wide_int_bitmask PTA_KNM = PTA_KNL |
> PTA_AVX5124VNNIW
> | PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ; diff --git
> a/gcc/doc/extend.texi b/gcc/doc/extend.texi index
> d1b018ee6d6..17436e4579b 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -22144,6 +22144,9 @@ Intel Core i7 Rocketlake CPU.
> @item graniterapids
> Intel Core i7 graniterapids CPU.
>
> +@item graniterapids-d
> +Intel Core i7 graniterapids D CPU.
> +
> @item bonnell
> Intel Atom Bonnell CPU.
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index
> efcf3bfb3d6..059500f58b4 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -32663,6 +32663,17 @@ MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT,
> ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, UINTR,
> AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16,
> AMX-FP16 and PREFETCHI instruction set support.
>
> +@item graniterapids-d
> +Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE,
> +SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX,
> +XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA,
> +MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC,
> XSAVES,
> +SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, PKU,
> AVX512VBMI,
> +AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
> VPCLMULQDQ,
> +AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
> MOVDIRI,
> +MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE,
> WAITPKG,
> +SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI,
> AVX512FP16, AVX512BF16, AMX-FP16, PREFETCHI and AMX-COMPLEX
> instruction set support.
> +
> @item k6
> AMD K6 CPU with MMX instruction set support.
>
> diff --git a/gcc/testsuite/g++.target/i386/mv16.C
> b/gcc/testsuite/g++.target/i386/mv16.C
> index 772791b96e8..2158d58a94e 100644
> --- a/gcc/testsuite/g++.target/i386/mv16.C
> +++ b/gcc/testsuite/g++.target/i386/mv16.C
> @@ -104,6 +104,10 @@ int __attribute__ ((target("arch=grandridge"))) foo ()
> {
> return 27;
> }
>
> +int __attribute__ ((target("arch=graniterapids-d"))) foo () {
> + return 28;
> +}
> +
> int main ()
> {
> int val = foo ();
> @@ -148,6 +152,8 @@ int main ()
> assert (val == 26);
> else if (__builtin_cpu_is ("grandridge"))
> assert (val == 27);
> + else if (__builtin_cpu_is ("graniterapids-d"))
> + assert (val == 28);
> else
> assert (val == 0);
>
> diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> index cf2899f9c32..f466962c36c 100644
> --- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> +++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
> @@ -203,6 +203,7 @@ extern void test_arch_sapphirerapids (void)
> __attribute__((__target__("arch=sapp
> extern void test_arch_alderlake (void)
> __attribute__((__target__("arch=alderlake")));
> extern void test_arch_rocketlake (void)
> __attribute__((__target__("arch=rocketlake")));
> extern void test_arch_graniterapids (void)
> __attribute__((__target__("arch=graniterapids")));
> +extern void test_arch_graniterapids_d (void)
> __attribute__((__target__("arch=graniterapids-d")));
> extern void test_arch_lujiazui (void)
> __attribute__((__target__("arch=lujiazui")));
> extern void test_arch_k8 (void)
> __attribute__((__target__("arch=k8")));
> extern void test_arch_k8_sse3 (void)
> __attribute__((__target__("arch=k8-sse3")));
> --
> 2.31.1
@@ -565,7 +565,6 @@ get_intel_cpu (struct __processor_model *cpu_model,
cpu_model->__cpu_type = INTEL_SIERRAFOREST;
break;
case 0xad:
- case 0xae:
/* Granite Rapids. */
cpu = "graniterapids";
CHECK___builtin_cpu_is ("corei7");
@@ -573,6 +572,14 @@ get_intel_cpu (struct __processor_model *cpu_model,
cpu_model->__cpu_type = INTEL_COREI7;
cpu_model->__cpu_subtype = INTEL_COREI7_GRANITERAPIDS;
break;
+ case 0xae:
+ /* Granite Rapids D. */
+ cpu = "graniterapids-d";
+ CHECK___builtin_cpu_is ("corei7");
+ CHECK___builtin_cpu_is ("graniterapids-d");
+ cpu_model->__cpu_type = INTEL_COREI7;
+ cpu_model->__cpu_subtype = INTEL_COREI7_GRANITERAPIDS_D;
+ break;
case 0xb6:
/* Grand Ridge. */
cpu = "grandridge";
@@ -2094,6 +2094,8 @@ const pta processor_alias_table[] =
M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2},
{"graniterapids", PROCESSOR_GRANITERAPIDS, CPU_HASWELL, PTA_GRANITERAPIDS,
M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS), P_PROC_AVX512F},
+ {"graniterapids-d", PROCESSOR_GRANITERAPIDS, CPU_HASWELL, PTA_GRANITERAPIDS_D,
+ M_CPU_SUBTYPE (INTEL_COREI7_GRANITERAPIDS_D), P_PROC_AVX512F},
{"bonnell", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL,
M_CPU_TYPE (INTEL_BONNELL), P_PROC_SSSE3},
{"atom", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL,
@@ -98,6 +98,7 @@ enum processor_subtypes
ZHAOXIN_FAM7H_LUJIAZUI,
AMDFAM19H_ZNVER4,
INTEL_COREI7_GRANITERAPIDS,
+ INTEL_COREI7_GRANITERAPIDS_D,
CPU_SUBTYPE_MAX
};
@@ -682,7 +682,7 @@ silvermont knl knm skylake-avx512 cannonlake icelake-client icelake-server \
skylake goldmont goldmont-plus tremont cascadelake tigerlake cooperlake \
sapphirerapids alderlake rocketlake eden-x2 nano nano-1000 nano-2000 nano-3000 \
nano-x2 eden-x4 nano-x4 lujiazui x86-64 x86-64-v2 x86-64-v3 x86-64-v4 \
-sierraforest graniterapids grandridge native"
+sierraforest graniterapids graniterapids-d grandridge native"
# Additional x86 processors supported by --with-cpu=. Each processor
# MUST be separated by exactly one space.
@@ -594,6 +594,9 @@ const char *host_detect_local_cpu (int argc, const char **argv)
/* Assume Grand Ridge. */
if (has_feature (FEATURE_RAOINT))
cpu = "grandridge";
+ /* Assume Granite Rapids D. */
+ else if (has_feature (FEATURE_AMX_COMPLEX))
+ cpu = "graniterapids-d";
/* Assume Granite Rapids. */
else if (has_feature (FEATURE_AMX_FP16))
cpu = "graniterapids";
@@ -2343,7 +2343,9 @@ constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_TREMONT | PTA_ADX | PTA_AVX
constexpr wide_int_bitmask PTA_SIERRAFOREST = PTA_ALDERLAKE | PTA_AVXIFMA
| PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD;
constexpr wide_int_bitmask PTA_GRANITERAPIDS = PTA_SAPPHIRERAPIDS | PTA_AMX_FP16
- | PTA_PREFETCHI | PTA_AMX_COMPLEX;
+ | PTA_PREFETCHI;
+constexpr wide_int_bitmask PTA_GRANITERAPIDS_D = PTA_GRANITERAPIDS
+ | PTA_AMX_COMPLEX;
constexpr wide_int_bitmask PTA_GRANDRIDGE = PTA_SIERRAFOREST | PTA_RAOINT;
constexpr wide_int_bitmask PTA_KNM = PTA_KNL | PTA_AVX5124VNNIW
| PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ;
@@ -22144,6 +22144,9 @@ Intel Core i7 Rocketlake CPU.
@item graniterapids
Intel Core i7 graniterapids CPU.
+@item graniterapids-d
+Intel Core i7 graniterapids D CPU.
+
@item bonnell
Intel Atom Bonnell CPU.
@@ -32663,6 +32663,17 @@ MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
+@item graniterapids-d
+Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
+SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
+RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
+AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
+AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
+VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
+MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
+SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16,
+AVX512BF16, AMX-FP16, PREFETCHI and AMX-COMPLEX instruction set support.
+
@item k6
AMD K6 CPU with MMX instruction set support.
@@ -104,6 +104,10 @@ int __attribute__ ((target("arch=grandridge"))) foo () {
return 27;
}
+int __attribute__ ((target("arch=graniterapids-d"))) foo () {
+ return 28;
+}
+
int main ()
{
int val = foo ();
@@ -148,6 +152,8 @@ int main ()
assert (val == 26);
else if (__builtin_cpu_is ("grandridge"))
assert (val == 27);
+ else if (__builtin_cpu_is ("graniterapids-d"))
+ assert (val == 28);
else
assert (val == 0);
@@ -203,6 +203,7 @@ extern void test_arch_sapphirerapids (void) __attribute__((__target__("arch=sapp
extern void test_arch_alderlake (void) __attribute__((__target__("arch=alderlake")));
extern void test_arch_rocketlake (void) __attribute__((__target__("arch=rocketlake")));
extern void test_arch_graniterapids (void) __attribute__((__target__("arch=graniterapids")));
+extern void test_arch_graniterapids_d (void) __attribute__((__target__("arch=graniterapids-d")));
extern void test_arch_lujiazui (void) __attribute__((__target__("arch=lujiazui")));
extern void test_arch_k8 (void) __attribute__((__target__("arch=k8")));
extern void test_arch_k8_sse3 (void) __attribute__((__target__("arch=k8-sse3")));