public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062]
@ 2023-03-08  6:31 Hongyu Wang
  2023-03-08  7:35 ` Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: Hongyu Wang @ 2023-03-08  6:31 UTC (permalink / raw)
  To: jakub; +Cc: gcc-patches

Hi,

When OMP_WAIT_POLICY is not specified, current implementation will cause
icv flag GOMP_ICV_WAIT_POLICY unset, so global variable wait_policy
will remain its uninitialized value. Set it to -1 when the flag is not
specified to keep GOMP_SPINCOUNT behavior consistent with its description.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

libgomp/ChangeLog:

	PR libgomp/109062
	* env.c (initialize_env): Set wait_policy to -1 if
	OMP_WAIT_POLICY is not specified.
	* testsuite/libgomp.c-c++-common/pr109062.c: New test.
---
 libgomp/env.c                                     |  2 ++
 libgomp/testsuite/libgomp.c-c++-common/pr109062.c | 14 ++++++++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.c-c++-common/pr109062.c

diff --git a/libgomp/env.c b/libgomp/env.c
index c41c1f852cc..fa36a8697d6 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -2249,6 +2249,8 @@ initialize_env (void)
     wait_policy = none->icvs.wait_policy;
   else if (all != NULL && gomp_get_icv_flag (all->flags, GOMP_ICV_WAIT_POLICY))
     wait_policy = all->icvs.wait_policy;
+  else
+    wait_policy = -1;
 
   if (!parse_spincount ("GOMP_SPINCOUNT", &gomp_spin_count_var))
     {
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr109062.c b/libgomp/testsuite/libgomp.c-c++-common/pr109062.c
new file mode 100644
index 00000000000..5c7c287dafd
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr109062.c
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  omp_display_env (1);
+
+  return 0;
+}
+
+/* { dg-output ".*\\\[host] GOMP_SPINCOUNT = '300000'.*" { target native } } */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-08  9:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  6:31 [PATCH] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] Hongyu Wang
2023-03-08  7:35 ` Jakub Jelinek
2023-03-08  8:07   ` Hongyu Wang
2023-03-08  8:21     ` Hongyu Wang
2023-03-08  8:35       ` Jakub Jelinek
2023-03-08  8:54         ` Hongyu Wang
2023-03-08  9:03           ` 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).