From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9EAA33858C30 for ; Wed, 8 Mar 2023 07:35:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EAA33858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678260939; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=xtL5km13uNFh1ei+zSlRHl0SrXon9wKlxv9W3/xZ2rQ=; b=OD+gCOvYn2I1lR/2GXWnaO19uaI+JtoVtDytKvHcsFNnngAB+V8Bly0Cr+K9NFynwccUKs tC0phTCiF0xI5gWfingXflK04itjpv2jCW9Nw9MLziYLmXfANnFcc/z68NNzH3C2MI2q9B 9MrANEF+2TLm7yb14lTKas2JQYCcg/I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-7GnYQaGUNBixh-anem_MPg-1; Wed, 08 Mar 2023 02:35:36 -0500 X-MC-Unique: 7GnYQaGUNBixh-anem_MPg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E04F618E53C6; Wed, 8 Mar 2023 07:35:35 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3107492C3E; Wed, 8 Mar 2023 07:35:35 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3287ZWpB2671610 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 8 Mar 2023 08:35:33 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3287ZWoO2671609; Wed, 8 Mar 2023 08:35:32 +0100 Date: Wed, 8 Mar 2023 08:35:31 +0100 From: Jakub Jelinek To: Hongyu Wang Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] Message-ID: Reply-To: Jakub Jelinek References: <20230308063138.1490431-1-hongyu.wang@intel.com> MIME-Version: 1.0 In-Reply-To: <20230308063138.1490431-1-hongyu.wang@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Mar 08, 2023 at 02:31:38PM +0800, Hongyu Wang wrote: > 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. I think the right spot to fix this would be instead in initialize_icvs, change the icvs->wait_policy = 0; in there to icvs->wait_policy = -1; That way it will be the default for all the devices, not just the initial one. Ok for trunk with that change if it works. > 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 > +#include > + > +int > +main () > +{ > + omp_display_env (1); > + > + return 0; > +} > + > +/* { dg-output ".*\\\[host] GOMP_SPINCOUNT = '300000'.*" { target native } } */ > -- > 2.31.1 Jakub