diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2022-11-02 09:06:28 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2022-11-02 09:06:28 +0100 |
commit | cb934e37962eeccc8641982b9a9855408979c767 (patch) | |
tree | 875ec2ac36afb458fa463e312dedf9f18df92522 /gcc | |
parent | 488d2df2148900259c3f865740ea0abfee39bc5a (diff) | |
download | gcc-cb934e37962eeccc8641982b9a9855408979c767.zip gcc-cb934e37962eeccc8641982b9a9855408979c767.tar.gz gcc-cb934e37962eeccc8641982b9a9855408979c767.tar.bz2 |
OpenMP/Fortran: 'target update' with strides + DT components
OpenMP 5.0 permits to use arrays with strides and derived
type components for the list items to the 'from'/'to' clauses
of the 'target update' directive.
Submitted to mainline (but pending review):
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604687.html
gcc/fortran/ChangeLog:
* openmp.cc (gfc_match_omp_clauses): Permit derived types.
(resolve_omp_clauses):Accept noncontiguous
arrays.
* trans-openmp.cc (gfc_trans_omp_clauses): Fixes for
derived-type changes; fix size for scalars.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/target-11.f90: New test.
* testsuite/libgomp.fortran/target-13.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog.omp | 8 | ||||
-rw-r--r-- | gcc/fortran/openmp.cc | 19 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.cc | 9 |
3 files changed, 27 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 7504a83..0e06ffb 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,11 @@ +2022-11-02 Tobias Burnus <tobias@codesourcery.com> + + * openmp.cc (gfc_match_omp_clauses): Permit derived types. + (resolve_omp_clauses):Accept noncontiguous + arrays. + * trans-openmp.cc (gfc_trans_omp_clauses): Fixes for + derived-type changes; fix size for scalars. + 2022-10-27 Marcel Vollweiler <marcel@codesourcery.com> * openmp.cc (oacc_is_parallel): Remove. diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index ed21f52..52ffb2c 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -3046,9 +3046,10 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, true) == MATCH_YES) continue; if ((mask & OMP_CLAUSE_FROM) - && gfc_match_omp_variable_list ("from (", + && (gfc_match_omp_variable_list ("from (", &c->lists[OMP_LIST_FROM], false, - NULL, &head, true) == MATCH_YES) + NULL, &head, true, true) + == MATCH_YES)) continue; break; case 'g': @@ -3983,9 +3984,10 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, continue; } else if ((mask & OMP_CLAUSE_TO) - && gfc_match_omp_variable_list ("to (", + && (gfc_match_omp_variable_list ("to (", &c->lists[OMP_LIST_TO], false, - NULL, &head, true) == MATCH_YES) + NULL, &head, true, true) + == MATCH_YES)) continue; break; case 'u': @@ -8376,8 +8378,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, Only raise an error here if we're really sure the array isn't contiguous. An expression such as arr(-n:n,-n:n) could be contiguous even if it looks - like it may not be. */ + like it may not be. + And OpenMP's 'target update' permits strides for + the to/from clause. */ if (code->op != EXEC_OACC_UPDATE + && code->op != EXEC_OMP_TARGET_UPDATE && list != OMP_LIST_CACHE && list != OMP_LIST_DEPEND && !gfc_is_simply_contiguous (n->expr, false, true) @@ -8421,7 +8426,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, int i; gfc_array_ref *ar = &lastslice->u.ar; for (i = 0; i < ar->dimen; i++) - if (ar->stride[i] && code->op != EXEC_OACC_UPDATE) + if (ar->stride[i] + && code->op != EXEC_OACC_UPDATE + && code->op != EXEC_OMP_TARGET_UPDATE) { gfc_error ("Stride should not be specified for " "array section in %s clause at %L", diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 712e372..255c676 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -5126,7 +5126,10 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, gcc_unreachable (); } tree node = build_omp_clause (input_location, clause_code); - if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL) + if (n->expr == NULL + || (n->expr->ref->type == REF_ARRAY + && n->expr->ref->u.ar.type == AR_FULL + && n->expr->ref->next == NULL)) { tree decl = gfc_trans_omp_variable (n->sym, false); if (gfc_omp_privatize_by_reference (decl)) @@ -5166,13 +5169,13 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, { tree ptr; gfc_init_se (&se, NULL); - if (n->expr->ref->u.ar.type == AR_ELEMENT) + if (n->expr->rank == 0) { gfc_conv_expr_reference (&se, n->expr); ptr = se.expr; gfc_add_block_to_block (block, &se.pre); OMP_CLAUSE_SIZE (node) - = TYPE_SIZE_UNIT (TREE_TYPE (ptr)); + = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ptr))); } else { |