]> gcc.gnu.org Git - gcc.git/commit
openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc
authorJakub Jelinek <jakub@redhat.com>
Thu, 30 Sep 2021 07:30:18 +0000 (09:30 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 30 Sep 2021 07:30:18 +0000 (09:30 +0200)
commitb38a4bd10249b5070ea1f4708a0fd228df268c26
tree432fb7276617f8c2caae8723fa38e2f8a2b44e06
parent257fd0333fe9fe5b0b4f9fddde50a09afa82b2ef
openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc

This patch adds new OpenMP 5.1 allocator entrypoints and in addition to that
fixes an omp_alloc bug which is hard to test for - if the first allocator
fails but has a larger alignment trait and has a fallback allocator, either
the default behavior or a user fallback, then the extra alignment will be used
even in the fallback allocation, rather than just starting with whatever
alignment has been requested (in GOMP_alloc or the minimum one in omp_alloc).

Jonathan's comment on IRC this morning made me realize that I should add
alloc_align attributes to 2 of the prototypes and I still need to add testsuite
coverage for omp_realloc, will do that in a follow-up.

2021-09-30  Jakub Jelinek  <jakub@redhat.com>

* omp.h.in (omp_aligned_alloc, omp_calloc, omp_aligned_calloc,
omp_realloc): New prototypes.
(omp_alloc): Move after omp_free prototype, add __malloc__ (omp_free)
attribute.
* allocator.c: Include string.h.
(omp_aligned_alloc): No longer static, add ialias.  Add new_alignment
variable and use it instead of alignment so that when retrying the old
alignment is used again.  Don't retry if new alignment is the same
as old alignment, unless allocator had pool size.
(omp_alloc, GOMP_alloc, GOMP_free): Use ialias_call.
(omp_aligned_calloc, omp_calloc, omp_realloc): New functions.
* libgomp.map (OMP_5.0.2): Export omp_aligned_alloc, omp_calloc,
omp_aligned_calloc and omp_realloc.
* testsuite/libgomp.c-c++-common/alloc-4.c (main): Add
omp_aligned_alloc, omp_calloc and omp_aligned_calloc tests.
* testsuite/libgomp.c-c++-common/alloc-5.c: New test.
* testsuite/libgomp.c-c++-common/alloc-6.c: New test.
* testsuite/libgomp.c-c++-common/alloc-7.c: New test.
* testsuite/libgomp.c-c++-common/alloc-8.c: New test.
libgomp/allocator.c
libgomp/libgomp.map
libgomp/omp.h.in
libgomp/testsuite/libgomp.c-c++-common/alloc-4.c
libgomp/testsuite/libgomp.c-c++-common/alloc-5.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/alloc-6.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/alloc-7.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/alloc-8.c [new file with mode: 0644]
This page took 0.062325 seconds and 5 git commands to generate.