From patchwork Thu Dec 2 14:43:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 73977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 62779B7043 for ; Fri, 3 Dec 2010 01:43:17 +1100 (EST) Received: (qmail 11179 invoked by alias); 2 Dec 2010 14:43:14 -0000 Received: (qmail 11168 invoked by uid 22791); 2 Dec 2010 14:43:13 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Dec 2010 14:43:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB2Eh67M028750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Dec 2010 09:43:06 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB2Eh6Pi003721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Dec 2010 09:43:06 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oB2Eh5K7023498 for ; Thu, 2 Dec 2010 15:43:05 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oB2Eh5tK023496 for gcc-patches@gcc.gnu.org; Thu, 2 Dec 2010 15:43:05 +0100 Date: Thu, 2 Dec 2010 15:43:05 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Decrease default spin count in libgomp (PR libgomp/43706) Message-ID: <20101202144305.GM29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! As discussed in the PR, the default when OMP_WAIT_POLICY nor GOMP_SPINCOUNT is not present in the environment, is probably too big in many cases, when OpenMP programs aren't the sole thing run on the machine. Ideally we'd do some dynamic adjustment when we detect that threads spinning are too often scheduled away from the CPU, but for best results we'd need some kernel support, or at least query hw profiling registers. So, for now, I'm just decreasing the defaults. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2010-12-02 Jakub Jelinek PR libgomp/43706 * env.c (initialize_env): Default to spin count 300000 instead of 20000000 if neither OMP_WAIT_POLICY nor GOMP_SPINCOUNT is specified. Jakub --- libgomp/env.c.jj 2010-12-02 09:59:48.000000000 +0100 +++ libgomp/env.c 2010-12-02 10:01:07.000000000 +0100 @@ -502,14 +502,14 @@ initialize_env (void) { /* Using a rough estimation of 100000 spins per msec, use 5 min blocking for OMP_WAIT_POLICY=active, - 200 msec blocking when OMP_WAIT_POLICY is not specificed + 3 msec blocking when OMP_WAIT_POLICY is not specificed and 0 when OMP_WAIT_POLICY=passive. Depending on the CPU speed, this can be e.g. 5 times longer or 5 times shorter. */ if (wait_policy > 0) gomp_spin_count_var = 30000000000LL; else if (wait_policy < 0) - gomp_spin_count_var = 20000000LL; + gomp_spin_count_var = 300000LL; } /* gomp_throttled_spin_count_var is used when there are more libgomp managed threads than available CPUs. Use very short spinning. */