diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2023-12-11 15:19:02 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2023-12-11 15:19:02 +0100 |
commit | 055f08feee3424a29403047a7049af467f2b26cd (patch) | |
tree | 417064b8af148bf8f49dd344cfe78a5829e17028 /gcc/c | |
parent | 2505a8b41d3b74a545755a278f3750a29c1340b6 (diff) | |
download | gcc-055f08feee3424a29403047a7049af467f2b26cd.zip gcc-055f08feee3424a29403047a7049af467f2b26cd.tar.gz gcc-055f08feee3424a29403047a7049af467f2b26cd.tar.bz2 |
OpenMP: Support acquires/release in 'omp require atomic_default_mem_order'
This is an OpenMP 5.2 feature.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_requires): Handle acquires/release
in atomic_default_mem_order clause.
(c_parser_omp_atomic): Update.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_requires): Handle acquires/release
in atomic_default_mem_order clause.
(cp_parser_omp_atomic): Update.
gcc/fortran/ChangeLog:
* gfortran.h (enum gfc_omp_requires_kind): Add
OMP_REQ_ATOMIC_MEM_ORDER_ACQUIRE and OMP_REQ_ATOMIC_MEM_ORDER_RELEASE.
(gfc_namespace): Add a 7th bit to omp_requires.
* module.cc (enum ab_attribute): Add AB_OMP_REQ_MEM_ORDER_ACQUIRE
and AB_OMP_REQ_MEM_ORDER_RELEASE
(mio_symbol_attribute): Handle it.
* openmp.cc (gfc_omp_requires_add_clause): Update for acquire/release.
(gfc_match_omp_requires): Likewise.
(gfc_match_omp_atomic): Handle them for atomic_default_mem_order.
* parse.cc: Likewise.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/requires-3.c: Update for now valid code.
* gfortran.dg/gomp/requires-3.f90: Likewise.
* gfortran.dg/gomp/requires-2.f90: Update dg-error.
* gfortran.dg/gomp/requires-5.f90: Likewise.
* c-c++-common/gomp/requires-5.c: New test.
* c-c++-common/gomp/requires-6.c: New test.
* c-c++-common/gomp/requires-7.c: New test.
* c-c++-common/gomp/requires-8.c: New test.
* gfortran.dg/gomp/requires-10.f90: New test.
* gfortran.dg/gomp/requires-11.f90: New test.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-parser.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index df9a079..5700ccc 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -20896,6 +20896,28 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc) case OMP_MEMORY_ORDER_SEQ_CST: memory_order = OMP_MEMORY_ORDER_SEQ_CST; break; + case OMP_MEMORY_ORDER_ACQUIRE: + if (code == NOP_EXPR) /* atomic write */ + { + error_at (loc, "%<#pragma omp atomic write%> incompatible with " + "%<acquire%> clause implicitly provided by a " + "%<requires%> directive"); + memory_order = OMP_MEMORY_ORDER_SEQ_CST; + } + else + memory_order = OMP_MEMORY_ORDER_ACQUIRE; + break; + case OMP_MEMORY_ORDER_RELEASE: + if (code == OMP_ATOMIC_READ) + { + error_at (loc, "%<#pragma omp atomic read%> incompatible with " + "%<release%> clause implicitly provided by a " + "%<requires%> directive"); + memory_order = OMP_MEMORY_ORDER_SEQ_CST; + } + else + memory_order = OMP_MEMORY_ORDER_RELEASE; + break; case OMP_MEMORY_ORDER_ACQ_REL: switch (code) { @@ -25724,15 +25746,21 @@ c_parser_omp_requires (c_parser *parser) else if (!strcmp (p, "relaxed")) this_req = (enum omp_requires) OMP_MEMORY_ORDER_RELAXED; + else if (!strcmp (p, "release")) + this_req + = (enum omp_requires) OMP_MEMORY_ORDER_RELEASE; else if (!strcmp (p, "acq_rel")) this_req = (enum omp_requires) OMP_MEMORY_ORDER_ACQ_REL; + else if (!strcmp (p, "acquire")) + this_req + = (enum omp_requires) OMP_MEMORY_ORDER_ACQUIRE; } if (this_req == 0) { error_at (c_parser_peek_token (parser)->location, - "expected %<seq_cst%>, %<relaxed%> or " - "%<acq_rel%>"); + "expected %<acq_rel%>, %<acquire%>, " + "%<relaxed%>, %<release%> or %<seq_cst%>"); switch (c_parser_peek_token (parser)->type) { case CPP_EOF: |