diff mbox series

[committed,amdgcn] Use GFX9 granulated sgprs count correctly

Message ID b3bcfdd5-fff0-0b46-97f4-8fad25a74cc6@codesourcery.com
State New
Headers show
Series [committed,amdgcn] Use GFX9 granulated sgprs count correctly | expand

Commit Message

Andrew Stubbs Nov. 22, 2019, 2:47 p.m. UTC
I've committed the attached. The patch adjusts the GCN kernel metadata 
so that it is correct for GFX9 devices.

The existing implementation was correct for GFX8, and seems to work on 
GFX9, but wasn't technically correct.

Comments

Tobias Burnus Nov. 22, 2019, 2:56 p.m. UTC | #1
Hi Andrew,

On 11/22/19 3:47 PM, Andrew Stubbs wrote:
> --- a/gcc/config/gcn/gcn.c
> +++ b/gcc/config/gcn/gcn.c
> @@ -4922,6 +4922,14 @@ gcn_hsa_declare_function_name (FILE *file, const char *name, tree)
> +  int granulated_sgprs;
> +  if (TARGET_GCN3)
> +    granulated_sgprs = (sgpr + extra_regs + 7) / 8 - 1;
> +  else if (TARGET_GCN5)
> +    granulated_sgprs = 2 * ((sgpr + extra_regs + 15) / 16 - 1);

Would it make sense to add here:

else
   gcc_unreachable ();

(TARGET_GCN5_PLUS would also work, but gcc_unreachable is probably better.)

Cheers,

Tobias
diff mbox series

Patch

Use GFX9 granulated sgprs count correctly.

2019-11-22  Andrew Stubbs  <ams@codesourcery.com>

	gcc/
	* config/gcn/gcn.c (gcn_hsa_declare_function_name): Calculate
	granulated_sgprs according to architecture.

diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 4401896d441..b34e8e7f5e2 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -4922,6 +4922,14 @@  gcn_hsa_declare_function_name (FILE *file, const char *name, tree)
 	sgpr = MAX_NORMAL_SGPR_COUNT - extra_regs;
     }
 
+  /* GFX8 allocates SGPRs in blocks of 8.
+     GFX9 uses blocks of 16.  */
+  int granulated_sgprs;
+  if (TARGET_GCN3)
+    granulated_sgprs = (sgpr + extra_regs + 7) / 8 - 1;
+  else if (TARGET_GCN5)
+    granulated_sgprs = 2 * ((sgpr + extra_regs + 15) / 16 - 1);
+
   fputs ("\t.align\t256\n", file);
   fputs ("\t.type\t", file);
   assemble_name (file, name);
@@ -4960,7 +4968,7 @@  gcn_hsa_declare_function_name (FILE *file, const char *name, tree)
 	   "\t\tcompute_pgm_rsrc2_excp_en = 0\n",
 	   (vgpr - 1) / 4,
 	   /* Must match wavefront_sgpr_count */
-	   (sgpr + extra_regs + 7) / 8 - 1,
+	   granulated_sgprs,
 	   /* The total number of SGPR user data registers requested.  This
 	      number must match the number of user data registers enabled.  */
 	   cfun->machine->args.nsgprs);