Debian Codegraph @

gcc/testsuite/gfortran.dg/gomp/allocate-9.f90

raw
1 module m
2 use iso_c_binding
3 integer, parameter :: omp_allocator_handle_kind = c_intptr_t
4 integer (kind=omp_allocator_handle_kind), &
5 parameter :: omp_null_allocator = 0
6 integer (kind=omp_allocator_handle_kind), &
7 parameter :: omp_default_mem_alloc = 1
8 integer (kind=omp_allocator_handle_kind), &
9 parameter :: omp_large_cap_mem_alloc = 2
10 integer (kind=omp_allocator_handle_kind), &
11 parameter :: omp_const_mem_alloc = 3
12 integer (kind=omp_allocator_handle_kind), &
13 parameter :: omp_high_bw_mem_alloc = 4
14 integer (kind=omp_allocator_handle_kind), &
15 parameter :: omp_low_lat_mem_alloc = 5
16 integer (kind=omp_allocator_handle_kind), &
17 parameter :: omp_cgroup_mem_alloc = 6
18 integer (kind=omp_allocator_handle_kind), &
19 parameter :: omp_pteam_mem_alloc = 7
20 integer (kind=omp_allocator_handle_kind), &
21 parameter :: omp_thread_mem_alloc = 8
22 end
23
24
25 module m2
26 use m
27 implicit none
28 integer :: A(5) = [1,2,3,4,5], A2, A3, A4, A5
29 integer :: B, C, D
30
31 ! If the following fails because of added predefined allocators, please update
32 ! - c/c-parser.c's c_parser_omp_allocate
33 ! - fortran/openmp.cc's is_predefined_allocator
34 ! - libgomp/env.c's parse_allocator
35 ! - libgomp/libgomp.texi (document the new values - multiple locations)
36 ! + ensure that the memory-spaces are also up to date.
37
38 !$omp allocate(A) align(32) allocator(9_omp_allocator_handle_kind) ! { dg-error "Predefined allocator required in ALLOCATOR clause at .1. as the list item 'a' at .2. has the SAVE attribute" }
39
40 ! typo in allocator name:
41 !$omp allocate(A2) allocator(omp_low_latency_mem_alloc) ! { dg-error "Symbol 'omp_low_latency_mem_alloc' at .1. has no IMPLICIT type; did you mean 'omp_low_lat_mem_alloc'\\?" }
42 ! { dg-error "Predefined allocator required in ALLOCATOR clause at .1. as the list item 'a2' at .2. has the SAVE attribute" "" { target *-*-* } .-1 }
43
44 ! align be const multiple of 2
45 !$omp allocate(A3) align(31) allocator(omp_default_mem_alloc) ! { dg-error "ALIGN requires a scalar positive constant integer alignment expression at .1. that is a power of two" }
46
47 ! allocator missing (required as A is static)
48 !$omp allocate(A4) align(32) ! { dg-error "An ALLOCATOR clause is required as the list item 'a4' at .1. has the SAVE attribute" }
49
50 ! "expression in the clause must be a constant expression that evaluates to one of the
51 ! predefined memory allocator values -> omp_low_lat_mem_alloc"
52 !$omp allocate(B) allocator(omp_high_bw_mem_alloc+1_omp_allocator_handle_kind) align(32) ! OK: omp_low_lat_mem_alloc
53
54 !$omp allocate(C) allocator(2_omp_allocator_handle_kind) ! OK: omp_large_cap_mem_alloc
55
56 !$omp allocate(A5) align(32) allocator(omp_null_allocator) ! { dg-error "Predefined allocator required in ALLOCATOR clause at .1. as the list item 'a5' at .2. has the SAVE attribute" }
57
58 !$omp allocate(C) align(32) allocator(omp_large_cap_mem_alloc) ! { dg-error "Duplicated variable 'c' in !.OMP ALLOCATE at .1." }
59
60 contains
61
62 integer function f()
63 !$omp allocate(D) align(32) allocator(omp_large_cap_mem_alloc) ! { dg-error "Argument 'd' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" }
64 f = A(1)
65 end
66
67 integer function g()
68 integer :: a2, b2
69 !$omp allocate(a2)
70 !$omp allocate(a2) ! { dg-error "Duplicated variable 'a2' in !.OMP ALLOCATE at .1." }
71 a2=1; b2=2
72 block
73 integer :: c2
74 !$omp allocate(c2, b2) ! { dg-error "Argument 'b2' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" }
75 c2 = 3
76 g = c2+a2+b2
77 end block
78 end
79
80 integer function h(q)
81 integer :: q
82 !$omp allocate(q) ! { dg-error "Unexpected dummy argument 'q' as argument at .1. to declarative !.OMP ALLOCATE" }
83 h = q
84 end
85
86 integer function k ()
87 integer, save :: var3 = 8
88 !$omp allocate(var3) allocator(-1_omp_allocator_handle_kind) ! { dg-error "Predefined allocator required in ALLOCATOR clause at .1. as the list item 'var3' at .2. has the SAVE attribute" }
89 k = var3
90 end
91 end module
92
93
94 subroutine foo
95 integer :: a, b
96 integer :: c, d,h
97 !$omp allocate(a,b)
98 b = 1; d = 5
99 contains
100 subroutine internal
101 integer :: e,f
102 !$omp allocate(c,d)
103 ! { dg-error "Argument 'c' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" "" { target *-*-* } .-1 }
104 ! { dg-error "Argument 'd' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" "" { target *-*-* } .-2 }
105 !$omp allocate(e)
106 a = 1; c = 2; e = 4
107 block
108 !$omp allocate(f) ! { dg-error "Argument 'f' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" }
109 !$omp allocate(h) ! { dg-error "Argument 'h' at .1. to declarative !.OMP ALLOCATE shall be in the same scope as the variable declaration" }
110 end block
111 end
112 end