From patchwork Wed Nov 21 20:36:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 200854 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 EE09D2C0082 for ; Thu, 22 Nov 2012 07:36:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1354134992; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=U7V1chpPYY1TfxQazPvq J+4MvYA=; b=e9mur6wGuqpecS59OrO54y0wRBZhuLtZOr1KmTnNeb5ZZWnchnEo B3foyGZIEoHGPu334QnzoRZ9aSMFPKcIsaZLHY1yAAiCNpkq5GGTkGYqxQ7VjE+0 WiQYYL5nt5NI8JBis3qPlExwUA4/78uwadiC5VSc+5FnHZNNvqPz9ME= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=G6lddJd8gHnTRiImsfbZA9BYeeSRqwaEdyk/QeXKngEeQx8oHdXPpT3Rhep25A IMA5qEMjk0uGLIwB6Wy2CXBigHDKkaKmIAOFU/kSlamuMirhhbH6Ff4l/tfYgCmZ 7g/8iS97gsCeKyX8ELAplAu1eTxhYYGFU3543tmrsNd4Y=; Received: (qmail 19415 invoked by alias); 21 Nov 2012 20:36:26 -0000 Received: (qmail 19101 invoked by uid 22791); 21 Nov 2012 20:36:22 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Wed, 21 Nov 2012 20:36:13 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qALKaCCJ030845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 21 Nov 2012 15:36:12 -0500 Received: from zalov.redhat.com (vpn1-6-55.ams2.redhat.com [10.36.6.55]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qALKaBM7017533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 21 Nov 2012 15:36:12 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qALKaACf017953 for ; Wed, 21 Nov 2012 21:36:10 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qALKaAaX017952 for gcc-patches@gcc.gnu.org; Wed, 21 Nov 2012 21:36:10 +0100 Date: Wed, 21 Nov 2012 21:36:10 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Update gomp_managed_threads in gomp_free_thread (PR libgomp/55411) Message-ID: <20121121203609.GH2315@tucnak.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! gomp_free_thread wasn't updating gomp_managed_threads count, so if a thread that executed #pragma omp parallel terminated, we might be still using throttled spin count instead of normal one unnecessarily. Tested on x86_64-linux and i686-linux, committed to trunk and 4.7. 2012-11-21 Jakub Jelinek PR libgomp/55411 * team.c (gomp_free_thread): Decrease gomp_managed_threads if pool had any threads_used. Jakub --- libgomp/team.c.jj 2011-08-03 18:40:16.000000000 +0200 +++ libgomp/team.c 2012-11-21 11:21:42.188165545 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 +/* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011, 2012 Free Software Foundation, Inc. Contributed by Richard Henderson . @@ -232,6 +232,15 @@ gomp_free_thread (void *arg __attribute_ gomp_barrier_wait (&pool->threads_dock); /* Now it is safe to destroy the barrier and free the pool. */ gomp_barrier_destroy (&pool->threads_dock); + +#ifdef HAVE_SYNC_BUILTINS + __sync_fetch_and_add (&gomp_managed_threads, + 1L - pool->threads_used); +#else + gomp_mutex_lock (&gomp_remaining_threads_lock); + gomp_managed_threads -= pool->threads_used - 1L; + gomp_mutex_unlock (&gomp_remaining_threads_lock); +#endif } free (pool->threads); if (pool->last_team)