This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Update gomp_managed_threads in gomp_free_thread (PR libgomp/55411)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 21 Nov 2012 21:36:10 +0100
- Subject: [committed] Update gomp_managed_threads in gomp_free_thread (PR libgomp/55411)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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 <jakub@redhat.com>
PR libgomp/55411
* team.c (gomp_free_thread): Decrease gomp_managed_threads
if pool had any threads_used.
--- 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 <rth@redhat.com>.
@@ -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)
Jakub