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
>From b89ec8060de3affb94b580be3260381028d4c183 Mon Sep 17 00:00:00 2001 From: Cesar Philippidis <ce...@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