1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! Check OpenMP declarative directives
5 !TODO: all internal errors
6 ! enable declare-reduction example after name resolution
10 subroutine requires_1(a
)
11 real(8), intent(inout
) :: a
12 !$omp requires reverse_offload, unified_shared_memory, atomic_default_mem_order(relaxed)
14 end subroutine requires_1
16 subroutine requires_2(a
)
17 real(8), intent(inout
) :: a
18 !$omp requires unified_address
20 end subroutine requires_2
24 subroutine declare_simd_1(a
, b
)
25 real(8), intent(inout
) :: a
, b
26 !$omp declare simd(declare_simd_1) aligned(a)
28 end subroutine declare_simd_1
33 integer, intent(in
)::x
34 integer, intent(in
)::y
39 subroutine declare_simd_2
42 !ERROR: NOTINBRANCH and INBRANCH clauses are mutually exclusive and may not appear on the same DECLARE SIMD directive
43 !$omp declare simd(sub1) inbranch notinbranch
44 procedure (sub
), pointer::p
47 end subroutine declare_simd_2
50 integer, intent(in
)::x
, y
54 ! 2.10.6 declare-target
55 ! 2.15.2 threadprivate
61 !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
62 !WARNING: The entity with PARAMETER attribute is used in a DECLARE TARGET directive
63 !$omp declare target (foo, N, M)
64 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
65 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
66 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
67 !$omp declare target to(Q, S) link(R)
68 !ERROR: MAP clause is not allowed on the DECLARE TARGET directive
69 !$omp declare target map(from:Q)
70 integer, parameter :: N
=10000, M
=1024
72 real :: Q(N
, N
), R(N
,M
), S(M
,M
)
73 !ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
74 !$omp threadprivate(i)
78 ! 2.16 declare-reduction
80 ! subroutine declare_red_1()
83 ! !$omp declare reduction (my_add_red : integer : omp_out = omp_out + omp_in) initializer (omp_priv=0)
85 ! !$omp parallel reduction (my_add_red : my_var) num_threads(4)
86 ! my_var = omp_get_thread_num() + 1
88 ! print *, "sum of thread numbers is ", my_var
89 ! end subroutine declare_red_1