public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Cesar Philippidis <cesar@codesourcery.com>
To: Tom de Vries <Tom_deVries@mentor.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Thomas Schwinge	<thomas@codesourcery.com>
Subject: Re: [og7] vector_length extension part 2: Generalize state propagation and synchronization
Date: Thu, 22 Mar 2018 15:18:00 -0000	[thread overview]
Message-ID: <7cc5faf7-255d-523d-144f-a5a3439ce25b@codesourcery.com> (raw)
In-Reply-To: <0e1729fb-fd98-1f37-8de9-0a11e2aa9c7a@mentor.com>

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

On 03/22/2018 07:23 AM, Tom de Vries wrote:
> On 03/02/2018 05:55 PM, Cesar Philippidis wrote:
> 
>>     (nvptx_declare_function_name): Emit a .maxntid directive hint and
>>     call nvptx_init_oacc_workers.
> 
>> +
>> +  /* Emit a .maxntid hint to help the PTX JIT emit SYNC branches.  */
>> +  if (lookup_attribute ("omp target entrypoint", DECL_ATTRIBUTES (decl))
>> +      && lookup_attribute ("oacc function", DECL_ATTRIBUTES (decl)))
>> +      s << ".maxntid " << cfun->machine->axis_dim[0] << ", "
>> +    << cfun->machine->axis_dim[1] << ", 1\n";
>> +
> 
> This change:
> ...
>  // BEGIN FUNCTION DEF: main$_omp_fn$0
>  .entry main$_omp_fn$0 (.param .u64 %in_ar0)
> +  .maxntid 32, 32, 1
> ...
> needs to be an individual patch.

cfun->machine->axis_dims is something new to the vector length changes,
so I hard-coded .maxntid to size '32, 32, 1' for og7 as an interim solution.

>> +  /* Emit a .maxntid hint to help the PTX JIT emit SYNC branches.  */
> 
> 'Help' is too strongly formulated, given that there's no clear link
> between the semantics of the directive, and the observed effect.
> 
> Use "seems to have the effect" or some such formulation.
> 
> Also, list in the comment a JIT driver version, and sm_ version and a
> testcase for which this is required.
> 
> Also, guard it with WORKAROUND_PTXJIT_BUG_3 (_2 is already taken in trunk.)

Sounds reasonable. I'll commit the patch to og7 once the regression
testing has completed.

Thanks,
Cesar

[-- Attachment #2: 0001-add-.maxntid-hint.patch --]
[-- Type: text/x-patch, Size: 1289 bytes --]

From b89ec8060de3affb94b580be3260381028d4c183 Mon Sep 17 00:00:00 2001
From: Cesar Philippidis <cesar@codesourcery.com>
Date: Thu, 22 Mar 2018 08:05:53 -0700
Subject: [PATCH] add .maxntid hint

---
 gcc/config/nvptx/nvptx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index eff87732c4b..9fb2bcd6852 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -76,6 +76,7 @@
 #include "target-def.h"
 
 #define WORKAROUND_PTXJIT_BUG 1
+#define WORKAROUND_PTXJIT_BUG_3 1
 
 /* Define dimension sizes for known hardware.  */
 #define PTX_VECTOR_LENGTH 32
@@ -1219,6 +1220,15 @@ nvptx_declare_function_name (FILE *file, const char *name, const_tree decl)
      stream, in order to share the prototype writing code.  */
   std::stringstream s;
   write_fn_proto (s, true, name, decl);
+
+#if WORKAROUND_PTXJIT_BUG_3
+  /* Emitting a .maxntid seems to have the effect of encouraging the
+     PTX JIT emit SYNC branches.  */
+  if (lookup_attribute ("omp target entrypoint", DECL_ATTRIBUTES (decl))
+      && lookup_attribute ("oacc function", DECL_ATTRIBUTES (decl)))
+      s << ".maxntid 32, 32, 1\n";
+#endif
+
   s << "{\n";
 
   bool return_in_mem = write_return_type (s, false, result_type);
-- 
2.14.3


  reply	other threads:[~2018-03-22 15:11 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 21:17 [og7] vector_length extension part 1: generalize function and variable names Cesar Philippidis
2018-03-02 16:55 ` [og7] vector_length extension part 2: Generalize state propagation and synchronization Cesar Philippidis
2018-03-21 17:16   ` Tom de Vries
2018-03-22  8:05     ` Cesar Philippidis
2018-03-22 14:16       ` Tom de Vries
2018-03-22 14:35         ` Cesar Philippidis
2018-03-22 14:24   ` Tom de Vries
2018-03-22 15:18     ` Cesar Philippidis [this message]
2018-03-22 16:20       ` Tom de Vries
2018-03-22 17:26         ` Cesar Philippidis
2018-03-22 17:58           ` Tom de Vries
2018-03-22 19:32             ` Cesar Philippidis
2018-03-23  8:56               ` Tom de Vries
2018-03-23 14:35           ` Tom de Vries
2018-03-22 15:04   ` Tom de Vries
2018-03-22 17:14     ` Cesar Philippidis
2018-03-22 17:47   ` Tom de Vries
2018-03-22 17:48     ` Cesar Philippidis
2018-03-22 18:00       ` Tom de Vries
2018-03-23 13:14   ` Tom de Vries
2018-03-23 13:16   ` Tom de Vries
2018-03-23 14:18   ` Tom de Vries
2018-03-23 16:30   ` Tom de Vries
2018-03-30  1:50   ` Tom de Vries
2018-03-30 14:48     ` Tom de Vries
2018-03-30 15:06       ` Cesar Philippidis
2018-03-30 15:35         ` Tom de Vries
2018-04-05 16:33           ` Tom de Vries
2018-04-03 14:52   ` [nvptx] Use MAX, MIN, ROUND_UP macros Tom de Vries
2018-04-03 15:00   ` [og7] vector_length extension part 2: Generalize state propagation and synchronization Tom de Vries
2018-04-05 14:06     ` Tom de Vries
2018-04-05 14:14     ` Tom de Vries
2018-03-02 17:51 ` [og7] vector_length extension part 3: reductions Cesar Philippidis
2018-04-05 14:07   ` Tom de Vries
2018-04-05 16:26   ` Tom de Vries
2018-03-02 19:18 ` [og7] vector_length extension part 4: target hooks and automatic parallelism Cesar Philippidis
2018-03-21 15:55   ` Tom de Vries
2018-03-21 20:28     ` Cesar Philippidis
2018-03-26 14:25   ` Tom de Vries
2018-03-26 14:37     ` Cesar Philippidis
2018-03-26 16:52   ` Tom de Vries
2018-03-27 12:16     ` Tom de Vries
2018-03-26 17:13   ` Tom de Vries
2018-04-05 16:32   ` Tom de Vries
2018-03-02 20:47 ` [og7] vector_length extension part 5: libgomp and tests Cesar Philippidis
2018-03-16 13:50   ` Thomas Schwinge
2018-03-27 13:00   ` Tom de Vries
2018-04-05 16:36   ` Tom de Vries
2018-03-09 15:29 ` [og7] vector_length extension part 1: generalize function and variable names Thomas Schwinge
2018-03-09 15:31   ` Cesar Philippidis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cc5faf7-255d-523d-144f-a5a3439ce25b@codesourcery.com \
    --to=cesar@codesourcery.com \
    --cc=Tom_deVries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=thomas@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).