public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-986] [OpenACC privatization] Explain OpenACC privatization candidate selection [PR90115] Date: Fri, 21 May 2021 18:54:55 +0000 (GMT) [thread overview] Message-ID: <20210521185455.500533AA8CB5@sourceware.org> (raw) https://gcc.gnu.org/g:5a0fe1f6c4ad0e50bf4684e723ae2ba17d94c9e4 commit r12-986-g5a0fe1f6c4ad0e50bf4684e723ae2ba17d94c9e4 Author: Thomas Schwinge <thomas@codesourcery.com> Date: Thu May 20 15:55:18 2021 +0200 [OpenACC privatization] Explain OpenACC privatization candidate selection [PR90115] gcc/ PR middle-end/90115 * omp-low.c (oacc_privatization_candidate_p): New function. (oacc_privatization_scan_clause_chain) (oacc_privatization_scan_decl_chain): Use it. Also 'gcc_checking_assert' that we're not seeing duplicates. Diff: --- gcc/omp-low.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a86c6c1e82c..577676b2a16 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -10144,6 +10144,36 @@ lower_omp_for_lastprivate (struct omp_for_data *fd, gimple_seq *body_p, } } +/* OpenACC privatization. + + Or, in other words, *sharing* at the respective OpenACC level of + parallelism. + + From a correctness perspective, a non-addressable variable can't be accessed + outside the current thread, so it can go in a (faster than shared memory) + register -- though that register may need to be broadcast in some + circumstances. A variable can only meaningfully be "shared" across workers + or vector lanes if its address is taken, e.g. by a call to an atomic + builtin. + + From an optimisation perspective, the answer might be fuzzier: maybe + sometimes, using shared memory directly would be faster than + broadcasting. */ + +static bool +oacc_privatization_candidate_p (const tree decl) +{ + bool res = true; + + if (res && !VAR_P (decl)) + res = false; + + if (res && !TREE_ADDRESSABLE (decl)) + res = false; + + return res; +} + /* Scan CLAUSES for candidates for adjusting OpenACC privatization level in CTX. */ @@ -10154,8 +10184,12 @@ oacc_privatization_scan_clause_chain (omp_context *ctx, tree clauses) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE) { tree decl = OMP_CLAUSE_DECL (c); - if (VAR_P (decl) && TREE_ADDRESSABLE (decl)) - ctx->oacc_privatization_candidates.safe_push (decl); + + if (!oacc_privatization_candidate_p (decl)) + continue; + + gcc_checking_assert (!ctx->oacc_privatization_candidates.contains (decl)); + ctx->oacc_privatization_candidates.safe_push (decl); } } @@ -10166,8 +10200,13 @@ static void oacc_privatization_scan_decl_chain (omp_context *ctx, tree decls) { for (tree decl = decls; decl; decl = DECL_CHAIN (decl)) - if (VAR_P (decl) && TREE_ADDRESSABLE (decl)) + { + if (!oacc_privatization_candidate_p (decl)) + continue; + + gcc_checking_assert (!ctx->oacc_privatization_candidates.contains (decl)); ctx->oacc_privatization_candidates.safe_push (decl); + } } /* Callback for walk_gimple_seq. Find #pragma omp scan statement. */
reply other threads:[~2021-05-21 18:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210521185455.500533AA8CB5@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).