Debian Codegraph @

libgomp/testsuite/libgomp.fortran/get-mapped-ptr-3.f90

raw
1 program main
2 use omp_lib
3 use iso_c_binding
4 implicit none (external, type)
5 integer :: d, id
6 type(c_ptr) :: p, p1, p2
7 integer, target :: a(1:0), b(1:2)
8
9 d = omp_get_default_device ()
10 id = omp_get_initial_device ()
11
12 if (d < 0 .or. d >= omp_get_num_devices ()) &
13 d = id
14
15 p = omp_target_alloc (c_sizeof (c_int), d)
16 if (.not. c_associated (p)) &
17 stop 0 ! okay
18
19 if (omp_target_associate_ptr (c_loc (a), p, c_sizeof (c_int), &
20 0_c_size_t, d) == 0) then
21
22 if(.not. c_associated (omp_get_mapped_ptr (c_loc (a), d), p)) &
23 stop 1
24
25 if (omp_target_disassociate_ptr (c_loc (a), d) /= 0) &
26 stop 2
27
28 if(c_associated (omp_get_mapped_ptr (c_loc (a), d))) &
29 stop 3
30
31 !$omp target data map(alloc: a) device(d)
32 !$omp target map(from: p1) map(alloc: a) device(d)
33 p1 = c_loc (a);
34 !$omp end target
35 if (c_associated (omp_get_mapped_ptr (c_loc (a), d))) &
36 stop 4
37 !$omp end target data
38
39 !$omp target data map(alloc: b(1:0)) device(d)
40 !$omp target map(from: p2) map(alloc: b(1:0)) device(d)
41 p2 = c_loc (b(1));
42 !$omp end target
43 if (c_associated (omp_get_mapped_ptr (c_loc (b(1)), d))) &
44 stop 5
45 !$omp end target data
46 end if
47 call omp_target_free (p, d)
48 end program main