On Thu, Jul 02, 2015 at 09:57:20PM +0200, Sebastian Huber wrote: > does anyone know what the purpose of gomp_thread_pool::last_team is? This > field seems to be used to delay the team destruction in gomp_team_end() in > case the team has more than one thread and the previous team state has no > team associated (identifies this a master thread?): > > if (__builtin_expect (thr->ts.team != NULL, 0) > || __builtin_expect (team->nthreads == 1, 0)) > free_team (team); > else > { > struct gomp_thread_pool *pool = thr->thread_pool; > if (pool->last_team) > free_team (pool->last_team); > pool->last_team = team; > } > > Why can you not immediately free the team?
That was added with https://gcc.gnu.org/ml/gcc-patches/2008-05/msg01674.html and the purpose is for non-nested teams make sure all the threads in the team move on to the pool's barrier before the team's barrier is destroyed. Jakub