summaryrefslogtreecommitdiff
path: root/libgomp/omp.h.in
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-09-30 09:30:18 +0200
committerJakub Jelinek <jakub@redhat.com>2021-09-30 09:30:18 +0200
commitb38a4bd10249b5070ea1f4708a0fd228df268c26 (patch)
tree432fb7276617f8c2caae8723fa38e2f8a2b44e06 /libgomp/omp.h.in
parent257fd0333fe9fe5b0b4f9fddde50a09afa82b2ef (diff)
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.
Diffstat (limited to 'libgomp/omp.h.in')
-rw-r--r--libgomp/omp.h.in25
1 files changed, 22 insertions, 3 deletions
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index 314f964f841..e39988e7cbd 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -295,12 +295,31 @@ extern omp_allocator_handle_t omp_init_allocator (omp_memspace_handle_t,
extern void omp_destroy_allocator (omp_allocator_handle_t) __GOMP_NOTHROW;
extern void omp_set_default_allocator (omp_allocator_handle_t) __GOMP_NOTHROW;
extern omp_allocator_handle_t omp_get_default_allocator (void) __GOMP_NOTHROW;
-extern void *omp_alloc (__SIZE_TYPE__,
- omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
- __GOMP_NOTHROW __attribute__((__malloc__, __alloc_size__ (1)));
extern void omp_free (void *,
omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
__GOMP_NOTHROW;
+extern void *omp_alloc (__SIZE_TYPE__,
+ omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+ __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+ __alloc_size__ (1)));
+extern void *omp_aligned_alloc (__SIZE_TYPE__, __SIZE_TYPE__,
+ omp_allocator_handle_t
+ __GOMP_DEFAULT_NULL_ALLOCATOR)
+ __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+ __alloc_size__ (2)));
+extern void *omp_calloc (__SIZE_TYPE__, __SIZE_TYPE__,
+ omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+ __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+ __alloc_size__ (1, 2)));
+extern void *omp_aligned_calloc (__SIZE_TYPE__, __SIZE_TYPE__, __SIZE_TYPE__,
+ omp_allocator_handle_t
+ __GOMP_DEFAULT_NULL_ALLOCATOR)
+ __GOMP_NOTHROW __attribute__((__malloc__, __malloc__ (omp_free),
+ __alloc_size__ (2, 3)));
+extern void *omp_realloc (void *, __SIZE_TYPE__,
+ omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR,
+ omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR)
+ __GOMP_NOTHROW __attribute__((__malloc__ (omp_free), __alloc_size__ (2)));
extern void omp_display_env (int) __GOMP_NOTHROW;