Debian Codegraph @

libgomp/testsuite/libgomp.fortran/allocators-1.f90

raw
1 ! { dg-additional-options "-fopenmp-allocators -fdump-tree-original" }
2 module m
3 use omp_lib
4 use iso_c_binding, only: c_intptr_t
5 implicit none (type,external)
6 integer(omp_allocator_handle_kind) :: handle
7 integer(c_intptr_t) :: iptr
8 end module m
9
10 subroutine scalar
11 use m
12 implicit none (type,external)
13 integer :: i
14 integer, allocatable :: SSS
15 i = 5 ! required executive statement before 'omp allocators'
16 !$omp allocate allocator(handle)
17 allocate(SSS)
18 if (mod (loc (sss), 64) /= 0) stop 1
19 deallocate(SSS)
20 allocate(SSS)
21 end
22 ! { dg-final { scan-tree-dump-times "sss = \\(integer\\(kind=4\\) \\*\\) __builtin_GOMP_alloc \\(4, 4, D\\.\[0-9\]+\\);" 1 "original" } }
23 ! { dg-final { scan-tree-dump-times "GOMP_add_alloc \\(sss\\);" 1 "original" } }
24 ! { dg-final { scan-tree-dump-times "if \\(GOMP_is_alloc \\(sss\\)\\)" 2 "original" } }
25 ! { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(sss, 0B\\);" 2 "original" } }
26
27 subroutine array
28 use m
29 implicit none (type,external)
30 integer :: i
31 integer, allocatable :: A(:)
32 i = 5 ! required executive statement before 'omp allocators'
33 !$omp allocate allocator(handle) align(512)
34 allocate(A(5))
35 if (mod (loc (A), 512) /= 0) stop 2
36 A=[1]
37 if (mod (loc (A), 64) /= 0) stop 3
38 deallocate(A)
39 A=[1]
40 deallocate(A)
41 call omp_set_default_allocator (handle)
42 !$omp allocate
43 allocate(A(7))
44 if (mod (loc (A), 64) /= 0) stop 4
45 end
46 ! { dg-final { scan-tree-dump-times "a.dtype = {.elem_len=4, .version=0, .rank=1, .type=1};" 5 "original" } }
47 ! { dg-final { scan-tree-dump-times "\\.elem_len=4" 5 "original" } }
48 ! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) __builtin_GOMP_alloc \\(512, 20, D\\.\[0-9\]+\\);" 1 "original" } }
49 ! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) __builtin_GOMP_alloc \\(4, 28, 0B\\);" 1 "original" } }
50 ! { dg-final { scan-tree-dump-times "a.dtype.version = 1;" 2 "original" } }
51 ! { dg-final { scan-tree-dump-times "a.data = \\(void \\* restrict\\) \\(a.dtype.version == 1 \\? __builtin_omp_realloc \\(\\(void \\*\\) a.data, 4, 0B, 0B\\) : __builtin_realloc \\(\\(void \\*\\) a.data, 4\\)\\);" 2 "original" } }
52 ! { dg-final { scan-tree-dump-times "if \\(a.dtype.version == 1\\)" 3 "original" } }
53 ! { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(\\(integer\\(kind=4\\)\\\[0:\\\] \\* restrict\\) a.data, 0B\\);" 3 "original" } }
54 ! { dg-final { scan-tree-dump-times "a.dtype.version = 0;" 3 "original" } }
55
56 program main
57 use m
58 implicit none (type,external)
59 external :: scalar, array
60 type (omp_alloctrait), parameter :: traits(*) &
61 = [omp_alloctrait(omp_atk_sync_hint, omp_atv_contended), &
62 omp_alloctrait(omp_atk_alignment, 64)]
63 handle = omp_init_allocator (omp_high_bw_mem_alloc, size(traits), traits)
64 call scalar
65 call array
66 call omp_destroy_allocator (handle)
67 end
68