Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    b38a4bd1
    openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc · b38a4bd1
    Jakub Jelinek authored
    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.
    b38a4bd1
    History
    openmp: Add omp_aligned_{,c}alloc and omp_{c,re}alloc
    Jakub Jelinek authored
    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.