On Wed, Jan 18, 2017 at 05:52:49PM +0300, Alexander Monakov wrote:
> On Wed, 18 Jan 2017, Jakub Jelinek wrote:
> > Can't it be e.g. recorded inside a flag on the VAR_DECLs or magic attributes
> > on them during omplower time and then only finalized into the magic .local
> > alloca in the pass_omp_device_lower pass?
> 
> No (see my adjacent response): it can't be a variable flag because one 
> variable
> can be private to one SIMD region but not others, and even if we make private
> instances be separate variables, we need to be sure the compiler can't move
> references to them outside of their SIMT_ENTER/EXIT SESE region.

If it is a privatized variable in the SIMD region, then it should be used
only in a single SIMD region and nowhere else (I bet it can appear in the
initialization or finalization code before/after a SIMD loop), the original
VAR_DECL/PARM_DECL is replaced during omp lowering with a new VAR_DECL.  And
this happens for each SIMD loop separately.  So, if you attach the flag or
attribute to the replacement VAR_DECL (created through omp_copy_decl_{1,2},
install_var_local etc.), rather than the original one, I don't see why it
wouldn't work.

> > The inliner would need to be able to add those flags or magic attributes 
> > also
> > when duplicating vars/parameters from inline functions into the SIMT region
> > (perhaps some flag on GIMPLE_CALL stmts, or on bbs in the simt region, or
> > something similar could turn that behavior on in the inliner)?
> 
> In patch 2/5 I've used loop properties for that (works nicely since loops are
> persistent), but it's not perfect because SIMT regions are not really loops:
> it's a combination of original SIMD loop, plus helper reduction loop, plus
> lastprivate copying, plus calls to C++ constructors for private objects on
> entry.  But that's the best approach I see at the moment.

        Jakub

Reply via email to