diff options
author | Marcel Vollweiler <marcel@codesourcery.com> | 2021-08-31 06:09:40 -0700 |
---|---|---|
committer | Marcel Vollweiler <marcel@codesourcery.com> | 2021-08-31 06:19:31 -0700 |
commit | 03be3cfeef7b3811acb6c4a8da2fc5c1e25d3e4c (patch) | |
tree | 6ccba78c726f6621e6851caf061f944bc7b5c9d3 /gcc/omp-low.c | |
parent | 69b09c5599b201ac039db564c303f7b20d87e0df (diff) | |
download | gcc-03be3cfeef7b3811acb6c4a8da2fc5c1e25d3e4c.zip gcc-03be3cfeef7b3811acb6c4a8da2fc5c1e25d3e4c.tar.gz gcc-03be3cfeef7b3811acb6c4a8da2fc5c1e25d3e4c.tar.bz2 |
Add support for device-modifiers for 'omp target device'.
'device_num' and 'ancestor' are now parsed on target device constructs for C,
C++, and Fortran (see OpenMP specification 5.0, p. 170). When 'ancestor' is
used, then 'sorry, not supported' is output. Moreover, the restrictions for
'ancestor' are implemented (see OpenMP specification 5.0, p. 174f).
gcc/c/ChangeLog:
* c-parser.c (c_parser_omp_clause_device): Parse device-modifiers 'device_num'
and 'ancestor' in 'target device' clauses.
gcc/cp/ChangeLog:
* parser.c (cp_parser_omp_clause_device): Parse device-modifiers 'device_num'
and 'ancestor' in 'target device' clauses.
* semantics.c (finish_omp_clauses): Error handling. Constant device ids must
evaluate to '1' if 'ancestor' is used.
gcc/fortran/ChangeLog:
* gfortran.h: Add variable for 'ancestor' in struct gfc_omp_clauses.
* openmp.c (gfc_match_omp_clauses): Parse device-modifiers 'device_num'
and 'ancestor' in 'target device' clauses.
* trans-openmp.c (gfc_trans_omp_clauses): Set OMP_CLAUSE_DEVICE_ANCESTOR.
gcc/ChangeLog:
* gimplify.c (gimplify_scan_omp_clauses): Error handling. 'ancestor' only
allowed on target constructs and only with particular other clauses.
* omp-expand.c (expand_omp_target): Output of 'sorry, not supported' if
'ancestor' is used.
* omp-low.c (check_omp_nesting_restrictions): Error handling. No nested OpenMP
structs when 'ancestor' is used.
(scan_omp_1_stmt): No usage of OpenMP runtime routines in a target region when
'ancestor' is used.
* tree-pretty-print.c (dump_omp_clause): Append 'ancestor'.
* tree.h (OMP_CLAUSE_DEVICE_ANCESTOR): Define macro.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/target-device-1.c: New test.
* c-c++-common/gomp/target-device-2.c: New test.
* c-c++-common/gomp/target-device-ancestor-1.c: New test.
* c-c++-common/gomp/target-device-ancestor-2.c: New test.
* c-c++-common/gomp/target-device-ancestor-3.c: New test.
* c-c++-common/gomp/target-device-ancestor-4.c: New test.
* gfortran.dg/gomp/target-device-1.f90: New test.
* gfortran.dg/gomp/target-device-2.f90: New test.
* gfortran.dg/gomp/target-device-ancestor-1.f90: New test.
* gfortran.dg/gomp/target-device-ancestor-2.f90: New test.
* gfortran.dg/gomp/target-device-ancestor-3.f90: New test.
* gfortran.dg/gomp/target-device-ancestor-4.f90: New test.
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a0b41af..6686946 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -3114,6 +3114,16 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) if (gimple_code (ctx->stmt) == GIMPLE_OMP_TARGET && gimple_omp_target_kind (ctx->stmt) == GF_OMP_TARGET_KIND_REGION) { + c = omp_find_clause (gimple_omp_target_clauses (ctx->stmt), + OMP_CLAUSE_DEVICE); + if (c && OMP_CLAUSE_DEVICE_ANCESTOR (c)) + { + error_at (gimple_location (stmt), + "OpenMP constructs are not allowed in target region " + "with %<ancestor%>"); + return false; + } + if (gimple_code (stmt) == GIMPLE_OMP_TEAMS && !ctx->teams_nested_p) ctx->teams_nested_p = true; else @@ -4063,6 +4073,17 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, "OpenMP runtime API call %qD in a region with " "%<order(concurrent)%> clause", fndecl); } + if (gimple_code (ctx->stmt) == GIMPLE_OMP_TARGET + && (gimple_omp_target_kind (ctx->stmt) + == GF_OMP_TARGET_KIND_REGION)) + { + tree tgt_clauses = gimple_omp_target_clauses (ctx->stmt); + tree c = omp_find_clause (tgt_clauses, OMP_CLAUSE_DEVICE); + if (c && OMP_CLAUSE_DEVICE_ANCESTOR (c)) + error_at (gimple_location (stmt), + "OpenMP runtime API call %qD in a region with " + "%<device(ancestor)%> clause", fndecl); + } } } } |