Skip to content

Commit 1721b2b

Browse files
committed
Revision 2: adding runtime test, fixing comment
1 parent d1fe42b commit 1721b2b

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
11211121
eleType = refType.getElementType();
11221122

11231123
// If a variable is specified in declare target link and if device
1124-
// type is nohost, it needs to be mapped tofrom
1124+
// type is not specified as `nohost`, it needs to be mapped tofrom
11251125
mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
11261126
mlir::Operation *op = mod.lookupSymbol(converter.mangleName(sym));
11271127
auto declareTargetOp =

openmp/libomptarget/test/offloading/fortran/declare-target-array-in-target-region.f90

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,59 @@
1111
! RUN: %libomptarget-compile-fortran-run-and-check-generic
1212
module test_0
1313
implicit none
14-
INTEGER :: sp(10) = (/0,0,0,0,0,0,0,0,0,0/)
15-
!$omp declare target link(sp)
14+
INTEGER :: arr1(10) = (/0,0,0,0,0,0,0,0,0,0/)
15+
INTEGER :: arr2(10) = (/0,0,0,0,0,0,0,0,0,0/)
16+
!$omp declare target link(arr1) enter(arr2)
1617
end module test_0
1718

18-
program main
19+
subroutine test_with_array_link_and_tofrom()
1920
use test_0
2021
integer :: i = 1
2122
integer :: j = 11
22-
!$omp target map(tofrom:sp, i, j)
23+
!$omp target map(tofrom:arr1, i, j)
2324
do while (i <= j)
24-
sp(i) = i;
25+
arr1(i) = i;
2526
i = i + 1
2627
end do
2728
!$omp end target
2829

29-
PRINT *, sp(:)
30+
! CHECK: 1 2 3 4 5 6 7 8 9 10
31+
PRINT *, arr1(:)
32+
end subroutine test_with_array_link_and_tofrom
3033

31-
end program
34+
subroutine test_with_array_link_only()
35+
use test_0
36+
integer :: i = 1
37+
integer :: j = 11
38+
!$omp target map(i, j)
39+
do while (i <= j)
40+
arr1(i) = i + 1;
41+
i = i + 1
42+
end do
43+
!$omp end target
3244

33-
! CHECK: 1 2 3 4 5 6 7 8 9 10
45+
! CHECK: 2 3 4 5 6 7 8 9 10 11
46+
PRINT *, arr1(:)
47+
end subroutine test_with_array_link_only
48+
49+
subroutine test_with_array_enter_only()
50+
use test_0
51+
integer :: i = 1
52+
integer :: j = 11
53+
!$omp target map(i, j)
54+
do while (i <= j)
55+
arr2(i) = i + 1;
56+
i = i + 1
57+
end do
58+
!$omp end target
59+
60+
! CHECK: 0 0 0 0 0 0 0 0 0 0
61+
PRINT *, arr2(:)
62+
end subroutine test_with_array_enter_only
63+
64+
65+
program main
66+
call test_with_array_link_and_tofrom()
67+
call test_with_array_link_only()
68+
call test_with_array_enter_only()
69+
end program

0 commit comments

Comments
 (0)