pool.h revision 1.1.1.2 1 1.1.1.2 mrg /* Copyright (C) 2005-2017 Free Software Foundation, Inc.
2 1.1 mrg Contributed by Sebastian Huber <sebastian.huber (at) embedded-brains.de>.
3 1.1 mrg
4 1.1 mrg This file is part of the GNU Offloading and Multi Processing Library
5 1.1 mrg (libgomp).
6 1.1 mrg
7 1.1 mrg Libgomp is free software; you can redistribute it and/or modify it
8 1.1 mrg under the terms of the GNU General Public License as published by
9 1.1 mrg the Free Software Foundation; either version 3, or (at your option)
10 1.1 mrg any later version.
11 1.1 mrg
12 1.1 mrg Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 1.1 mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 1.1 mrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 1.1 mrg more details.
16 1.1 mrg
17 1.1 mrg Under Section 7 of GPL version 3, you are granted additional
18 1.1 mrg permissions described in the GCC Runtime Library Exception, version
19 1.1 mrg 3.1, as published by the Free Software Foundation.
20 1.1 mrg
21 1.1 mrg You should have received a copy of the GNU General Public License and
22 1.1 mrg a copy of the GCC Runtime Library Exception along with this program;
23 1.1 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 1.1 mrg <http://www.gnu.org/licenses/>. */
25 1.1 mrg
26 1.1 mrg /* This is the default implementation of the thread pool management
27 1.1 mrg for libgomp. This type is private to the library. */
28 1.1 mrg
29 1.1 mrg #ifndef GOMP_POOL_H
30 1.1 mrg #define GOMP_POOL_H 1
31 1.1 mrg
32 1.1 mrg #include "libgomp.h"
33 1.1 mrg
34 1.1 mrg /* Get the thread pool, allocate and initialize it on demand. */
35 1.1 mrg
36 1.1 mrg static inline struct gomp_thread_pool *
37 1.1 mrg gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads)
38 1.1 mrg {
39 1.1 mrg struct gomp_thread_pool *pool = thr->thread_pool;
40 1.1 mrg if (__builtin_expect (pool == NULL, 0))
41 1.1 mrg {
42 1.1 mrg pool = gomp_malloc (sizeof (*pool));
43 1.1 mrg pool->threads = NULL;
44 1.1 mrg pool->threads_size = 0;
45 1.1 mrg pool->threads_used = 0;
46 1.1 mrg pool->last_team = NULL;
47 1.1 mrg pool->threads_busy = nthreads;
48 1.1 mrg thr->thread_pool = pool;
49 1.1 mrg pthread_setspecific (gomp_thread_destructor, thr);
50 1.1 mrg }
51 1.1 mrg return pool;
52 1.1 mrg }
53 1.1 mrg
54 1.1 mrg static inline void
55 1.1 mrg gomp_release_thread_pool (struct gomp_thread_pool *pool)
56 1.1 mrg {
57 1.1 mrg /* Do nothing in the default implementation. */
58 1.1 mrg }
59 1.1 mrg
60 1.1 mrg static inline pthread_attr_t *
61 1.1 mrg gomp_adjust_thread_attr (pthread_attr_t *attr, pthread_attr_t *mutable_attr)
62 1.1 mrg {
63 1.1 mrg /* Do nothing in the default implementation. */
64 1.1 mrg return attr;
65 1.1 mrg }
66 1.1 mrg
67 1.1 mrg #endif /* GOMP_POOL_H */
68