public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9399] openmp: -fopenmp-simd fixes [PR98187] Date: Tue, 20 Apr 2021 23:30:37 +0000 (GMT) [thread overview] Message-ID: <20210420233037.3DE513AA7C9C@sourceware.org> (raw) https://gcc.gnu.org/g:22b900e2db91095414832a83ae5761e689c676e7 commit r9-9399-g22b900e2db91095414832a83ae5761e689c676e7 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Dec 8 10:45:30 2020 +0100 openmp: -fopenmp-simd fixes [PR98187] This patch fixes two bugs in the -fopenmp-simd support. One is that in C++ #pragma omp parallel master would actually create OMP_PARALLEL in the IL, which is a big no-no for -fopenmp-simd, we should be creating only the constructs -fopenmp-simd handles (mainly OMP_SIMD, OMP_LOOP which is gimplified as simd in that case, declare simd/reduction and ordered simd). The other bug was that #pragma omp master taskloop simd combined construct contains simd and thus should be recognized as #pragma omp simd (with only the simd applicable clauses), but as master wasn't included in omp_pragmas_simd, we'd ignore it completely instead. 2020-12-08 Jakub Jelinek <jakub@redhat.com> PR c++/98187 * c-pragma.c (omp_pragmas): Remove "master". (omp_pragmas_simd): Add "master". * parser.c (cp_parser_omp_parallel): For parallel master with -fopenmp-simd only, just call cp_parser_omp_master instead of wrapping it in OMP_PARALLEL. * c-c++-common/gomp/pr98187.c: New test. (cherry picked from commit e315ba968d2a47643a9487ea48d62e6399a07d49) Diff: --- gcc/c-family/c-pragma.c | 2 +- gcc/cp/parser.c | 3 + gcc/testsuite/c-c++-common/gomp/pr98187.c | 97 +++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index fbc734a047b..9cb77fcbb3d 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1289,7 +1289,6 @@ static const struct omp_pragma_def omp_pragmas[] = { { "depobj", PRAGMA_OMP_DEPOBJ }, { "end", PRAGMA_OMP_END_DECLARE_TARGET }, { "flush", PRAGMA_OMP_FLUSH }, - { "master", PRAGMA_OMP_MASTER }, { "requires", PRAGMA_OMP_REQUIRES }, { "section", PRAGMA_OMP_SECTION }, { "sections", PRAGMA_OMP_SECTIONS }, @@ -1304,6 +1303,7 @@ static const struct omp_pragma_def omp_pragmas_simd[] = { { "declare", PRAGMA_OMP_DECLARE }, { "distribute", PRAGMA_OMP_DISTRIBUTE }, { "for", PRAGMA_OMP_FOR }, + { "master", PRAGMA_OMP_MASTER }, { "ordered", PRAGMA_OMP_ORDERED }, { "parallel", PRAGMA_OMP_PARALLEL }, { "simd", PRAGMA_OMP_SIMD }, diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7fda6bb99ba..96151a70a7f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -37836,6 +37836,9 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, cclauses = cclauses_buf; cp_lexer_consume_token (parser->lexer); + if (!flag_openmp) /* flag_openmp_simd */ + return cp_parser_omp_master (parser, pragma_tok, p_name, mask, + cclauses, if_p); block = begin_omp_parallel (); save = cp_parser_begin_omp_structured_block (parser); tree ret = cp_parser_omp_master (parser, pragma_tok, p_name, mask, diff --git a/gcc/testsuite/c-c++-common/gomp/pr98187.c b/gcc/testsuite/c-c++-common/gomp/pr98187.c new file mode 100644 index 00000000000..c273d39843d --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr98187.c @@ -0,0 +1,97 @@ +/* PR c++/98187 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp-simd -O2 -fdump-tree-gimple" } */ +/* { dg-final { scan-tree-dump-times "#pragma omp simd" 13 "gimple" } } */ + +void +foo (int *p) +{ + int i; + #pragma omp distribute parallel for + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp distribute parallel for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp distribute simd + for (i = 0; i < 64; i++) + p[i]++; +} + +void +bar (int *p) +{ + int i; + #pragma omp for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp master taskloop + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp master taskloop simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp parallel for + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp parallel for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp parallel master + p[0]++; + #pragma omp parallel master taskloop + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp parallel master taskloop simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp parallel sections + { + p[0]++; + #pragma omp section + p[1]++; + #pragma omp section + p[2]++; + } + #pragma omp target parallel + #pragma omp master + p[0]++; + #pragma omp target parallel for + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target parallel for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target teams private (i) + i = 0; + #pragma omp target teams distribute + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target teams distribute parallel for + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target teams distribute parallel for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target teams distribute simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp target simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp taskloop simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp teams distribute + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp teams distribute parallel for + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp teams distribute parallel for simd + for (i = 0; i < 64; i++) + p[i]++; + #pragma omp teams distribute simd + for (i = 0; i < 64; i++) + p[i]++; +}
reply other threads:[~2021-04-20 23:30 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=20210420233037.3DE513AA7C9C@sourceware.org \ --to=jakub@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).