From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 60EA038515F7; Wed, 11 May 2022 06:22:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60EA038515F7 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-10105] openmp: Fix up handling of OMP_PLACES=threads(1) X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: ee221ea5cc02d628d0b967c007c52e7cac83c008 X-Git-Newrev: be2c01c63459e21f8a6da1e9c9933fdadd76eee5 Message-Id: <20220511062247.60EA038515F7@sourceware.org> Date: Wed, 11 May 2022 06:22:47 +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: Wed, 11 May 2022 06:22:47 -0000 https://gcc.gnu.org/g:be2c01c63459e21f8a6da1e9c9933fdadd76eee5 commit r9-10105-gbe2c01c63459e21f8a6da1e9c9933fdadd76eee5 Author: Jakub Jelinek Date: Fri Oct 15 16:25:25 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. (cherry picked from commit 4764049dd620affcd3e2658dc7f03a6616370a29) Diff: --- libgomp/config/linux/affinity.c | 9 +++++++-- libgomp/testsuite/libgomp.c/places-6.c | 8 ++++++++ libgomp/testsuite/libgomp.c/places-7.c | 8 ++++++++ libgomp/testsuite/libgomp.c/places-8.c | 8 ++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libgomp/config/linux/affinity.c b/libgomp/config/linux/affinity.c index 278101e31f2..15f58f71d8d 100644 --- a/libgomp/config/linux/affinity.c +++ b/libgomp/config/linux/affinity.c @@ -281,8 +281,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-6.c b/libgomp/testsuite/libgomp.c/places-6.c new file mode 100644 index 00000000000..831034601eb --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-6.c @@ -0,0 +1,8 @@ +/* { dg-set-target-env-var OMP_PLACES "threads(1)" } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "true" } */ + +int +main () +{ + 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..f0a77f41def --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-7.c @@ -0,0 +1,8 @@ +/* { dg-set-target-env-var OMP_PLACES "cores(1)" } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "true" } */ + +int +main () +{ + 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..31c698337e4 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/places-8.c @@ -0,0 +1,8 @@ +/* { dg-set-target-env-var OMP_PLACES "sockets(1)" } */ +/* { dg-set-target-env-var OMP_DISPLAY_ENV "true" } */ + +int +main () +{ + return 0; +}