diff options
author | pfg <pfg@FreeBSD.org> | 2015-05-16 15:44:13 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2015-05-16 15:44:13 +0000 |
commit | c5245aadbbe5796d58c966d6d6209a110f78dbe1 (patch) | |
tree | b026710099072006d1fbb442261e609e70bf15ec /contrib/gcclibs/libgomp/team.c | |
parent | 0f07927a1e80c78fdd924b93496d912f723740da (diff) | |
download | FreeBSD-src-c5245aadbbe5796d58c966d6d6209a110f78dbe1.zip FreeBSD-src-c5245aadbbe5796d58c966d6d6209a110f78dbe1.tar.gz |
MFC r282115, r282152, r282201
MFV r282150
libgomp: Update to version 4.3.5.
bring initial BSD support from upstream.
This was not meant to be MFC'd at first but the original OMP support
for FreeBSD was in very poor shape. The effect of this change should
be minimal as all ports are already using the version of libgomp that
comes with the gcc ports. The local libgomp is planned to be disabled
for platforms that are not using older gcc by default so this version
of libgomp will not be shipped in tier-1 platform releases.
Discussed with: emaste
Diffstat (limited to 'contrib/gcclibs/libgomp/team.c')
-rw-r--r-- | contrib/gcclibs/libgomp/team.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/contrib/gcclibs/libgomp/team.c b/contrib/gcclibs/libgomp/team.c index 060f4ea..7d50bfc 100644 --- a/contrib/gcclibs/libgomp/team.c +++ b/contrib/gcclibs/libgomp/team.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU OpenMP Library (libgomp). @@ -183,6 +183,7 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, struct gomp_team *team; bool nested; unsigned i, n, old_threads_used = 0; + pthread_attr_t thread_attr, *attr; thr = gomp_thread (); nested = thr->ts.team != NULL; @@ -265,6 +266,17 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, } } + attr = &gomp_thread_attr; + if (gomp_cpu_affinity != NULL) + { + size_t stacksize; + pthread_attr_init (&thread_attr); + pthread_attr_setdetachstate (&thread_attr, PTHREAD_CREATE_DETACHED); + if (! pthread_attr_getstacksize (&gomp_thread_attr, &stacksize)) + pthread_attr_setstacksize (&thread_attr, stacksize); + attr = &thread_attr; + } + start_data = gomp_alloca (sizeof (struct gomp_thread_start_data) * (nthreads-i)); @@ -283,12 +295,17 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads, start_data->fn_data = data; start_data->nested = nested; - err = pthread_create (&pt, &gomp_thread_attr, - gomp_thread_start, start_data); + if (gomp_cpu_affinity != NULL) + gomp_init_thread_affinity (attr); + + err = pthread_create (&pt, attr, gomp_thread_start, start_data); if (err != 0) gomp_fatal ("Thread creation failed: %s", strerror (err)); } + if (gomp_cpu_affinity != NULL) + pthread_attr_destroy (&thread_attr); + do_release: gomp_barrier_wait (nested ? &team->barrier : &gomp_threads_dock); |