public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9169] openmp: Fix up handling of OMP_PLACES=threads(1)
@ 2021-10-18 15:41 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-10-18 15:41 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2e6c780e1e1c7da24ec1bf3f8053980fa9ac0674
commit r11-9169-g2e6c780e1e1c7da24ec1bf3f8053980fa9ac0674
Author: Jakub Jelinek <jakub@redhat.com>
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 <jakub@redhat.com>
* 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 1b636c61370..ca83bc3909a 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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-18 15:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 15:41 [gcc r11-9169] openmp: Fix up handling of OMP_PLACES=threads(1) Jakub Jelinek
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).