From: Julian Brown <julian@codesourcery.com>
To: Chung-Lin Tang <cltang@pllab.cs.nthu.edu.tw>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
Thomas Schwinge <thomas@codesourcery.com>,
Andrew Stubbs <ams@codesourcery.com>,
"Catherine Moore" <clm@codesourcery.com>
Subject: Re: [PATCH, OpenACC 2.7] Implement reductions for arrays and structs
Date: Wed, 10 Jan 2024 11:33:16 +0000 [thread overview]
Message-ID: <20240110113316.4ae809bf@squid.athome> (raw)
In-Reply-To: <1ee7eb45-6bf1-40e5-9aec-48f2a8d28196@pllab.cs.nthu.edu.tw>
On Tue, 2 Jan 2024 23:21:21 +0800
Chung-Lin Tang <cltang@pllab.cs.nthu.edu.tw> wrote:
> To Julian, there is a patch to the middle-end neutering, a hack
> actually, that detects SSA_NAMEs used in reduction array MEM_REFs,
> and avoids single->parallel copying (by moving those definitions
> before BUILT_IN_GOACC_SINGLE_COPY_START). This appears to work
> because reductions do their own initializing of the private copy.
It looks OK to me I think (bearing in mind your following paragraph, of
course!). I wonder though if maybe non-SSA (i.e. addressable) variables
need to be handled also, i.e. parts like this:
+ /* For accesses of variables used in array reductions, instead of
+ propagating the value for the main thread to all other worker threads
+ (which doesn't make sense as a reduction private var), move the defs
+ of such SSA_NAMEs to before the copy block and leave them alone (each
+ thread should access their own local copy). */
+ for (gimple_stmt_iterator i = gsi_after_labels (from); !gsi_end_p (i);)
+ {
+ gimple *stmt = gsi_stmt (i);
+ if (gimple_assign_single_p (stmt)
+ && def_escapes_block->contains (gimple_assign_lhs (stmt))
+ && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
are only handling SSA-converted variables. But maybe that's OK?
> As we discussed in our internal calls, the real proper way is to
> create the private array in a more appropriate stage, but that is too
> long a shot for now. The changes here are needed at least for some
> -O0 cases (when under optimization, propagation of the private
> copies' local address eliminate the SSA_NAME and things actually just
> work in that case). So please bear with this hack.
HTH,
Julian
next prev parent reply other threads:[~2024-01-10 11:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-02 15:21 Chung-Lin Tang
2024-01-10 11:33 ` Julian Brown [this message]
2024-02-08 14:47 ` [PATCH, OpenACC 2.7] struct/array reductions for Fortran Chung-Lin Tang
2024-03-13 18:59 ` Tobias Burnus
2024-03-18 16:39 ` Thomas Schwinge
2024-03-13 17:05 ` [PATCH, OpenACC 2.7] Implement reductions for arrays and structs Tobias Burnus
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=20240110113316.4ae809bf@squid.athome \
--to=julian@codesourcery.com \
--cc=ams@codesourcery.com \
--cc=clm@codesourcery.com \
--cc=cltang@pllab.cs.nthu.edu.tw \
--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).