[committed] amdgcn: Add gfx908 support

Message ID b7a7662f-ff23-a165-cbfb-6209e33a907e@codesourcery.com
State New
Headers show
Series
  • [committed] amdgcn: Add gfx908 support
Related show

Commit Message

Andrew Stubbs Feb. 3, 2021, 2:50 p.m.
This patch adds a new -march option and multilib configuration to the 
amdgcn GPU target. The patch does not attempt to support any of the new 
features of the gfx908 devices, but does set the correct ELF flags etc. 
that are expected by the ROCm runtime.

The GFX908 devices are not generally available yet, and don't have a 
public name yet, but with this we will be ready when they do.

Andrew

Patch

amdgcn: Add gfx908 support

gcc/

	* config/gcn/gcn-opts.h (enum processor_type): Add PROCESSOR_GFX908.
	* config/gcn/gcn.c (gcn_omp_device_kind_arch_isa): Add gfx908.
	(output_file_start): Add gfx908.
	* config/gcn/gcn.opt (gpu_type): Add gfx908.
	* config/gcn/t-gcn-hsa (MULTILIB_OPTIONS): Add march=gfx908.
	(MULTILIB_DIRNAMES): Add gfx908.
	* config/gcn/mkoffload.c (EF_AMDGPU_MACH_AMDGCN_GFX908): New define.
	(main): Recognize gfx908.
	* config/gcn/t-omp-device: Add gfx908.

libgomp/

	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): Add
	EF_AMDGPU_MACH_AMDGCN_GFX908.
	(gcn_gfx908_s): New constant string.
	(isa_hsa_name): Add gfx908.
	(isa_code): Add gfx908.

diff --git a/gcc/config/gcn/gcn-opts.h b/gcc/config/gcn/gcn-opts.h
index ed9b45109ff..ed67d015ff8 100644
--- a/gcc/config/gcn/gcn-opts.h
+++ b/gcc/config/gcn/gcn-opts.h
@@ -22,7 +22,8 @@  enum processor_type
 {
   PROCESSOR_FIJI,    // gfx803
   PROCESSOR_VEGA10,  // gfx900
-  PROCESSOR_VEGA20   // gfx906
+  PROCESSOR_VEGA20,  // gfx906
+  PROCESSOR_GFX908   // as yet unnamed
 };
 
 /* Set in gcn_option_override.  */
diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 2351b24a4d5..e8bb0b63756 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -2589,6 +2589,8 @@  gcn_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
 	return gcn_arch == PROCESSOR_VEGA10;
       if (strcmp (name, "gfx906") == 0)
 	return gcn_arch == PROCESSOR_VEGA20;
+      if (strcmp (name, "gfx908") == 0)
+	return gcn_arch == PROCESSOR_GFX908;
       return 0;
     default:
       gcc_unreachable ();
@@ -5030,6 +5032,7 @@  output_file_start (void)
     case PROCESSOR_FIJI: cpu = "gfx803"; break;
     case PROCESSOR_VEGA10: cpu = "gfx900"; break;
     case PROCESSOR_VEGA20: cpu = "gfx906"; break;
+    case PROCESSOR_GFX908: cpu = "gfx908+sram-ecc"; break;
     default: gcc_unreachable ();
     }
 
diff --git a/gcc/config/gcn/gcn.opt b/gcc/config/gcn/gcn.opt
index 7fd84f83572..767d45826c2 100644
--- a/gcc/config/gcn/gcn.opt
+++ b/gcc/config/gcn/gcn.opt
@@ -34,6 +34,9 @@  Enum(gpu_type) String(gfx900) Value(PROCESSOR_VEGA10)
 EnumValue
 Enum(gpu_type) String(gfx906) Value(PROCESSOR_VEGA20)
 
+EnumValue
+Enum(gpu_type) String(gfx908) Value(PROCESSOR_GFX908)
+
 march=
 Target RejectNegative 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.c b/gcc/config/gcn/mkoffload.c
index eb1c717e6e9..dc9d5180a35 100644
--- a/gcc/config/gcn/mkoffload.c
+++ b/gcc/config/gcn/mkoffload.c
@@ -51,6 +51,8 @@ 
 #define EF_AMDGPU_MACH_AMDGCN_GFX900 0x2c
 #undef  EF_AMDGPU_MACH_AMDGCN_GFX906
 #define EF_AMDGPU_MACH_AMDGCN_GFX906 0x2f
+#undef  EF_AMDGPU_MACH_AMDGCN_GFX908
+#define EF_AMDGPU_MACH_AMDGCN_GFX908 0x230  // Assume SRAM-ECC enabled.
 
 #ifndef R_AMDGPU_NONE
 #define R_AMDGPU_NONE		0
@@ -856,6 +858,8 @@  main (int argc, char **argv)
 	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX900;
       else if (strcmp (argv[i], "-march=gfx906") == 0)
 	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX906;
+      else if (strcmp (argv[i], "-march=gfx908") == 0)
+	elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX908;
     }
 
   if (!(fopenacc ^ fopenmp))
diff --git a/gcc/config/gcn/t-gcn-hsa b/gcc/config/gcn/t-gcn-hsa
index bf47da79227..ee4d9b30ff2 100644
--- a/gcc/config/gcn/t-gcn-hsa
+++ b/gcc/config/gcn/t-gcn-hsa
@@ -42,8 +42,8 @@  ALL_HOST_OBJS += gcn-run.o
 gcn-run$(exeext): gcn-run.o
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $< -ldl
 
-MULTILIB_OPTIONS = march=gfx900/march=gfx906
-MULTILIB_DIRNAMES = gfx900 gfx906
+MULTILIB_OPTIONS = march=gfx900/march=gfx906/march=gfx908
+MULTILIB_DIRNAMES = gfx900 gfx906 gfx908
 
 gcn-tree.o: $(srcdir)/config/gcn/gcn-tree.c
 	$(COMPILE) $<
diff --git a/gcc/config/gcn/t-omp-device b/gcc/config/gcn/t-omp-device
index d9809d5f455..8461c432ca9 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.c
 	echo kind: gpu > $@
 	echo arch: gcn >> $@
-	echo isa: fiji gfx900 gfx906 >> $@
+	echo isa: fiji gfx900 gfx906 gfx908 >> $@
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 47f0b6e25f8..8e6af69988e 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -403,6 +403,7 @@  typedef enum {
   EF_AMDGPU_MACH_AMDGCN_GFX803 = 0x02a,
   EF_AMDGPU_MACH_AMDGCN_GFX900 = 0x02c,
   EF_AMDGPU_MACH_AMDGCN_GFX906 = 0x02f,
+  EF_AMDGPU_MACH_AMDGCN_GFX908 = 0x030
 } EF_AMDGPU_MACH;
 
 const static int EF_AMDGPU_MACH_MASK = 0x000000ff;
@@ -1596,6 +1597,7 @@  elf_gcn_isa_field (Elf64_Ehdr *image)
 const static char *gcn_gfx803_s = "gfx803";
 const static char *gcn_gfx900_s = "gfx900";
 const static char *gcn_gfx906_s = "gfx906";
+const static char *gcn_gfx908_s = "gfx908";
 const static int gcn_isa_name_len = 6;
 
 /* Returns the name that the HSA runtime uses for the ISA or NULL if we do not
@@ -1611,6 +1613,8 @@  isa_hsa_name (int isa) {
       return gcn_gfx900_s;
     case EF_AMDGPU_MACH_AMDGCN_GFX906:
       return gcn_gfx906_s;
+    case EF_AMDGPU_MACH_AMDGCN_GFX908:
+      return gcn_gfx908_s;
     }
   return NULL;
 }
@@ -1644,6 +1648,9 @@  isa_code(const char *isa) {
   if (!strncmp (isa, gcn_gfx906_s, gcn_isa_name_len))
     return EF_AMDGPU_MACH_AMDGCN_GFX906;
 
+  if (!strncmp (isa, gcn_gfx908_s, gcn_isa_name_len))
+    return EF_AMDGPU_MACH_AMDGCN_GFX908;
+
   return -1;
 }