Debian Codegraph @

libgomp/testsuite/libgomp.fortran/reverse-offload-5.f90

raw
1 ! { dg-additional-options "-foffload-options=nvptx-none=-misa=sm_35" { target { offload_target_nvptx } } }
2 ! { dg-xfail-run-if "Copying on-device allocated memory fails with cuMemcpyDtoHAsync error: invalid argument" { offload_device_nvptx } }
3
4 ! Because of the nvptx fail, a non-device alloc version has been
5 ! created: reverse-offload-5a.f90
6
7 implicit none
8 !$omp requires reverse_offload
9
10 integer, allocatable :: A(:), A2(:), s1, s2
11 integer :: i
12 logical :: shared_mem
13
14 shared_mem = .false.
15
16 a = [1,2,3,4]
17 a2 = [8,7,6,5]
18 s1 = 532
19 s2 = 55
20
21 !$omp target map(to: shared_mem)
22 shared_mem = .true.
23 !$omp end target
24
25 !$omp target map(to: A, A2, s1, s2)
26 block
27 integer, allocatable :: ai(:), ai2(:), ai3(:), si1, si2, si3
28
29 a = a * 2
30 a2 = a2 * 3
31 s1 = s1 * 4
32 s2 = s2 * 5
33
34 ai = [23,35,86,43]
35 ai2 = [8,4,7,1]
36 si1 = 64
37 si2 = 765
38
39 !$omp target device (ancestor:1) &
40 !$omp& map(to: A, s1, ai, si1) map(always, to: a2, s2) &
41 !$omp& map(tofrom: ai2, si2, ai3, si3)
42 if (shared_mem) then
43 if (any (a /= 2 * [1,2,3,4])) stop 1
44 if (s1 /= 4 * 532) stop 2
45 else
46 if (any (a /= [1,2,3,4])) stop 3
47 if (s1 /= 532) stop 4
48 endif
49 if (any (a2 /= 3 * [8,7,6,5])) stop 5
50 if (s2 /= 5 * 55) stop 6
51 if (any (ai /= [23,35,86,43])) stop 7
52 if (any (ai2 /= [8,4,7,1])) stop 8
53 if (si1 /= 64) stop 9
54 if (si2 /= 765) stop 10
55 if (allocated (ai3) .or. allocated(si3)) stop 26
56
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
66
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 if (allocated (ai3) .or. allocated(si3)) stop 27
85
86 deallocate (ai, ai2, si1, si2)
87 end block
88
89 if (shared_mem) then
90 if (any (a /= 3 * 2 * [1,2,3,4])) stop 30
91 if (any (a2 /= 7 * 3 * [8,7,6,5])) stop 31
92 if (s1 /= 11 * 4 * 532) stop 32
93 if (s2 /= 5 * 5 * 55) stop 33
94 else
95 if (any (a /= 3 * [1,2,3,4])) stop 34
96 if (any (a2 /= 3 * 7 * [8,7,6,5])) stop 35
97 if (s1 /= 11 * 532) stop 36
98 if (s2 /= 5 * 5 * 55) stop 37
99 endif
100
101 deallocate (a, a2, s1, s2)
102 end