Hi!
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.
Regtested on x86_64-linux and i686-linux, commited to trunk.
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.
Jakub
@@ -546,6 +546,7 @@ parse_one_place (char **envp, bool *nega
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 *nega
++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 *nega
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 *nega
++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 *nega
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 *nega
++env;
}
}
- if (*negatep && len != 1)
- return false;
*envp = env;
*lenp = len;
*stridep = stride;
@@ -309,7 +309,7 @@ The OpenMP 4.5 specification is fully su
@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 su
@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
@@ -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;