From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 542C13858418; Sat, 16 Oct 2021 15:51:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 542C13858418 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] openmp: Fix up handling of OMP_PLACES=threads(1) X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: c0a91dff3902eb00ff1ac8755f1b20a27b721728 X-Git-Newrev: 372e0273080638bfa3b02e30558581a1b82f1500 Message-Id: <20211016155116.542C13858418@sourceware.org> Date: Sat, 16 Oct 2021 15:51:16 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Oct 2021 15:51:16 -0000 https://gcc.gnu.org/g:372e0273080638bfa3b02e30558581a1b82f1500 commit 372e0273080638bfa3b02e30558581a1b82f1500 Author: Jakub Jelinek Date: Fri Oct 15 23:31:13 2021 +0200 openmp: Fix up handling of OMP_PLACES=threads(1) When writing the places-*.c tests, I've noticed that we mishandle threads abstract name with specified num-places if num-places isn't a multiple of number of hw threads in a core. It then happily ignores the maximum count and overwrites for the remaining hw threads in a core further places that haven't been allocated. 2021-10-15 Jakub Jelinek * config/linux/affinity.c (gomp_affinity_init_level_1): For level 1 after creating count places clean up and return immediately. * testsuite/libgomp.c/places-6.c: New test. * testsuite/libgomp.c/places-7.c: New test. * testsuite/libgomp.c/places-8.c: New test. * testsuite/libgomp.c/places-9.c: New test. * testsuite/libgomp.c/places-10.c: New test. (cherry picked from commit 4764049dd620affcd3e2658dc7f03a6616370a29) Diff: --- libgomp/ChangeLog.omp | 13 +++++++++++++ libgomp/config/linux/affinity.c | 9 +++++++-- libgomp/testsuite/libgomp.c/places-10.c | 10 ++++++++++ libgomp/testsuite/libgomp.c/places-6.c | 10 ++++++++++ libgomp/testsuite/libgomp.c/places-7.c | 10 ++++++++++ libgomp/testsuite/libgomp.c/places-8.c | 10 ++++++++++ libgomp/testsuite/libgomp.c/places-9.c | 10 ++++++++++ 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index cb05c2c11f2..f7303f491cf 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,16 @@ +2021-10-15 Tobias Burnus + + Backported from master: + 2021-10-15 Jakub Jelinek + + * config/linux/affinity.c (gomp_affinity_init_level_1): For level 1 + after creating count places clean up and return immediately. + * testsuite/libgomp.c/places-6.c: New test. + * testsuite/libgomp.c/places-7.c: New test. + * testsuite/libgomp.c/places-8.c: New test. + * testsuite/libgomp.c/places-9.c: New test. + * testsuite/libgomp.c/places-10.c: New test. + 2021-10-15 Tobias Burnus Backported from master: diff --git a/libgomp/config/linux/affinity.c b/libgomp/config/linux/affinity.c index 82981b65472..69e72a8d141 100644 --- a/libgomp/config/linux/affinity.c +++ b/libgomp/config/linux/affinity.c @@ -338,8 +338,13 @@ gomp_affinity_init_level_1 (int level, int this_level, unsigned long count, if (gomp_affinity_add_cpus (pl, first, 1, 0, true)) { CPU_CLR_S (first, gomp_cpuset_size, copy); - if (level == 1) - gomp_places_list_len++; + if (level == 1 + && ++gomp_places_list_len >= count) + { + fclose (f); + free (line); + return; + } } } if (*p == ',') diff --git a/libgomp/testsuite/libgomp.c/places-10.c b/libgomp/testsuite/libgomp.c/places-10.c new file mode 100644 index 00000000000..7746b15cb44 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-10.c @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "numa_domains(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/places-6.c b/libgomp/testsuite/libgomp.c/places-6.c new file mode 100644 index 00000000000..bf552fbe2d4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-6.c @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "threads(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/places-7.c b/libgomp/testsuite/libgomp.c/places-7.c new file mode 100644 index 00000000000..07f3d97e7b2 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-7.c @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "cores(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/places-8.c b/libgomp/testsuite/libgomp.c/places-8.c new file mode 100644 index 00000000000..ca7d55bc7a8 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-8.c @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "sockets(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/places-9.c b/libgomp/testsuite/libgomp.c/places-9.c new file mode 100644 index 00000000000..627cdcea538 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-9.c @@ -0,0 +1,10 @@ +/* { dg-set-target-env-var OMP_PLACES "ll_caches(1)" } */ + +#include + +int +main () +{ + omp_display_env (0); + return 0; +}