49 lines · plain
1! This test validates that declare mapper for a derived type with an2! allocatable component preserves TO/FROM semantics for the component,3! ensuring the payload is copied back to the host on target exit.4 5! REQUIRES: flang, amdgpu6 7! RUN: %libomptarget-compile-fortran-run-and-check-generic8 9program target_declare_mapper_allocatable10 implicit none11 12 type :: real_t13 real, allocatable :: real_arr(:)14 end type real_t15 16 ! Map the allocatable array payload via a named mapper.17 !$omp declare mapper (xyz : real_t :: t) map(tofrom: t%real_arr)18 19 type(real_t) :: r20 integer :: i21 logical :: ok22 23 allocate(r%real_arr(10))24 r%real_arr = 1.025 26 !$omp target map(mapper(xyz), tofrom: r)27 do i = 1, size(r%real_arr)28 r%real_arr(i) = 3.029 end do30 !$omp end target31 32 ok = .true.33 do i = 1, size(r%real_arr)34 if (r%real_arr(i) /= 3.0) ok = .false.35 end do36 if (ok) then37 print *, "Test passed!"38 else39 print *, "Test failed!"40 do i = 1, size(r%real_arr)41 print *, r%real_arr(i)42 end do43 end if44 45 deallocate(r%real_arr)46end program target_declare_mapper_allocatable47 48! CHECK: Test passed!49