]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
amdgcn: Work around XNACK register allocation problem
authorAndrew Stubbs <ams@codesourcery.com>
Wed, 13 Dec 2023 12:00:52 +0000 (12:00 +0000)
committerAndrew Stubbs <ams@codesourcery.com>
Wed, 13 Dec 2023 15:30:42 +0000 (15:30 +0000)
The extra register pressure is causing infinite loops in some cases, especially
at -O0.  I have not yet observed any issue on devices that have AVGPRs for
spilling, and XNACK is only really useful on those devices anyway, so change
the defaults.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (NO_XNACK): Change the defaults.
* config/gcn/gcn-opts.h (enum hsaco_attr_type): Add HSACO_ATTR_DEFAULT.
* config/gcn/gcn.cc (gcn_option_override): Set the default flag_xnack.
* config/gcn/gcn.opt: Add -mxnack=default.
* doc/invoke.texi: Document the -mxnack default.

gcc/config/gcn/gcn-hsa.h
gcc/config/gcn/gcn-opts.h
gcc/config/gcn/gcn.cc
gcc/config/gcn/gcn.opt
gcc/doc/invoke.texi

index bfb104526c52636ce2b20b4e9bde3c52f1a3f64d..b44d42b02d6f3b911ece47f9e330453112dc91c4 100644 (file)
@@ -75,7 +75,9 @@ extern unsigned int gcn_local_sym_hash (const char *name);
    supported for gcn.  */
 #define GOMP_SELF_SPECS ""
 
-#define NO_XNACK "march=fiji:;march=gfx1030:;"
+#define NO_XNACK "march=fiji:;march=gfx1030:;" \
+    /* 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:;"
 
 /* In HSACOv4 no attribute setting means the binary supports "any" hardware
index b4f494d868cd7cd1b971e57f0a9b58f697a36ef4..634cec6d832459ab88d0ef708c3c06a0dab2682c 100644 (file)
@@ -65,7 +65,8 @@ enum hsaco_attr_type
 {
   HSACO_ATTR_OFF,
   HSACO_ATTR_ON,
-  HSACO_ATTR_ANY
+  HSACO_ATTR_ANY,
+  HSACO_ATTR_DEFAULT
 };
 
 #endif
index d92cd01d03f02f43b8436f6fa4562ae6d09b1652..b67551a2e8eee9e662a7256c20030eef42ca2ff9 100644 (file)
@@ -172,6 +172,29 @@ gcn_option_override (void)
       /* Allow HSACO_ATTR_ANY silently because that's the default.  */
       flag_xnack = HSACO_ATTR_OFF;
     }
+
+  /* There's no need for XNACK on devices without USM, and there are register
+     allocation problems caused by the early-clobber when AVGPR spills are not
+     available.
+     FIXME: can the regalloc mean the default can be really "any"?  */
+  if (flag_xnack == HSACO_ATTR_DEFAULT)
+    switch (gcn_arch)
+      {
+      case PROCESSOR_FIJI:
+      case PROCESSOR_VEGA10:
+      case PROCESSOR_VEGA20:
+      case PROCESSOR_GFX908:
+       flag_xnack = HSACO_ATTR_OFF;
+       break;
+      case PROCESSOR_GFX90a:
+       flag_xnack = HSACO_ATTR_ANY;
+       break;
+      default:
+       gcc_unreachable ();
+      }
+
+  if (flag_sram_ecc == HSACO_ATTR_DEFAULT)
+    flag_sram_ecc = HSACO_ATTR_ANY;
 }
 
 /* }}}  */
index c356a0cbb0894a51f4e33ffe9a8f111d5693f6a6..32486d9615feb4c49974f9c6e3b382dcbfab9d0a 100644 (file)
@@ -97,9 +97,12 @@ Enum(hsaco_attr_type) String(on) Value(HSACO_ATTR_ON)
 EnumValue
 Enum(hsaco_attr_type) String(any) Value(HSACO_ATTR_ANY)
 
+EnumValue
+Enum(hsaco_attr_type) String(default) Value(HSACO_ATTR_DEFAULT)
+
 mxnack=
-Target RejectNegative Joined ToLower Enum(hsaco_attr_type) Var(flag_xnack) Init(HSACO_ATTR_ANY)
-Compile for devices requiring XNACK enabled. Default \"any\".
+Target RejectNegative Joined ToLower Enum(hsaco_attr_type) Var(flag_xnack) Init(HSACO_ATTR_DEFAULT)
+Compile for devices requiring XNACK enabled. Default \"any\" if USM is supported.
 
 msram-ecc=
 Target RejectNegative Joined ToLower Enum(hsaco_attr_type) Var(flag_sram_ecc) Init(HSACO_ATTR_ANY)
index db039c47220963496c32427a941dd32b4e9741d1..8f885b8c6d69b512bd3be676bdc6bc737c7dc88f 100644 (file)
@@ -21628,7 +21628,8 @@ run-time performance.  The default is 32KB when using OpenACC or OpenMP, and
 Compile binaries suitable for devices with the XNACK feature enabled, disabled,
 or either mode.  Some devices always require XNACK and some allow the user to
 configure XNACK.  The compiled code must match the device mode.
-The default is @samp{-mxnack=any}.
+The default is @samp{-mxnack=any} on devices that support Unified Shared
+Memory, and @samp{-mxnack=no} otherwise.
 
 @end table