From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 357B23851ABF for ; Wed, 8 Mar 2023 09:00:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 357B23851ABF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x52f.google.com with SMTP id ay14so59034403edb.11 for ; Wed, 08 Mar 2023 01:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678266014; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SOwv7UcxnqfWUb02uDO3NoOL/wsog7kw7GRgHy2nj6w=; b=FT3UP72dPrtUtL0L+PILGSKzElKZKwX5JJoya8yTyg22telq1NKTgk1mn37q6u9sO+ P+GbkuLkMvED0UqLICrQWwZpKEmuCFMEyMSG0xLtdvAL5rxUy76j0t3Y6IINPZZRm0ZY oTGS9qC4eesvmiHHpWDDxugaLIrhhZLN1kUHpE0VlrVVEUNekAgnB3jUBqXta5xYxj8/ NLhD64UiYAl6jRq10oammqWKVlWPkBOdJmG3JT0d9DZXQbUkXmUGTnTuTRmnbcl7kThS 7hVSIU6HrOFFt6/oZRUULEtI4iwPX1KzlGDJ5juyQq2VKe2ePFA2yr1KVN81MmYU5WX/ CsGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678266014; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SOwv7UcxnqfWUb02uDO3NoOL/wsog7kw7GRgHy2nj6w=; b=HuJhxdFTU/19L4ry4ds7RoI8z5n5UU/V5vgolqmkjevUELp59JIRkSzK2kadpQz5/I Z3F9OnTrxzP3qfKAuJ2qrM/2TbisIG53bSWWzk2UcW+R6CwTQ4dQM/PLDEoqWY+7Uakg FNGSLxjdZU+u3chFiLMLKidvX6jmbTkSyXLy1y0oB9m3XO4cNLdGB4C8DrC7LHHjYxyV JlJ2Iagi6JujAAO5bfO3jQwTABL/fZQ+SA6BHwHT4N3sGoDA/Sd+ciuj7i1T7j212xeC z0Woy0zThJDg7Luiced1UZw439cnqjEIji9TcpU6EaW4zp1zWKu6GTR2JzEjtZrLS6rr l6/A== X-Gm-Message-State: AO0yUKULs3d9ZzJyQ1xzU7it2P34hoAgj2iHuBhqhbiZguvzeJA95nny VfLaDRJt6iYADXe15cTcHhmQWbYLN+yeXmxuh0U= X-Google-Smtp-Source: AK7set84ItV6IBYVMdPfxBQSXr0f8+B+P5st+OfaiiHevt8oUBYEz/m7Ne1UJOF0YkQxdoZvsjNhmKZg27C3YlrCp8g= X-Received: by 2002:a17:906:1849:b0:8b1:749f:b2c6 with SMTP id w9-20020a170906184900b008b1749fb2c6mr8141133eje.2.1678266013805; Wed, 08 Mar 2023 01:00:13 -0800 (PST) MIME-Version: 1.0 References: <20230308063138.1490431-1-hongyu.wang@intel.com> In-Reply-To: From: Hongyu Wang Date: Wed, 8 Mar 2023 16:54:20 +0800 Message-ID: Subject: Re: [PATCH] libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] To: Jakub Jelinek Cc: Hongyu Wang , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: > Seems for many ICVs the default values are done through > gomp_default_icv_values, but that doesn't cover wait_policy. > For other vars, the defaults are provided through just initializers of > those vars on the var definitions, e.g.: > char *gomp_affinity_format_var = "level %L thread %i affinity %A"; > So, I'd do the initialize_icvs change and change > static int wait_policy; > to > static int wait_policy = -1; Agreed, here is the updated patch, ok for trunk? 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 | 4 ++-- libgomp/testsuite/libgomp.c-c++-common/pr109062.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 libgomp/testsuite/libgomp.c-c++-common/pr109062.c 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 } } */ -- 2.31.1