From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7861) id 60859385B520; Thu, 9 Mar 2023 01:01:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60859385B520 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678323700; bh=aR7egwag48a0+IvbNPj6tYmUOJs4DQiWvt1mRl6pK6U=; h=From:To:Subject:Date:From; b=XqsxQ8k1lv3E49V45MXBeIAtWJcNj0lxQmy8KIV39ZxwNIrutcggRIgJrxH1J6wK2 LlQmBQ5dbiywgcoRcVYDG8xn4+e/53yWDSbs3tD1SmPlNSpZUI4/7dLC3tSJMwc8b2 GSlj7iZmCoTH1wNxCx9LErQvRj0bmNq3oUHrbluA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Hongyu Wang To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6548] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] X-Act-Checkin: gcc X-Git-Author: Hongyu Wang X-Git-Refname: refs/heads/master X-Git-Oldrev: 6a87fdd3ed6ef3511466f9cf41271726b643520b X-Git-Newrev: 288bc7b5d17511d1791899e4b2e3bf3489eb06dd Message-Id: <20230309010140.60859385B520@sourceware.org> Date: Thu, 9 Mar 2023 01:01:40 +0000 (GMT) List-Id: https://gcc.gnu.org/g:288bc7b5d17511d1791899e4b2e3bf3489eb06dd commit r13-6548-g288bc7b5d17511d1791899e4b2e3bf3489eb06dd Author: Hongyu Wang Date: Wed Mar 8 11:29:46 2023 +0800 libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] 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. Diff: --- libgomp/env.c | 4 ++-- libgomp/testsuite/libgomp.c-c++-common/pr109062.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libgomp/env.c b/libgomp/env.c index c41c1f852cc..e7a035b593c 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -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 index 00000000000..5c7c287dafd --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/pr109062.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ + +#include +#include + +int +main () +{ + omp_display_env (1); + + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_SPINCOUNT = '300000'.*" { target native } } */