diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-11-18 09:10:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-11-18 09:10:40 +0100 |
commit | 17da2c7425ea1f5bf417b954f444dbe1f1618a1c (patch) | |
tree | 9ce2dd3deabea300a014828072e33f3abfa6c277 /libgomp/team.c | |
parent | 7a2aa63fad06a72d9770b08491f1a7809eac7c50 (diff) | |
download | gcc-17da2c7425ea1f5bf417b954f444dbe1f1618a1c.zip gcc-17da2c7425ea1f5bf417b954f444dbe1f1618a1c.tar.gz gcc-17da2c7425ea1f5bf417b954f444dbe1f1618a1c.tar.bz2 |
libgomp: Ensure that either gomp_team is properly aligned [PR102838]
struct gomp_team has struct gomp_work_share array inside of it.
If that latter structure has 64-byte aligned member in the middle,
the whole struct gomp_team needs to be 64-byte aligned, but we weren't
allocating it using gomp_aligned_alloc.
This patch fixes that, except that on gcn team_malloc is special, so
I've instead decided at least for now to avoid using aligned member
and use the padding instead on gcn.
2021-11-18 Jakub Jelinek <jakub@redhat.com>
PR libgomp/102838
* libgomp.h (GOMP_USE_ALIGNED_WORK_SHARES): Define if
GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC is defined and __AMDGCN__ is not.
(struct gomp_work_share): Use GOMP_USE_ALIGNED_WORK_SHARES instead of
GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC.
* work.c (alloc_work_share, gomp_work_share_start): Likewise.
* team.c (gomp_new_team): If GOMP_USE_ALIGNED_WORK_SHARES, use
gomp_aligned_alloc instead of team_malloc.
Diffstat (limited to 'libgomp/team.c')
-rw-r--r-- | libgomp/team.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libgomp/team.c b/libgomp/team.c index 3bcc817..19cc392 100644 --- a/libgomp/team.c +++ b/libgomp/team.c @@ -177,7 +177,12 @@ gomp_new_team (unsigned nthreads) { size_t extra = sizeof (team->ordered_release[0]) + sizeof (team->implicit_task[0]); +#ifdef GOMP_USE_ALIGNED_WORK_SHARES + team = gomp_aligned_alloc (__alignof (struct gomp_team), + sizeof (*team) + nthreads * extra); +#else team = team_malloc (sizeof (*team) + nthreads * extra); +#endif #ifndef HAVE_SYNC_BUILTINS gomp_mutex_init (&team->work_share_list_free_lock); |