public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] amdgcn: Prefer V32 on RDNA devices
@ 2024-03-22 15:54 Andrew Stubbs
  2024-03-28  7:00 ` Thomas Schwinge
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Stubbs @ 2024-03-22 15:54 UTC (permalink / raw)
  To: gcc-patches

This patch alters the default (preferred) vector size to 32 on RDNA devices to
better match the actual hardware.  64-lane vectors will continue to be
used where they are hard-coded (such as function prologues).

We run these devices in wavefrontsize64 for compatibility, but they actually
only have 32-lane vectors, natively.  If the upper part of a V64 is masked
off (as it is in V32) then RDNA devices will skip execution of the upper part
for most operations, so this adjustment shouldn't leave too much performance on
the table.  One exception is memory instructions, so full wavefrontsize32
support would be better.

The advantage is that we avoid the missing V64 operations (such as permute and
vec_extract).

Committed to mainline.

Andrew

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_vectorize_preferred_simd_mode): Prefer V32 on
	RDNA devices.
---
 gcc/config/gcn/gcn.cc | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 498146dcde9..efb73af50c4 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -5226,6 +5226,32 @@ gcn_vector_mode_supported_p (machine_mode mode)
 static machine_mode
 gcn_vectorize_preferred_simd_mode (scalar_mode mode)
 {
+  /* RDNA devices have 32-lane vectors with limited support for 64-bit vectors
+     (in particular, permute operations are only available for cases that don't
+     span the 32-lane boundary).
+
+     From the RDNA3 manual: "Hardware may choose to skip either half if the
+     EXEC mask for that half is all zeros...". This means that preferring
+     32-lanes is a good stop-gap until we have proper wave32 support.  */
+  if (TARGET_RDNA2_PLUS)
+    switch (mode)
+      {
+      case E_QImode:
+	return V32QImode;
+      case E_HImode:
+	return V32HImode;
+      case E_SImode:
+	return V32SImode;
+      case E_DImode:
+	return V32DImode;
+      case E_SFmode:
+	return V32SFmode;
+      case E_DFmode:
+	return V32DFmode;
+      default:
+	return word_mode;
+      }
+
   switch (mode)
     {
     case E_QImode:
-- 
2.41.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-04-12  8:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 15:54 [committed] amdgcn: Prefer V32 on RDNA devices Andrew Stubbs
2024-03-28  7:00 ` Thomas Schwinge
2024-04-08 10:45   ` GCN: '--param=gcn-preferred-vector-lane-width=[default,32,64]' (was: [committed] amdgcn: Prefer V32 on RDNA devices) Thomas Schwinge
2024-04-08 12:24     ` GCN: '--param=gcn-preferred-vector-lane-width=[default,32,64]' Andrew Stubbs
2024-04-08 20:17       ` GCN: '--param=gcn-preferred-vectorization-factor=[default,32,64]' (was: GCN: '--param=gcn-preferred-vector-lane-width=[default,32,64]') Thomas Schwinge
2024-04-11 17:52         ` [PATCH] contrib/check-params-in-docs.py: Ignore gcn-preferred-vectorization-factor Martin Jambor
2024-04-11 18:51           ` Thomas Schwinge
2024-04-12  7:08             ` [PATCH] contrib/check-params-in-docs.py: Ignore target-specific params Filip Kastl
2024-04-12  7:40               ` Thomas Schwinge
2024-04-12  8:39               ` Martin Jambor

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).