Fix gcc.c-torture/execute/ieee/cdivchkf.c on hpux
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / reverse-offload-5a.f90
blob914d10d8144113592b2d35420fe763e590e0300f
1 ! { dg-additional-options "-foffload-options=nvptx-none=-misa=sm_35" { target { offload_target_nvptx } } }
3 ! Copying on-device allocated memory fails with cuMemcpyDtoHAsync error: invalid argument
4 ! Hence, reverse-offload-5.f90 has been copied to *this* file,
5 ! which uses on-host allocated vars - but only on the device side stack variables
7 implicit none
8 !$omp requires reverse_offload
10 integer, allocatable :: A(:), A2(:), s1, s2
11 integer :: i,D(4)
12 logical :: shared_mem
14 shared_mem = .false.
16 a = [1,2,3,4]
17 a2 = [8,7,6,5]
18 s1 = 532
19 s2 = 55
21 !$omp target map(to: shared_mem)
22 shared_mem = .true.
23 !$omp end target
25 !$omp target map(to: A, A2, s1, s2)
26 block
27 ! stack variables:
28 integer :: ai(4), ai2(4), si1, si2
30 a = a * 2
31 a2 = a2 * 3
32 s1 = s1 * 4
33 s2 = s2 * 5
35 ai = [23,35,86,43]
36 ai2 = [8,4,7,1]
37 si1 = 64
38 si2 = 765
40 !$omp target device (ancestor:1) &
41 !$omp& map(to: A, s1, ai, si1) map(always, to: a2, s2) &
42 !$omp& map(tofrom: ai2, si2)
43 if (shared_mem) then
44 if (any (a /= 2 * [1,2,3,4])) stop 1
45 if (s1 /= 4 * 532) stop 2
46 else
47 if (any (a /= [1,2,3,4])) stop 3
48 if (s1 /= 532) stop 4
49 endif
50 if (any (a2 /= 3 * [8,7,6,5])) stop 5
51 if (s2 /= 5 * 55) stop 6
52 if (any (ai /= [23,35,86,43])) stop 7
53 if (any (ai2 /= [8,4,7,1])) stop 8
54 if (si1 /= 64) stop 9
55 if (si2 /= 765) stop 10
57 a = a*3
58 a2 = a2*7
59 s1 = s1*11
60 s2 = s2*5
61 ai = ai*13
62 ai2 = ai2*21
63 si1 = si1*27
64 si2 = si2*31
65 !$omp end target
67 if (shared_mem) then
68 if (any (a /= 3 * 2 * [1,2,3,4])) stop 11
69 if (any (a2 /= 7 * 3 * [8,7,6,5])) stop 12
70 if (s1 /= 11 * 4 * 532) stop 13
71 if (s2 /= 5 * 5 * 55) stop 14
72 if (any (ai /= 13 * [23,35,86,43])) stop 15
73 if (si1 /= 27 * 64) stop 16
74 else
75 if (any (a /= 2 * [1,2,3,4])) stop 17
76 if (any (a2 /= 3 * [8,7,6,5])) stop 18
77 if (s1 /= 4 * 532) stop 19
78 if (s2 /= 5 * 55) stop 20
79 if (any (ai /= [23,35,86,43])) stop 22
80 if (si1 /= 64) stop 23
81 endif
82 if (any (ai2 /= 21 * [8,4,7,1])) stop 24
83 if (si2 /= 31 * 765) stop 25
84 end block
85 if (shared_mem) then
86 if (any (a /= 3 * 2 * [1,2,3,4])) stop 30
87 if (any (a2 /= 7 * 3 * [8,7,6,5])) stop 31
88 if (s1 /= 11 * 4 * 532) stop 32
89 if (s2 /= 5 * 5 * 55) stop 33
90 else
91 if (any (a /= 3 * [1,2,3,4])) stop 34
92 if (any (a2 /= 3 * 7 * [8,7,6,5])) stop 35
93 if (s1 /= 11 * 532) stop 36
94 if (s2 /= 5 * 5 * 55) stop 37
95 endif
97 deallocate (a, a2, s1, s2)
98 end