public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] amdgcn: Add gfx1103 target
@ 2024-03-22 14:45 Andrew Stubbs
  0 siblings, 0 replies; only message in thread
From: Andrew Stubbs @ 2024-03-22 14:45 UTC (permalink / raw)
  To: gcc-patches

This patch adds support for the gfx1103 RDNA3 APU integrated graphics
devices.  The ROCm documentation warns that these may not be supported,
but it seems to work at least partially.

This device should be considered "Experimental" at this point, although
so far it seems to be at least as functional as gfx1100.

Committed to mainline.

Andrew

gcc/ChangeLog:

	* config.gcc (amdgcn): Add gfx1103 entries.
	* config/gcn/gcn-hsa.h (NO_XNACK): Likewise.
	(gcn_local_sym_hash): Likewise.
	* config/gcn/gcn-opts.h (enum processor_type): Likewise.
	(TARGET_GFX1103): New macro.
	* config/gcn/gcn.cc (gcn_option_override): Handle gfx1103.
	(gcn_omp_device_kind_arch_isa): Likewise.
	(output_file_start): Likewise.
	(gcn_hsa_declare_function_name): Use TARGET_RDNA3, not just gfx1100.
	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __gfx1103__.
	* config/gcn/gcn.opt: Add gfx1103.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1103): New.
	(main): Handle gfx1103.
	* config/gcn/t-omp-device: Add gfx1103 isa.
	* doc/install.texi (amdgcn): Add gfx1103.
	* doc/invoke.texi (-march): Likewise.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): GFX1103.
	(gcn_gfx1103_s): New.
	(isa_hsa_name): Handle gfx1103.
	(isa_code): Likewise.
	(max_isa_vgprs): Likewise.
---
 gcc/config.gcc              |  4 ++--
 gcc/config/gcn/gcn-hsa.h    |  6 +++---
 gcc/config/gcn/gcn-opts.h   |  4 +++-
 gcc/config/gcn/gcn.cc       | 14 ++++++++++++--
 gcc/config/gcn/gcn.h        |  2 ++
 gcc/config/gcn/gcn.opt      |  3 +++
 gcc/config/gcn/mkoffload.cc |  5 +++++
 gcc/config/gcn/t-omp-device |  2 +-
 gcc/doc/install.texi        | 13 +++++++------
 gcc/doc/invoke.texi         |  3 +++
 libgomp/plugin/plugin-gcn.c | 10 +++++++++-
 11 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 040afabd9ec..87a5c92b6e3 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4560,7 +4560,7 @@ case "${target}" in
 		for which in arch tune; do
 			eval "val=\$with_$which"
 			case ${val} in
-			"" | fiji | gfx900 | gfx906 | gfx908 | gfx90a | gfx1030 | gfx1100)
+			"" | fiji | gfx900 | gfx906 | gfx908 | gfx90a | gfx1030 | gfx1100 | gfx1103)
 				# OK
 				;;
 			*)
@@ -4576,7 +4576,7 @@ case "${target}" in
 			TM_MULTILIB_CONFIG=
 			;;
 		xdefault | xyes)
-			TM_MULTILIB_CONFIG=`echo "gfx900,gfx906,gfx908,gfx90a,gfx1030,gfx1100" | sed "s/${with_arch},\?//;s/,$//"`
+			TM_MULTILIB_CONFIG=`echo "gfx900,gfx906,gfx908,gfx90a,gfx1030,gfx1100,gfx1103" | sed "s/${with_arch},\?//;s/,$//"`
 			;;
 		*)
 			TM_MULTILIB_CONFIG="${with_multilib_list}"
diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h
index c75256dbac3..ac32b8a328f 100644
--- a/gcc/config/gcn/gcn-hsa.h
+++ b/gcc/config/gcn/gcn-hsa.h
@@ -90,7 +90,7 @@ extern unsigned int gcn_local_sym_hash (const char *name);
    the ELF flags (e_flags) of that generated file must be identical to those
    generated by the compiler.  */
 
-#define NO_XNACK "march=fiji:;march=gfx1030:;march=gfx1100:;" \
+#define NO_XNACK "march=fiji:;march=gfx1030:;march=gfx1100:;march=gfx1103:;" \
     /* These match the defaults set in gcn.cc.  */ \
     "!mxnack*|mxnack=default:%{march=gfx900|march=gfx906|march=gfx908:-mattr=-xnack};"
 #define NO_SRAM_ECC "!march=*:;march=fiji:;march=gfx900:;march=gfx906:;"
@@ -106,8 +106,8 @@ extern unsigned int gcn_local_sym_hash (const char *name);
 		  "%{" ABI_VERSION_SPEC "} " \
 		  "%{" NO_XNACK XNACKOPT "} " \
 		  "%{" NO_SRAM_ECC SRAMOPT "} " \
-		  "%{march=gfx1030|march=gfx1100:-mattr=+wavefrontsize64} " \
-		  "%{march=gfx1030|march=gfx1100:-mattr=+cumode} " \
+		  "%{march=gfx1030|march=gfx1100|march=gfx1103:-mattr=+wavefrontsize64} " \
+		  "%{march=gfx1030|march=gfx1100|march=gfx1103:-mattr=+cumode} " \
 		  "-filetype=obj"
 #define LINK_SPEC "--pie --export-dynamic"
 #define LIB_SPEC  "-lc"
diff --git a/gcc/config/gcn/gcn-opts.h b/gcc/config/gcn/gcn-opts.h
index 6be2c9204fa..285746f7f4d 100644
--- a/gcc/config/gcn/gcn-opts.h
+++ b/gcc/config/gcn/gcn-opts.h
@@ -26,7 +26,8 @@ enum processor_type
   PROCESSOR_GFX908,
   PROCESSOR_GFX90a,
   PROCESSOR_GFX1030,
-  PROCESSOR_GFX1100
+  PROCESSOR_GFX1100,
+  PROCESSOR_GFX1103
 };
 
 #define TARGET_FIJI (gcn_arch == PROCESSOR_FIJI)
@@ -36,6 +37,7 @@ enum processor_type
 #define TARGET_GFX90a (gcn_arch == PROCESSOR_GFX90a)
 #define TARGET_GFX1030 (gcn_arch == PROCESSOR_GFX1030)
 #define TARGET_GFX1100 (gcn_arch == PROCESSOR_GFX1100)
+#define TARGET_GFX1103 (gcn_arch == PROCESSOR_GFX1103)
 
 /* Set in gcn_option_override.  */
 extern enum gcn_isa {
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index fca001811e5..498146dcde9 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -140,6 +140,7 @@ gcn_option_override (void)
       : gcn_arch == PROCESSOR_GFX90a ? ISA_CDNA2
       : gcn_arch == PROCESSOR_GFX1030 ? ISA_RDNA2
       : gcn_arch == PROCESSOR_GFX1100 ? ISA_RDNA3
+      : gcn_arch == PROCESSOR_GFX1103 ? ISA_RDNA3
       : ISA_UNKNOWN);
   gcc_assert (gcn_isa != ISA_UNKNOWN);
 
@@ -164,13 +165,15 @@ gcn_option_override (void)
   /* gfx803 "Fiji", gfx1030 and gfx1100 do not support XNACK.  */
   if (gcn_arch == PROCESSOR_FIJI
       || gcn_arch == PROCESSOR_GFX1030
-      || gcn_arch == PROCESSOR_GFX1100)
+      || gcn_arch == PROCESSOR_GFX1100
+      || gcn_arch == PROCESSOR_GFX1103)
     {
       if (flag_xnack == HSACO_ATTR_ON)
 	error ("%<-mxnack=on%> is incompatible with %<-march=%s%>",
 	       (gcn_arch == PROCESSOR_FIJI ? "fiji"
 		: gcn_arch == PROCESSOR_GFX1030 ? "gfx1030"
 		: gcn_arch == PROCESSOR_GFX1100 ? "gfx1100"
+		: gcn_arch == PROCESSOR_GFX1103 ? "gfx1103"
 		: NULL));
       /* Allow HSACO_ATTR_ANY silently because that's the default.  */
       flag_xnack = HSACO_ATTR_OFF;
@@ -3048,6 +3051,8 @@ gcn_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
 	return gcn_arch == PROCESSOR_GFX1030;
       if (strcmp (name, "gfx1100") == 0)
 	return gcn_arch == PROCESSOR_GFX1100;
+      if (strcmp (name, "gfx1103") == 0)
+	return gcn_arch == PROCESSOR_GFX1103;
       return 0;
     default:
       gcc_unreachable ();
@@ -6558,6 +6563,11 @@ output_file_start (void)
       xnack = "";
       sram_ecc = "";
       break;
+    case PROCESSOR_GFX1103:
+      cpu = "gfx1103";
+      xnack = "";
+      sram_ecc = "";
+      break;
     default: gcc_unreachable ();
     }
 
@@ -6705,7 +6715,7 @@ gcn_hsa_declare_function_name (FILE *file, const char *name,
 	   xnack_enabled,
 	   LDS_SIZE);
   /* Not supported with 'architected flat scratch'.  */
-  if (gcn_arch != PROCESSOR_GFX1100)
+  if (!TARGET_RDNA3)
     fprintf (file,
 	   "\t  .amdhsa_reserve_flat_scratch\t0\n");
   if (gcn_arch == PROCESSOR_GFX90a)
diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
index c314c7b4ae8..b003db6cd26 100644
--- a/gcc/config/gcn/gcn.h
+++ b/gcc/config/gcn/gcn.h
@@ -51,6 +51,8 @@
 	builtin_define ("__gfx1030");                                          \
       else if (TARGET_GFX1100)                                                 \
 	builtin_define ("__gfx1100__");                                        \
+      else if (TARGET_GFX1103)                                                 \
+	builtin_define ("__gfx1103__");                                        \
       else                                                                     \
 	gcc_unreachable ();                                                    \
   } while (0)
diff --git a/gcc/config/gcn/gcn.opt b/gcc/config/gcn/gcn.opt
index 842fd36d25c..e06a2849d90 100644
--- a/gcc/config/gcn/gcn.opt
+++ b/gcc/config/gcn/gcn.opt
@@ -46,6 +46,9 @@ Enum(gpu_type) String(gfx1030) Value(PROCESSOR_GFX1030)
 EnumValue
 Enum(gpu_type) String(gfx1100) Value(PROCESSOR_GFX1100)
 
+EnumValue
+Enum(gpu_type) String(gfx1103) Value(PROCESSOR_GFX1103)
+
 march=
 Target RejectNegative Negative(march=) Joined ToLower Enum(gpu_type) Var(gcn_arch) Init(PROCESSOR_FIJI)
 Specify the name of the target GPU.
diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc
index fe443abba21..58eeada8295 100644
--- a/gcc/config/gcn/mkoffload.cc
+++ b/gcc/config/gcn/mkoffload.cc
@@ -61,6 +61,8 @@
 #define EF_AMDGPU_MACH_AMDGCN_GFX1030 0x36
 #undef  EF_AMDGPU_MACH_AMDGCN_GFX1100
 #define EF_AMDGPU_MACH_AMDGCN_GFX1100 0x41
+#undef  EF_AMDGPU_MACH_AMDGCN_GFX1103
+#define EF_AMDGPU_MACH_AMDGCN_GFX1103 0x44
 
 #define EF_AMDGPU_FEATURE_XNACK_V4	0x300  /* Mask.  */
 #define EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4	0x000
@@ -971,6 +973,8 @@ main (int argc, char **argv)
 	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX1030;
       else if (strcmp (argv[i], "-march=gfx1100") == 0)
 	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX1100;
+      else if (strcmp (argv[i], "-march=gfx1103") == 0)
+	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX1103;
 #define STR "-mstack-size="
       else if (startswith (argv[i], STR))
 	gcn_stack_size = atoi (argv[i] + strlen (STR));
@@ -1013,6 +1017,7 @@ main (int argc, char **argv)
     case EF_AMDGPU_MACH_AMDGCN_GFX803:
     case EF_AMDGPU_MACH_AMDGCN_GFX1030:
     case EF_AMDGPU_MACH_AMDGCN_GFX1100:
+    case EF_AMDGPU_MACH_AMDGCN_GFX1103:
       SET_XNACK_UNSET (elf_flags);
       SET_SRAM_ECC_UNSET (elf_flags);
       break;
diff --git a/gcc/config/gcn/t-omp-device b/gcc/config/gcn/t-omp-device
index 2315ad594a3..037df2657cc 100644
--- a/gcc/config/gcn/t-omp-device
+++ b/gcc/config/gcn/t-omp-device
@@ -1,4 +1,4 @@
 omp-device-properties-gcn: $(srcdir)/config/gcn/gcn.cc
 	echo kind: gpu > $@
 	echo arch: amdgcn gcn >> $@
-	echo isa: fiji gfx803 gfx900 gfx906 gfx908 gfx90a gfx1030 gfx1100 >> $@
+	echo isa: fiji gfx803 gfx900 gfx906 gfx908 gfx90a gfx1030 gfx1100 gfx1103 >> $@
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 014ca25aa62..a9872e86bee 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1266,11 +1266,11 @@ default set of libraries is selected based on the value of
 @item amdgcn*-*-*
 @var{list} is a comma separated list of ISA names (allowed values: @code{fiji},
 @code{gfx900}, @code{gfx906}, @code{gfx908}, @code{gfx90a}, @code{gfx1030},
-@code{gfx1100}).  It ought not include the name of the default ISA, specified
-via @option{--with-arch}.  If @var{list} is empty, then there will be no
-multilibs and only the default run-time library will be built.  If @var{list}
-is @code{default} or @option{--with-multilib-list=} is not specified, then
-the default set of libraries is selected.
+@code{gfx1100}, @code{gfx1103}).  It ought not include the name of the default
+ISA, specified via @option{--with-arch}.  If @var{list} is empty, then there
+will be no multilibs and only the default run-time library will be built.  If
+@var{list} is @code{default} or @option{--with-multilib-list=} is not
+specified, then the default set of libraries is selected.
 
 @item arm*-*-*
 @var{list} is a comma separated list of @code{aprofile} and
@@ -3940,7 +3940,8 @@ Instead of GNU Binutils, you will need to install LLVM 15, or later, and copy
 @file{bin/llvm-nm} to @file{amdgcn-amdhsa/bin/nm}, and
 @file{bin/llvm-ar} to both @file{bin/amdgcn-amdhsa-ar} and
 @file{bin/amdgcn-amdhsa-ranlib}.  Note that LLVM 13.0.1 or LLVM 14 can be used
-by specifying a @code{--with-multilib-list=} that does not list @code{gfx1100}.
+by specifying a @code{--with-multilib-list=} that does not list @code{gfx1100}
+and @code{gfx1103}.
 
 Use Newlib (4.3.0 or newer; 4.4.0 or later is recommended).
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e0950ca5dc2..e7b96212354 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -21795,6 +21795,9 @@ Compile for RDNA2 gfx1030 devices (GFX10 series).
 @item gfx1100
 Compile for RDNA3 gfx1100 devices (GFX11 series).
 
+@item gfx1103
+Compile for RDNA3 gfx1103 devices (GFX11 series).
+
 @end table
 
 @opindex msram-ecc
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 7e141a85f31..53dc1c7d23a 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -391,7 +391,8 @@ typedef enum {
   EF_AMDGPU_MACH_AMDGCN_GFX908 = 0x030,
   EF_AMDGPU_MACH_AMDGCN_GFX90a = 0x03f,
   EF_AMDGPU_MACH_AMDGCN_GFX1030 = 0x036,
-  EF_AMDGPU_MACH_AMDGCN_GFX1100 = 0x041
+  EF_AMDGPU_MACH_AMDGCN_GFX1100 = 0x041,
+  EF_AMDGPU_MACH_AMDGCN_GFX1103 = 0x044
 } EF_AMDGPU_MACH;
 
 const static int EF_AMDGPU_MACH_MASK = 0x000000ff;
@@ -1677,6 +1678,7 @@ const static char *gcn_gfx908_s = "gfx908";
 const static char *gcn_gfx90a_s = "gfx90a";
 const static char *gcn_gfx1030_s = "gfx1030";
 const static char *gcn_gfx1100_s = "gfx1100";
+const static char *gcn_gfx1103_s = "gfx1103";
 const static int gcn_isa_name_len = 7;
 
 /* Returns the name that the HSA runtime uses for the ISA or NULL if we do not
@@ -1700,6 +1702,8 @@ isa_hsa_name (int isa) {
       return gcn_gfx1030_s;
     case EF_AMDGPU_MACH_AMDGCN_GFX1100:
       return gcn_gfx1100_s;
+    case EF_AMDGPU_MACH_AMDGCN_GFX1103:
+      return gcn_gfx1103_s;
     }
   return NULL;
 }
@@ -1745,6 +1749,9 @@ isa_code(const char *isa) {
   if (!strncmp (isa, gcn_gfx1100_s, gcn_isa_name_len))
     return EF_AMDGPU_MACH_AMDGCN_GFX1100;
 
+  if (!strncmp (isa, gcn_gfx1103_s, gcn_isa_name_len))
+    return EF_AMDGPU_MACH_AMDGCN_GFX1103;
+
   return EF_AMDGPU_MACH_UNSUPPORTED;
 }
 
@@ -1765,6 +1772,7 @@ max_isa_vgprs (int isa)
     case EF_AMDGPU_MACH_AMDGCN_GFX1030:
       return 512;  /* 512 SIMD32 = 256 wavefrontsize64.  */
     case EF_AMDGPU_MACH_AMDGCN_GFX1100:
+    case EF_AMDGPU_MACH_AMDGCN_GFX1103:
       return 1536; /* 1536 SIMD32 = 768 wavefrontsize64.  */
     }
   GOMP_PLUGIN_fatal ("unhandled ISA in max_isa_vgprs");
-- 
2.41.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-22 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 14:45 [committed] amdgcn: Add gfx1103 target Andrew Stubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).