]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062]
authorHongyu Wang <hongyu.wang@intel.com>
Wed, 8 Mar 2023 03:29:46 +0000 (11:29 +0800)
committerHongyu Wang <hongyu.wang@intel.com>
Thu, 9 Mar 2023 01:01:13 +0000 (09:01 +0800)
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. Initialize it to -1 to make
GOMP_SPINCOUNT behavior consistent with its description.

libgomp/ChangeLog:

PR libgomp/109062
* env.c (wait_policy): Initialize to -1.
(initialize_icvs): Initialize icvs->wait_policy to -1.
* testsuite/libgomp.c-c++-common/pr109062.c: New test.

libgomp/env.c
libgomp/testsuite/libgomp.c-c++-common/pr109062.c [new file with mode: 0644]

index c41c1f852ccf0de250e11a94f8fc6eba7a8903dd..e7a035b593c7370fbcb181cc9d0b6ee624e16d0e 100644 (file)
@@ -124,7 +124,7 @@ int goacc_default_dims[GOMP_DIM_MAX];
 
 #ifndef LIBGOMP_OFFLOADED_ONLY
 
-static int wait_policy;
+static int wait_policy = -1;
 static unsigned long stacksize = GOMP_DEFAULT_STACKSIZE;
 
 static void
@@ -1981,7 +1981,7 @@ initialize_icvs (struct gomp_initial_icvs *icvs)
   icvs->bind_var = gomp_default_icv_values.bind_var;
   icvs->nteams_var = gomp_default_icv_values.nteams_var;
   icvs->teams_thread_limit_var = gomp_default_icv_values.teams_thread_limit_var;
-  icvs->wait_policy = 0;
+  icvs->wait_policy = -1;
 }
 
 /* Helper function for initialize_env to add a device specific ICV value
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr109062.c b/libgomp/testsuite/libgomp.c-c++-common/pr109062.c
new file mode 100644 (file)
index 0000000..5c7c287
--- /dev/null
@@ -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 } } */