public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax
@ 2021-10-16 15:51 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-10-16 15:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4429405a68d0063191efaacc4d14fce5088d60f3
commit 4429405a68d0063191efaacc4d14fce5088d60f3
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Oct 15 23:38:43 2021 +0200
openmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax
In addition to adding ll_caches and numa_domain abstract names
to OMP_PLACES syntax, OpenMP 5.1 also added one syntax simplification:
https://github.com/OpenMP/spec/issues/2080
https://github.com/OpenMP/spec/pull/2081
in particular that in the grammar place non-terminal is now
not only { res-list } but also res (i.e. a non-negative integer),
which stands as a shortcut for { res }
So, one can specify OMP_PLACES=0,4,8,12 with the meaning
OMP_PLACES={0},{4},{8},{12} or OMP_PLACES=0:4 instead of OMP_PLACES={0}:4
or OMP_PLACES={0},{1},{2},{3} etc.
This patch implements that.
2021-10-15 Jakub Jelinek <jakub@redhat.com>
* env.c (parse_one_place): Handle non-negative-number the same
as { non-negative-number }. Reject even !number:1 and
!number:1:stride or !place:1 or !place:1:stride instead of just
length other than 1.
* libgomp.texi (OpenMP 5.1): Document OMP_PLACES syntax extensions
and OMP_NUM_TEAMS/OMP_TEAMS_THREAD_LIMIT and
omp_{set_num,get_max}_teams/omp_{s,g}et_teams_thread_limit features
as implemented.
* testsuite/libgomp.c/affinity-1.c: Add a test for the 5.1 place
simplified syntax.
(cherry picked from commit 4a0fed0c0c7241562eaa5f1a4c916b689429ad86)
Diff:
---
libgomp/ChangeLog.omp | 16 +++++++++++++++
libgomp/env.c | 35 ++++++++++++++++++++++++--------
libgomp/libgomp.texi | 6 +++---
libgomp/testsuite/libgomp.c/affinity-1.c | 6 ++++--
4 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 937eeb3e2cf..c149bc9a88b 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,19 @@
+2021-10-15 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-10-15 Jakub Jelinek <jakub@redhat.com>
+
+ * env.c (parse_one_place): Handle non-negative-number the same
+ as { non-negative-number }. Reject even !number:1 and
+ !number:1:stride or !place:1 or !place:1:stride instead of just
+ length other than 1.
+ * libgomp.texi (OpenMP 5.1): Document OMP_PLACES syntax extensions
+ and OMP_NUM_TEAMS/OMP_TEAMS_THREAD_LIMIT and
+ omp_{set_num,get_max}_teams/omp_{s,g}et_teams_thread_limit features
+ as implemented.
+ * testsuite/libgomp.c/affinity-1.c: Add a test for the 5.1 place
+ simplified syntax.
+
2021-10-15 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/libgomp/env.c b/libgomp/env.c
index b0acacb5783..df10ff656b6 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -546,6 +546,7 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
long stride = 1;
int pass;
bool any_negate = false;
+ bool has_braces = true;
*negatep = false;
while (isspace ((unsigned char) *env))
++env;
@@ -557,12 +558,28 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
++env;
}
if (*env != '{')
- return false;
- ++env;
- while (isspace ((unsigned char) *env))
- ++env;
+ {
+ char *end;
+ unsigned long this_num;
+
+ errno = 0;
+ this_num = strtoul (env, &end, 10);
+ if (errno || end == env)
+ return false;
+ env = end - 1;
+ has_braces = false;
+ if (gomp_places_list
+ && !gomp_affinity_add_cpus (p, this_num, 1, 1, false))
+ return false;
+ }
+ else
+ {
+ ++env;
+ while (isspace ((unsigned char) *env))
+ ++env;
+ }
start = env;
- for (pass = 0; pass < (any_negate ? 2 : 1); pass++)
+ for (pass = 0; pass < (any_negate ? 2 : has_braces); pass++)
{
env = start;
do
@@ -590,6 +607,8 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
if (*env == ':')
{
++env;
+ if (this_negate)
+ return false;
while (isspace ((unsigned char) *env))
++env;
errno = 0;
@@ -612,8 +631,6 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
++env;
}
}
- if (this_negate && this_len != 1)
- return false;
if (gomp_places_list && pass == this_negate)
{
if (this_negate)
@@ -640,6 +657,8 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
if (*env == ':')
{
char *end;
+ if (*negatep)
+ return false;
++env;
while (isspace ((unsigned char) *env))
++env;
@@ -663,8 +682,6 @@ parse_one_place (char **envp, bool *negatep, unsigned long *lenp,
++env;
}
}
- if (*negatep && len != 1)
- return false;
*envp = env;
*lenp = len;
*stridep = stride;
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 0cc988f23a8..38f9f4ade73 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -309,7 +309,7 @@ The OpenMP 4.5 specification is fully supported.
@item @code{present} argument to @code{defaultmap} clause @tab N @tab
@item @code{omp_set_num_teams}, @code{omp_set_teams_thread_limit},
@code{omp_get_max_teams}, @code{omp_get_teams_thread_limit} runtime
- routines @tab N @tab
+ routines @tab Y @tab
@item @code{omp_target_is_accessible} runtime routine @tab N @tab
@item @code{omp_target_memcpy_async} and @code{omp_target_memcpy_rect_async}
runtime routines @tab N @tab
@@ -328,9 +328,9 @@ The OpenMP 4.5 specification is fully supported.
@code{ompt_callback_target_emi_t}, @code{ompt_callback_target_map_emi_t}
and @code{ompt_callback_target_submit_emi_t} @tab N @tab
@item @code{ompt_callback_error_t} type @tab N @tab
-@item @code{OMP_PLACES} syntax was extension @tab N @tab
+@item @code{OMP_PLACES} syntax extensions @tab Y @tab
@item @code{OMP_NUM_TEAMS} and @code{OMP_TEAMS_THREAD_LIMIT} environment
- variables @tab N @tab
+ variables @tab Y @tab
@end multitable
@unnumberedsubsec Other new OpenMP 5.1 features
diff --git a/libgomp/testsuite/libgomp.c/affinity-1.c b/libgomp/testsuite/libgomp.c/affinity-1.c
index 574a9f7b69a..1039e3b9c96 100644
--- a/libgomp/testsuite/libgomp.c/affinity-1.c
+++ b/libgomp/testsuite/libgomp.c/affinity-1.c
@@ -48,7 +48,7 @@ struct place
};
struct places
{
- char name[40];
+ char name[50];
int count;
struct place places[8];
} places_array[] = {
@@ -62,7 +62,9 @@ struct places
{ { 1, 1 }, { 2, 1 }, { 3, 1 },
{ 4, 1 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } },
{ "{0,1},{3,2,4},{6,5,!6},{6},{7:2:-1,!6}", 5,
- { { 0, 2 }, { 2, 3 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } }
+ { { 0, 2 }, { 2, 3 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } },
+ { "1,2,{2,3,!2},3,3,!3,!{5:3:-1,!4,!5},{4},5,!4,!5", 3,
+ { { 1, 1 }, { 2, 1 }, { 3, 1 } } }
};
unsigned long contig_cpucount;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-16 15:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-16 15:51 [gcc/devel/omp/gcc-11] openmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax Tobias Burnus
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).