Message ID | 55A4F6DD.5000600@embedded-brains.de |
---|---|
State | New |
Headers | show |
Hi! On Tue, Jul 14, 2015 at 01:47:41PM +0200, Sebastian Huber wrote: > With --disable-linux-futex (without asserts) I got several failures, but > none of them is related to my patch, e.g. they are of the following type > > /tmp/ccw4RofR.o: In function `main': > data-already-3.f:(.text+0x56): undefined reference to `acc_copyin_array_h_' CCing Thomas on that, that is for the OpenACC folks to resolve. > 2015-07-14 Sebastian Huber <sebastian.huber@embedded-brains.de> > > * team.c (get_last_team): New. > (gomp_new_team): Recycle last non-nested team if possible. > (gomp_team_end): Move team work share list free lock destruction > to... > (free_team): ...here. Ok for trunk (please put a space in between to and ... and ... and here). > + if (team == NULL) > + { > + size_t extra = sizeof (team->ordered_release[0]) > + + sizeof (team->implicit_task[0]); And make sure to use tab instead of 8 spaces on the above line. Jakub
Thanks, I checked this in: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=225811
Hallo! On Tue, 14 Jul 2015 13:47:41 +0200, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote: > [...] > > I run the test suite on x86_64-unknown-linux-gnu with the previously > mentioned asserts and got no unexpected failures. > > With --disable-linux-futex (without asserts) I got several failures, but > none of them is related to my patch, e.g. they are of the following type > > /tmp/ccw4RofR.o: In function `main': > data-already-3.f:(.text+0x56): undefined reference to `acc_copyin_array_h_' Hmm, I have difficulties seeing how --disable-linux-futex and/or your libgomp/team.c could have any effect on OpenACC Fortran; I've not yet been able to reproduce this. Can you please tell me your complete GCC configuration command line, etc., as well as cite from libgomp.log a FAILing invocation command line: > === libgomp tests === > > Schedule of variations: > unix > > Running target unix > Using /usr/share/dejagnu/baseboards/unix.exp as board description file > for target. > Using /usr/share/dejagnu/config/unix.exp as generic interface file for > target. > Using > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/config/default.exp as > tool-and-target-specific interface file. > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.c/c.exp ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.c++/c++.exp > ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.fortran/fortran.exp > ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.graphite/graphite.exp > ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.oacc-c/c.exp > ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.oacc-c++/c++.exp > ... > Running > /home/EB/sebastian_h/archive/gcc-git/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp > ... > FAIL: libgomp.oacc-fortran/acc_on_device-1-1.f90 > -DACC_DEVICE_TYPE_host_nonshm=1 -DACC_MEM_SHARED=0 -O (test for excess > errors) > WARNING: libgomp.oacc-fortran/acc_on_device-1-1.f90 > -DACC_DEVICE_TYPE_host_nonshm=1 -DACC_MEM_SHARED=0 -O compilation > failed to produce executable > [...] Grüße, Thomas
On 15/07/15 14:16, Thomas Schwinge wrote: > Hallo! > > On Tue, 14 Jul 2015 13:47:41 +0200, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote: >> [...] >> >> I run the test suite on x86_64-unknown-linux-gnu with the previously >> mentioned asserts and got no unexpected failures. >> >> With --disable-linux-futex (without asserts) I got several failures, but >> none of them is related to my patch, e.g. they are of the following type >> >> /tmp/ccw4RofR.o: In function `main': >> data-already-3.f:(.text+0x56): undefined reference to `acc_copyin_array_h_' > Hmm, I have difficulties seeing how --disable-linux-futex and/or your > libgomp/team.c could have any effect on OpenACC Fortran; I've not yet > been able to reproduce this. Can you please tell me your complete GCC > configuration command line, etc., as well as cite from libgomp.log a > FAILing invocation command line: I deleted my build tree and started from scratch with the latest trunk version. Now I don't get errors with --disable-linux-futex: Native configuration is x86_64-unknown-linux-gnu === libgomp tests === Schedule of variations: unix Running target unix Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using gcc-git/libgomp/testsuite/config/default.exp as tool-and-target-specific interface file. Running gcc-git/libgomp/testsuite/libgomp.c/c.exp ... Running gcc-git/libgomp/testsuite/libgomp.c++/c++.exp ... Running gcc-git/libgomp/testsuite/libgomp.fortran/fortran.exp ... Running gcc-git/libgomp/testsuite/libgomp.graphite/graphite.exp ... Running gcc-git/libgomp/testsuite/libgomp.oacc-c/c.exp ... Running gcc-git/libgomp/testsuite/libgomp.oacc-c++/c++.exp ... Running gcc-git/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp ... === libgomp Summary === # of expected passes 5145 # of expected failures 8 # of unsupported tests 258 Sorry for the confusion, I guess that I somehow damaged my previous build tree.
Hi! On Wed, 15 Jul 2015 15:25:19 +0200, Sebastian Huber <sebastian.huber@embedded-brains.de> wrote: > I deleted my build tree and started from scratch with the latest trunk > version. Now I don't get errors with --disable-linux-futex: > # of expected passes 5145 > # of expected failures 8 > # of unsupported tests 258 > > Sorry for the confusion, I guess that I somehow damaged my previous > build tree. Alright, then there is no inexplicable mystery to be chased after; thanks for checking. :-) Grüße, Thomas
From 6e30dadecb5aa7f8dfb14cb0f2f4de2a56338012 Mon Sep 17 00:00:00 2001 From: Sebastian Huber <sebastian.huber@embedded-brains.de> Date: Tue, 7 Jul 2015 13:15:04 +0200 Subject: [PATCH] [gomp] Recycle last non-nested team if possible Try to recycle the last non-nested team to avoid the use of malloc() and free() in the normal case where the number of threads is the same. Avoid superfluous destruction and initialization of team synchronization objects. Using the microbenchmark posted here https://gcc.gnu.org/ml/gcc-patches/2008-03/msg00930.html shows an improvement in the parallel bench test case (target x86_64-unknown-linux-gnu, median out of 9 test runs, iteration count increased to 200000). Before the patch: parallel bench 11.2284 seconds After the patch: parallel bench 10.5912 seconds libgomp/ChangeLog 2015-07-14 Sebastian Huber <sebastian.huber@embedded-brains.de> * team.c (get_last_team): New. (gomp_new_team): Recycle last non-nested team if possible. (gomp_team_end): Move team work share list free lock destruction to... (free_team): ...here. --- libgomp/team.c | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/libgomp/team.c b/libgomp/team.c index b98b233..4525eaf 100644 --- a/libgomp/team.c +++ b/libgomp/team.c @@ -134,6 +134,25 @@ gomp_thread_start (void *xdata) return NULL; } +static inline struct gomp_team * +get_last_team (unsigned nthreads) +{ + struct gomp_thread *thr = gomp_thread (); + if (thr->ts.team == NULL) + { + struct gomp_thread_pool *pool = thr->thread_pool; + if (pool != NULL) + { + struct gomp_team *last_team = pool->last_team; + if (last_team != NULL && last_team->nthreads == nthreads) + { + pool->last_team = NULL; + return last_team; + } + } + } + return NULL; +} /* Create a new team data structure. */ @@ -141,18 +160,27 @@ struct gomp_team * gomp_new_team (unsigned nthreads) { struct gomp_team *team; - size_t size; int i; - size = sizeof (*team) + nthreads * (sizeof (team->ordered_release[0]) - + sizeof (team->implicit_task[0])); - team = gomp_malloc (size); + team = get_last_team (nthreads); + if (team == NULL) + { + size_t extra = sizeof (team->ordered_release[0]) + + sizeof (team->implicit_task[0]); + team = gomp_malloc (sizeof (*team) + nthreads * extra); + +#ifndef HAVE_SYNC_BUILTINS + gomp_mutex_init (&team->work_share_list_free_lock); +#endif + gomp_barrier_init (&team->barrier, nthreads); + gomp_mutex_init (&team->task_lock); + + team->nthreads = nthreads; + } team->work_share_chunk = 8; #ifdef HAVE_SYNC_BUILTINS team->single_count = 0; -#else - gomp_mutex_init (&team->work_share_list_free_lock); #endif team->work_shares_to_free = &team->work_shares[0]; gomp_init_work_share (&team->work_shares[0], false, nthreads); @@ -163,14 +191,10 @@ gomp_new_team (unsigned nthreads) team->work_shares[i].next_free = &team->work_shares[i + 1]; team->work_shares[i].next_free = NULL; - team->nthreads = nthreads; - gomp_barrier_init (&team->barrier, nthreads); - gomp_sem_init (&team->master_release, 0); team->ordered_release = (void *) &team->implicit_task[nthreads]; team->ordered_release[0] = &team->master_release; - gomp_mutex_init (&team->task_lock); team->task_queue = NULL; team->task_count = 0; team->task_queued_count = 0; @@ -187,6 +211,9 @@ gomp_new_team (unsigned nthreads) static void free_team (struct gomp_team *team) { +#ifndef HAVE_SYNC_BUILTINS + gomp_mutex_destroy (&team->work_share_list_free_lock); +#endif gomp_barrier_destroy (&team->barrier); gomp_mutex_destroy (&team->task_lock); free (team); @@ -895,9 +922,6 @@ gomp_team_end (void) while (ws != NULL); } gomp_sem_destroy (&team->master_release); -#ifndef HAVE_SYNC_BUILTINS - gomp_mutex_destroy (&team->work_share_list_free_lock); -#endif if (__builtin_expect (thr->ts.team != NULL, 0) || __builtin_expect (team->nthreads == 1, 0)) -- 1.8.4.5