| 1 |
! { dg-additional-options "-fopenmp-allocators" } |
| 2 |
! { dg-additional-options "-fdump-tree-omplower" } |
| 3 |
program main |
| 4 |
use iso_c_binding |
| 5 |
use omp_lib |
| 6 |
implicit none (type, external) |
| 7 |
integer(omp_allocator_handle_kind):: alloc_h |
| 8 |
integer :: i, N |
| 9 |
integer(c_intptr_t) :: intptr |
| 10 |
integer, allocatable :: A(:) |
| 11 |
type(omp_alloctrait):: traits(1) = [omp_alloctrait(omp_atk_alignment, 128)] |
| 12 |
|
| 13 |
N = 10 |
| 14 |
alloc_h = omp_init_allocator(omp_default_mem_space, 1, traits) |
| 15 |
|
| 16 |
!$omp allocate(A) allocator(alloc_h) |
| 17 |
allocate(A(N)) |
| 18 |
a(:) = [(i, i=1,N)] |
| 19 |
if (mod (transfer (loc(a), intptr),128) /= 0) & |
| 20 |
stop 1 |
| 21 |
if (any (a /= [(i, i=1,N)])) & |
| 22 |
stop 2 |
| 23 |
deallocate(A) |
| 24 |
!$omp allocate(A) allocator(alloc_h) align(512) |
| 25 |
allocate(A(N)) |
| 26 |
block |
| 27 |
integer, allocatable :: B(:) |
| 28 |
!$omp allocators allocate(allocator(alloc_h), align(256) : B) |
| 29 |
allocate(B(N)) |
| 30 |
B(:) = [(2*i, i=1,N)] |
| 31 |
A(:) = B |
| 32 |
if (mod (transfer (loc(B), intptr), 256) /= 0) & |
| 33 |
stop 1 |
| 34 |
! end of scope deallocation |
| 35 |
end block |
| 36 |
if (mod (transfer (loc(a), intptr),512) /= 0) & |
| 37 |
stop 1 |
| 38 |
if (any (a /= [(2*i, i=1,N)])) & |
| 39 |
stop 2 |
| 40 |
deallocate(A) ! Must deallocate here - before deallocator is destroyed |
| 41 |
call omp_destroy_allocator(alloc_h) |
| 42 |
! No auto dealloc of A because it is SAVE |
| 43 |
end |
| 44 |
! { dg-final { scan-tree-dump-times "__builtin_GOMP_alloc \\(" 3 "omplower" } } |
| 45 |
! { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(" 3 "omplower" } } |