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 0FA9C3858C54 for ; Wed, 8 Mar 2023 08:35:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FA9C3858C54 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=1678264544; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h7bq6jQeIi4m6IV8wAwXLOXQmtPO/0p2sWaIcqtlPK8=; b=eZYNJLm5vbNquR8jdItywoGKc1lvya8S2vZt8wgXO2wH8zl1gZMj4u1Doxs5wQSL2fcDpf qJz9tOr26M3ZLeGvyOSDOH462JXbS73wjJ0tre7b1vip+fDH5V58V4z4RytmSt1BXvEvq3 wAPxm49JkjRWmRA2cFzSS3N8JEAP+zQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-138-uyoQZqlxOEyOBDyad1jBsQ-1; Wed, 08 Mar 2023 03:35:41 -0500 X-MC-Unique: uyoQZqlxOEyOBDyad1jBsQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E72492805588; Wed, 8 Mar 2023 08:35:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5B0A2026D4B; Wed, 8 Mar 2023 08:35:40 +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 3288ZcgY2673318 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 8 Mar 2023 09:35:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3288ZaxR2673317; Wed, 8 Mar 2023 09:35:36 +0100 Date: Wed, 8 Mar 2023 09:35:36 +0100 From: Jakub Jelinek To: Hongyu Wang Cc: Hongyu Wang , 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: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 04:21:46PM +0800, Hongyu Wang wrote: > Hongyu Wang 于2023年3月8日周三 16:07写道: > > > > > 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. > > > > It doesn't work, for the code that determines value of wait_policy: > > > > if (none != NULL && gomp_get_icv_flag (none->flags, GOMP_ICV_WAIT_POLICY)) > > 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; > > > > gomp_get_icv_flag (none->flags, GOMP_ICV_WAIT_POLICY) returns true only when > > OMP_WAIT_POLICY is explicitly set, so the initial icvs->wait_policy > > could not affect the global wait_policy that used to set > > GOMP_SPINCOUNT. > > Also the global variable wait_policy here is only used for setting > spin_count related values that do not > belong to any ICV, so there is no need to set icvs->wait_policy since > for OMP_WAIT_POLICY_(DEV|ALL) > itself only has value 0 for passive and value 1 for active. 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; Jakub