From patchwork Wed Mar 8 06:31:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 1753899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=v/fvLMpk; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWjCW1zPlz1yWr for ; Wed, 8 Mar 2023 17:32:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8734C385480C for ; Wed, 8 Mar 2023 06:32:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8734C385480C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678257123; bh=bznZIg7Od2RmdEjD91L730k1WkjoRse6r+O/3hQO/9I=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=v/fvLMpkArThiFaivTZkU94FYP4U75R6OzX7x9fJiDm34XSCtHuBijXsEJnJhlCGL u3NUeOlbSE2eLBJFAQpyqsaFFaqQPsBCdJLV0tciDh20/vccP1MgNvaN6hUMMU/aPj rgLXJbJ9aLooGKKGQ3nDHDh9L0B9DUlrVpaBw2R4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 060143858410 for ; Wed, 8 Mar 2023 06:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 060143858410 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="334791462" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="334791462" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 22:31:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="676854393" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="676854393" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga002.jf.intel.com with ESMTP; 07 Mar 2023 22:31:39 -0800 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 849651007822; Wed, 8 Mar 2023 14:31:38 +0800 (CST) To: jakub@redhat.com Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] Date: Wed, 8 Mar 2023 14:31:38 +0800 Message-Id: <20230308063138.1490431-1-hongyu.wang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE, SPF_SOFTFAIL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hongyu Wang via Gcc-patches From: Hongyu Wang Reply-To: Hongyu Wang Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "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 +#include + +int +main () +{ + omp_display_env (1); + + return 0; +} + +/* { dg-output ".*\\\[host] GOMP_SPINCOUNT = '300000'.*" { target native } } */