diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2021-08-12 15:48:28 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2021-08-12 15:49:49 +0200 |
commit | 432de08498142d2266c0fb05f2c555a7f1e10ddd (patch) | |
tree | eb534cfc1379a9d59255a6c31f38519aaba927b4 /gcc | |
parent | 2d7967a10c2f3b4652f77a1a2119ba03b3472266 (diff) | |
download | gcc-432de08498142d2266c0fb05f2c555a7f1e10ddd.zip gcc-432de08498142d2266c0fb05f2c555a7f1e10ddd.tar.gz gcc-432de08498142d2266c0fb05f2c555a7f1e10ddd.tar.bz2 |
OpenMP 5.1: Add proc-bind 'primary' support
In OpenMP 5.1 "master thread" was changed to "primary thread" and
the proc_bind clause and the OMP_PROC_BIND environment variable
now take 'primary' as argument as alias for 'master', while the
latter is deprecated.
This commit accepts 'primary' and adds the named constant
omp_proc_bind_primary and changes 'master thread' in the
documentation; however, given that not even OpenMP 5.0 is
fully supported, omp_display_env and the dumps currently
still output 'master' and there is no deprecation warning
when using the 'master' in the proc_bind clause.
gcc/c/ChangeLog:
* c-parser.c (c_parser_omp_clause_proc_bind): Accept
'primary' as alias for 'master'.
gcc/cp/ChangeLog:
* parser.c (cp_parser_omp_clause_proc_bind): Accept
'primary' as alias for 'master'.
gcc/fortran/ChangeLog:
* gfortran.h (gfc_omp_proc_bind_kind): Add OMP_PROC_BIND_PRIMARY.
* dump-parse-tree.c (show_omp_clauses): Add TODO comment to
change 'master' to 'primary' in proc_bind for OpenMP 5.1.
* intrinsic.texi (OMP_LIB): Mention OpenMP 5.1; add
omp_proc_bind_primary.
* openmp.c (gfc_match_omp_clauses): Accept
'primary' as alias for 'master'.
* trans-openmp.c (gfc_trans_omp_clauses): Handle
OMP_PROC_BIND_PRIMARY.
gcc/ChangeLog:
* tree-core.h (omp_clause_proc_bind_kind): Add
OMP_CLAUSE_PROC_BIND_PRIMARY.
* tree-pretty-print.c (dump_omp_clause): Add TODO comment to
change 'master' to 'primary' in proc_bind for OpenMP 5.1.
libgomp/ChangeLog:
* env.c (parse_bind_var): Accept 'primary' as alias for
'master'.
(omp_display_env): Add TODO comment to
change 'master' to 'primary' in proc_bind for OpenMP 5.1.
* libgomp.texi: Change 'master thread' to 'primary thread'
in line with OpenMP 5.1.
(omp_get_proc_bind): Add omp_proc_bind_primary and note that
omp_proc_bind_master is an alias of it.
(OMP_PROC_BIND): Mention 'PRIMARY'.
* omp.h.in (__GOMP_DEPRECATED_5_1): Define.
(omp_proc_bind_primary): Add.
(omp_proc_bind_master): Deprecate for OpenMP 5.1.
* omp_lib.f90.in (omp_proc_bind_primary): Add.
(omp_proc_bind_master): Deprecate for OpenMP 5.1.
* omp_lib.h.in (omp_proc_bind_primary): Add.
* testsuite/libgomp.c/affinity-1.c: Check that
'primary' works and is identical to 'master'.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/pr61486-2.c: Duplicate one proc_bind(master)
testcase and test proc_bind(primary) instead.
* gfortran.dg/gomp/affinity-1.f90: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/c-parser.c | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 7 | ||||
-rw-r--r-- | gcc/fortran/dump-parse-tree.c | 1 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 1 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.texi | 6 | ||||
-rw-r--r-- | gcc/fortran/openmp.c | 5 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/pr61486-2.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/affinity-1.f90 | 9 | ||||
-rw-r--r-- | gcc/tree-core.h | 1 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 2 |
11 files changed, 48 insertions, 7 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index d24bfdb..195c137 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -15959,7 +15959,8 @@ c_parser_omp_clause_dist_schedule (c_parser *parser, tree list) proc_bind ( proc-bind-kind ) proc-bind-kind: - master | close | spread */ + primary | master | close | spread + where OpenMP 5.1 added 'primary' and deprecated the alias 'master'. */ static tree c_parser_omp_clause_proc_bind (c_parser *parser, tree list) @@ -15975,7 +15976,9 @@ c_parser_omp_clause_proc_bind (c_parser *parser, tree list) if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); - if (strcmp ("master", p) == 0) + if (strcmp ("primary", p) == 0) + kind = OMP_CLAUSE_PROC_BIND_PRIMARY; + else if (strcmp ("master", p) == 0) kind = OMP_CLAUSE_PROC_BIND_MASTER; else if (strcmp ("close", p) == 0) kind = OMP_CLAUSE_PROC_BIND_CLOSE; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 74de529..b7fe4b4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -39020,7 +39020,8 @@ cp_parser_omp_clause_dist_schedule (cp_parser *parser, tree list, proc_bind ( proc-bind-kind ) proc-bind-kind: - master | close | spread */ + primary | master | close | spread + where OpenMP 5.1 added 'primary' and deprecated the alias 'master'. */ static tree cp_parser_omp_clause_proc_bind (cp_parser *parser, tree list, @@ -39037,7 +39038,9 @@ cp_parser_omp_clause_proc_bind (cp_parser *parser, tree list, tree id = cp_lexer_peek_token (parser->lexer)->u.value; const char *p = IDENTIFIER_POINTER (id); - if (strcmp ("master", p) == 0) + if (strcmp ("primary", p) == 0) + kind = OMP_CLAUSE_PROC_BIND_PRIMARY; + else if (strcmp ("master", p) == 0) kind = OMP_CLAUSE_PROC_BIND_MASTER; else if (strcmp ("close", p) == 0) kind = OMP_CLAUSE_PROC_BIND_CLOSE; diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c index 8e4a101..360abf1 100644 --- a/gcc/fortran/dump-parse-tree.c +++ b/gcc/fortran/dump-parse-tree.c @@ -1712,6 +1712,7 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses) const char *type; switch (omp_clauses->proc_bind) { + case OMP_PROC_BIND_PRIMARY: type = "PRIMARY"; break; case OMP_PROC_BIND_MASTER: type = "MASTER"; break; case OMP_PROC_BIND_SPREAD: type = "SPREAD"; break; case OMP_PROC_BIND_CLOSE: type = "CLOSE"; break; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 921aed9..8f75dd9 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -1362,6 +1362,7 @@ enum gfc_omp_default_sharing enum gfc_omp_proc_bind_kind { OMP_PROC_BIND_UNKNOWN, + OMP_PROC_BIND_PRIMARY, OMP_PROC_BIND_MASTER, OMP_PROC_BIND_SPREAD, OMP_PROC_BIND_CLOSE diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 8a92b86..1aacd33 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -15293,8 +15293,9 @@ with the following options: @code{-fno-unsafe-math-optimizations @section OpenMP Modules @code{OMP_LIB} and @code{OMP_LIB_KINDS} @table @asis @item @emph{Standard}: -OpenMP Application Program Interface v4.5 and -OpenMP Application Program Interface v5.0 (partially supported). +OpenMP Application Program Interface v4.5, +OpenMP Application Program Interface v5.0 (partially supported) and +OpenMP Application Program Interface v5.1 (partially supported). @end table The OpenMP Fortran runtime library routines are provided both in @@ -15357,6 +15358,7 @@ kind @code{omp_proc_bind_kind}: @table @asis @item @code{omp_proc_bind_false} @item @code{omp_proc_bind_true} +@item @code{omp_proc_bind_primary} @item @code{omp_proc_bind_master} @item @code{omp_proc_bind_close} @item @code{omp_proc_bind_spread} diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 520a435..ec55865 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2231,7 +2231,10 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask, if ((mask & OMP_CLAUSE_PROC_BIND) && c->proc_bind == OMP_PROC_BIND_UNKNOWN) { - if (gfc_match ("proc_bind ( master )") == MATCH_YES) + /* Primary is new and master is deprecated in OpenMP 5.1. */ + if (gfc_match ("proc_bind ( primary )") == MATCH_YES) + c->proc_bind = OMP_PROC_BIND_MASTER; + else if (gfc_match ("proc_bind ( master )") == MATCH_YES) c->proc_bind = OMP_PROC_BIND_MASTER; else if (gfc_match ("proc_bind ( spread )") == MATCH_YES) c->proc_bind = OMP_PROC_BIND_SPREAD; diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index ac3f5f3..3d3b35e 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -3865,6 +3865,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses, c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_PROC_BIND); switch (clauses->proc_bind) { + case OMP_PROC_BIND_PRIMARY: + OMP_CLAUSE_PROC_BIND_KIND (c) = OMP_CLAUSE_PROC_BIND_PRIMARY; + break; case OMP_PROC_BIND_MASTER: OMP_CLAUSE_PROC_BIND_KIND (c) = OMP_CLAUSE_PROC_BIND_MASTER; break; diff --git a/gcc/testsuite/c-c++-common/gomp/pr61486-2.c b/gcc/testsuite/c-c++-common/gomp/pr61486-2.c index 4a68023..c86fd91 100644 --- a/gcc/testsuite/c-c++-common/gomp/pr61486-2.c +++ b/gcc/testsuite/c-c++-common/gomp/pr61486-2.c @@ -216,6 +216,19 @@ test (int n, int o, int p, int q, int r, int s, int *pp) s = i * 10; } #pragma omp target device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2]) + #pragma omp teams distribute parallel for simd if (n != 6)default(shared) \ + private (p) firstprivate (q) shared (n) reduction (+: r) \ + thread_limit (n * 2) dist_schedule (static, 4) num_threads (n + 4) \ + proc_bind (primary) lastprivate (s) schedule (static, 8) \ + num_teams (n + 4) safelen(16) linear(i:1) aligned (pp:4) + for (i = 0; i < 10; i++) + { + r = r + 1; + p = q; + a[2+i] = p + q; + s = i * 10; + } + #pragma omp target device (n + 1) if (n != 6)map(from:n) map(alloc:a[2:o-2]) #pragma omp teams distribute simd default(shared) \ private (p) firstprivate (q) shared (n) reduction (+: r) \ thread_limit (n * 2) dist_schedule (static, 4) collapse (2) \ diff --git a/gcc/testsuite/gfortran.dg/gomp/affinity-1.f90 b/gcc/testsuite/gfortran.dg/gomp/affinity-1.f90 index b6e20b9..cb1543b 100644 --- a/gcc/testsuite/gfortran.dg/gomp/affinity-1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/affinity-1.f90 @@ -9,6 +9,15 @@ j = 8 end do !$omp end parallel do +!$omp parallel do default(none)proc_bind(primary)shared(a) + do i = 1, 10 + j = 4 + do j = 1, 10 + a(i, j) = i + j + end do + j = 8 + end do +!$omp end parallel do !$omp parallel proc_bind (close) !$omp parallel default(none) proc_bind (spread) firstprivate(a) private (i) do i = 1, 10 diff --git a/gcc/tree-core.h b/gcc/tree-core.h index bfab988..9a1aa9a 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1498,6 +1498,7 @@ enum omp_clause_proc_bind_kind /* Numbers should match omp_proc_bind_t enum in omp.h. */ OMP_CLAUSE_PROC_BIND_FALSE = 0, OMP_CLAUSE_PROC_BIND_TRUE = 1, + OMP_CLAUSE_PROC_BIND_PRIMARY = 2, OMP_CLAUSE_PROC_BIND_MASTER = 2, OMP_CLAUSE_PROC_BIND_CLOSE = 3, OMP_CLAUSE_PROC_BIND_SPREAD = 4, diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 7201bd7..31f886f 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1008,6 +1008,8 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags) switch (OMP_CLAUSE_PROC_BIND_KIND (clause)) { case OMP_CLAUSE_PROC_BIND_MASTER: + /* Same enum value: case OMP_CLAUSE_PROC_BIND_PRIMARY: */ + /* TODO: Change to 'primary' for OpenMP 5.1. */ pp_string (pp, "master"); break; case OMP_CLAUSE_PROC_BIND_CLOSE: |