Skip to content

Commit e776601

Browse files
committed
R3: Reformatting test cases, adding a scalar test
1 parent 1721b2b commit e776601

File tree

3 files changed

+116
-104
lines changed

3 files changed

+116
-104
lines changed

flang/test/Lower/OpenMP/declare-target-link-tarop-cap.f90

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,51 @@
55

66
program test_link
77

8-
integer :: test_int = 1
9-
!$omp declare target link(test_int)
8+
integer :: test_int = 1
9+
!$omp declare target link(test_int)
1010

11-
integer :: test_array_1d(3) = (/1,2,3/)
12-
!$omp declare target link(test_array_1d)
11+
integer :: test_array_1d(3) = (/1,2,3/)
12+
!$omp declare target link(test_array_1d)
1313

14-
integer, pointer :: test_ptr1
15-
!$omp declare target link(test_ptr1)
14+
integer, pointer :: test_ptr1
15+
!$omp declare target link(test_ptr1)
1616

17-
integer, target :: test_target = 1
18-
!$omp declare target link(test_target)
17+
integer, target :: test_target = 1
18+
!$omp declare target link(test_target)
1919

20-
integer, pointer :: test_ptr2
21-
!$omp declare target link(test_ptr2)
20+
integer, pointer :: test_ptr2
21+
!$omp declare target link(test_ptr2)
2222

23-
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_int"}
24-
!$omp target
25-
test_int = test_int + 1
26-
!$omp end target
23+
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_int"}
24+
!$omp target
25+
test_int = test_int + 1
26+
!$omp end target
2727

2828

29-
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.array<3xi32>>, !fir.array<3xi32>) map_clauses(implicit, tofrom) capture(ByRef) bounds({{%.*}}) -> !fir.ref<!fir.array<3xi32>> {name = "test_array_1d"}
30-
!$omp target
31-
do i = 1,3
32-
test_array_1d(i) = i * 2
33-
end do
34-
!$omp end target
29+
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.array<3xi32>>, !fir.array<3xi32>) map_clauses(implicit, tofrom) capture(ByRef) bounds({{%.*}}) -> !fir.ref<!fir.array<3xi32>> {name = "test_array_1d"}
30+
!$omp target
31+
do i = 1,3
32+
test_array_1d(i) = i * 2
33+
end do
34+
!$omp end target
3535

36-
allocate(test_ptr1)
37-
test_ptr1 = 1
38-
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(implicit, tofrom) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr1"}
39-
!$omp target
40-
test_ptr1 = test_ptr1 + 1
41-
!$omp end target
36+
allocate(test_ptr1)
37+
test_ptr1 = 1
38+
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(implicit, tofrom) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr1"}
39+
!$omp target
40+
test_ptr1 = test_ptr1 + 1
41+
!$omp end target
4242

43-
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_target"}
44-
!$omp target
45-
test_target = test_target + 1
46-
!$omp end target
43+
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<i32>, i32) map_clauses(implicit, tofrom) capture(ByRef) -> !fir.ref<i32> {name = "test_target"}
44+
!$omp target
45+
test_target = test_target + 1
46+
!$omp end target
4747

4848

49-
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(implicit, tofrom) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr2"}
50-
test_ptr2 => test_target
51-
!$omp target
52-
test_ptr2 = test_ptr2 + 1
53-
!$omp end target
49+
!CHECK-DAG: {{%.*}} = omp.map_info var_ptr({{%.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(implicit, tofrom) capture(ByRef) members({{%.*}} : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "test_ptr2"}
50+
test_ptr2 => test_target
51+
!$omp target
52+
test_ptr2 = test_ptr2 + 1
53+
!$omp end target
5454

5555
end

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

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
! Offloading test with a target region mapping a declare target
2+
! Fortran array writing some values to it and checking the host
3+
! correctly receives the updates made on the device.
4+
! REQUIRES: flang
5+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
6+
! UNSUPPORTED: aarch64-unknown-linux-gnu
7+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
8+
! UNSUPPORTED: x86_64-pc-linux-gnu
9+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
10+
11+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
12+
module test_0
13+
implicit none
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)
17+
INTEGER :: scalar = 1
18+
!$omp declare target link(scalar)
19+
end module test_0
20+
21+
subroutine test_with_array_link_and_tofrom()
22+
use test_0
23+
integer :: i = 1
24+
integer :: j = 11
25+
!$omp target map(tofrom:arr1, i, j)
26+
do while (i <= j)
27+
arr1(i) = i;
28+
i = i + 1
29+
end do
30+
!$omp end target
31+
32+
! CHECK: 1 2 3 4 5 6 7 8 9 10
33+
PRINT *, arr1(:)
34+
end subroutine test_with_array_link_and_tofrom
35+
36+
subroutine test_with_array_link_only()
37+
use test_0
38+
integer :: i = 1
39+
integer :: j = 11
40+
!$omp target map(i, j)
41+
do while (i <= j)
42+
arr1(i) = i + 1;
43+
i = i + 1
44+
end do
45+
!$omp end target
46+
47+
! CHECK: 2 3 4 5 6 7 8 9 10 11
48+
PRINT *, arr1(:)
49+
end subroutine test_with_array_link_only
50+
51+
subroutine test_with_array_enter_only()
52+
use test_0
53+
integer :: i = 1
54+
integer :: j = 11
55+
!$omp target map(i, j)
56+
do while (i <= j)
57+
arr2(i) = i + 1;
58+
i = i + 1
59+
end do
60+
!$omp end target
61+
62+
! CHECK: 0 0 0 0 0 0 0 0 0 0
63+
PRINT *, arr2(:)
64+
end subroutine test_with_array_enter_only
65+
66+
subroutine test_with_scalar_link_only()
67+
use test_0
68+
!$omp target
69+
scalar = 10
70+
!$omp end target
71+
72+
! CHECK: 10
73+
PRINT *, scalar
74+
end subroutine test_with_scalar_link_only
75+
76+
program main
77+
call test_with_array_link_and_tofrom()
78+
call test_with_array_link_only()
79+
call test_with_array_enter_only()
80+
call test_with_scalar_link_only()
81+
end program

0 commit comments

Comments
 (0)