Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions test/fortran-map-tests/lcompiler-1621-v1.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

program prog_a
implicit none
common/cblock_a/var_a
real(kind=8), dimension(100) :: var_a
!$omp declare target(/cblock_a/)
integer var_b

var_a = 1.0d0

!$omp target update to(/cblock_a/)

!$omp target teams distribute parallel do
do var_b = 1, 100
var_a(var_b) = var_a(var_b) * 2.0d0
enddo
!$omp end target teams distribute parallel do

!$omp target update from(/cblock_a/)

call verification(var_a, 2.0d0)

!$omp parallel do
do var_b = 1, 100
var_a(var_b) = var_a(var_b) * 2.0d0
enddo
!$omp end parallel do

call verification(var_a, 4.0d0)

print*, "======= FORTRAN Test Passed! ======="
end program

subroutine verification(var_c, var_d)
real(kind=8), dimension(100) :: var_c
real(kind=8) :: var_d
integer :: var_e

write(*,*) var_c

do var_e = 1, 100
if (var_c(var_e) /= var_d) then
print*, "======= FORTRAN Test Failed! ======="
stop 1
end if
enddo
end subroutine
45 changes: 45 additions & 0 deletions test/fortran-map-tests/lcompiler-1621-v2.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
program prog_a
implicit none
common/cblock_a/var_a
real(kind=8), dimension(100) :: var_a
!$omp declare target(/cblock_a/)
integer var_b

var_a = 1.0d0
!$omp target enter data map(always, to: var_a)

!$omp target teams distribute parallel do
do var_b = 1, 100
var_a(var_b) = var_a(var_b) * 2.0d0
enddo
!$omp end target teams distribute parallel do

!$omp target update from(var_a)

call verification(var_a, 2.0d0)

!$omp parallel do
do var_b = 1, 100
var_a(var_b) = var_a(var_b) * 2.0d0
enddo
!$omp end parallel do

call verification(var_a, 4.0d0)

print*, "======= FORTRAN Test Passed! ======="
end program

subroutine verification(var_c, var_d)
real(kind=8), dimension(100) :: var_c
real(kind=8) :: var_d
integer :: var_e

write(*,*) var_c

do var_e = 1, 100
if (var_c(var_e) /= var_d) then
print*, "======= FORTRAN Test Failed! ======="
stop 1
end if
enddo
end subroutine
44 changes: 44 additions & 0 deletions test/fortran-map-tests/michael-map-example-2.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
program prog_a
implicit none
type :: dtype_a
integer, dimension(:), allocatable :: var_a
end type
type(dtype_a), allocatable :: var_b
integer, parameter :: var_c = 128
integer :: var_d

allocate(var_b)
allocate(var_b%var_a(var_c))

var_b%var_a = -42

associate(var_e => var_b%var_a)
!$omp target enter data map(to:var_e)

associate(var_f => var_b%var_a)
!$omp target enter data map(to:var_f)

!$omp target teams distribute parallel do
do var_d = 1, var_c
var_f(var_d) = 42
end do
!$omp end target teams distribute parallel do

!$omp target exit data map(from:var_f)
end associate

!$omp target exit data map(from:var_e)
end associate

print 100, var_b%var_a
100 format (8I4)

do var_d = 1, var_c
if (var_b%var_a(var_d) /= 42) then
print*, "======= FORTRAN Test Failed! ======="
stop 1
end if
end do

print*, "======= FORTRAN Test Passed! ======="
end program prog_a
67 changes: 56 additions & 11 deletions test/fortran-map-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ echo "compiling michael-map-example.f90"

$AOMP/bin/flang --offload-arch=$AOMP_GPU -fopenmp michael-map-example.f90 -o michael-map-example.out

echo "compiling michael-map-example-2.f90"

$AOMP/bin/flang --offload-arch=$AOMP_GPU -fopenmp michael-map-example-2.f90 -o michael-map-example-2.out

echo "compiling target_map_common_block_1.f90"

$AOMP/bin/flang --offload-arch=$AOMP_GPU -fopenmp target_map_common_block_1.f90 -o target_map_common_block_1.out
Expand Down Expand Up @@ -805,6 +809,22 @@ echo "compiling SWDEV-579431.f90"

$AOMP/bin/flang -fopenmp -fopenmp-version=60 --offload-arch=$AOMP_GPU SWDEV-579431.f90 -o SWDEV-579431.out

echo "compiling lcompiler-1621-v1.f90"

$AOMP/bin/flang -fopenmp --offload-arch=$AOMP_GPU lcompiler-1621-v1.f90 -o lcompiler-1621-v1.out

echo "compiling lcompiler-1621-v1.f90 for usm"

$AOMP/bin/flang -fopenmp -fopenmp-force-usm --offload-arch=$AOMP_GPU lcompiler-1621-v1.f90 -o lcompiler-1621-v1-usm.out

echo "compiling lcompiler-1621-v2.f90"

$AOMP/bin/flang -fopenmp --offload-arch=$AOMP_GPU lcompiler-1621-v2.f90 -o lcompiler-1621-v2.out

echo "compiling lcompiler-1621-v2.f90 for usm"

$AOMP/bin/flang -fopenmp -fopenmp-force-usm --offload-arch=$AOMP_GPU lcompiler-1621-v2.f90 -o lcompiler-1621-v2-usm.out

echo "basic exp map"

echo "RUNNING TEST: basic-exp-map"
Expand Down Expand Up @@ -868,7 +888,7 @@ echo "RUNNING TEST: constant-index-in-target"
echo "Use of from to to map arrays and transfer values"

echo "RUNNING TEST: from-to"
./from-to.out
./from-to.out

echo "Use of complex value map from host to device"

Expand Down Expand Up @@ -908,22 +928,22 @@ echo "RUNNING TEST: simple-full-struct-implicit-2"
echo "Passing Fort pointer to Fort target and doing a simple loop assign"

echo "RUNNING TEST: pointer-target-map"
./pointer-target-map.out
./pointer-target-map.out

echo "Passing Fort pointer and doing a simple loop assign"

echo "RUNNING TEST: pointer-map"
./pointer-map.out
./pointer-map.out

echo "Passing Fort allocatable and doing a simple loop assign"

echo "RUNNING TEST: allocatable-map"
./allocatable-map.out
./allocatable-map.out

echo "Check array section with upper bound (write off end of array on device)"

echo "RUNNING TEST: array-section-1d-upperbound"
./array-section-1d-upperbound.out
./array-section-1d-upperbound.out

echo "N-D Bounds (3 dimensions) map syntax"

Expand Down Expand Up @@ -1083,12 +1103,12 @@ echo "RUNNING TEST: target-alloca-from-map"
echo "Target allocatable map with enter+exit binding, remap of same variable and function invocation "

echo "RUNNING TEST: enter-exit-break-test"
./enter-exit-break-test.out
./enter-exit-break-test.out

echo "Target allocatable map with enter+exit binding and re-map of same variable"

echo "RUNNING TEST: enter-exit-break-test-2"
./enter-exit-break-test-2.out
./enter-exit-break-test-2.out

echo "Target in function with allocatable in parameter allocated then assigned to inside of function utilising target"

Expand Down Expand Up @@ -1439,6 +1459,11 @@ echo "Example from Michael, arrays specified with dimensions contained in derive
echo "RUNNING TEST: michael-map-example"
./michael-map-example.out

echo "Example from Michael, usage of associate that add extra layers of obfuscation to the mappings, should return all 42"

echo "RUNNING TEST: michael-map-example-2"
./michael-map-example-2.out

echo "Map of full common block over multiple subroutines"

echo "RUNNING TEST: target_map_common_block_3"
Expand Down Expand Up @@ -1793,6 +1818,21 @@ echo "Actually tests that derived type allcoatable storage is correctly released
echo "RUNNING TEST: test_map_types_omp60"
./test_map_types_omp60.out

echo "lcompiler-1621-v1"

echo "RUNNING TEST: lcompiler-1621-v1"
./lcompiler-1621-v1.out

echo "lcompiler-1621-v2"

echo "RUNNING TEST: lcompiler-1621-v2"
./lcompiler-1621-v2.out

echo "SWDEV-579431 write-back issue caused by inter-mixing of implicit declare mapper"

echo "RUNNING TEST: SWDEV-579431"
./SWDEV-579431.out

# Tests that require XNACK/USM to pass

echo "test declare target enter/to usm works reasonably in simple cases"
Expand All @@ -1802,9 +1842,14 @@ export HSA_XNACK=1
echo "RUNNING TEST: declare-target-enter-usm"
./declare-target-enter-usm.out

unset HSA_XNACK
echo "lcompiler-1621-v1-usm"

echo "SWDEV-579431 write-back issue caused by inter-mixing of implicit declare mapper"
echo "RUNNING TEST: lcompiler-1621-v1-usm"
./lcompiler-1621-v1-usm.out

echo "RUNNING TEST: SWDEV-579431"
./SWDEV-579431.out
echo "lcompiler-1621-v2-usm"

echo "RUNNING TEST: lcompiler-1621-v2-usm"
./lcompiler-1621-v2-usm.out

unset HSA_XNACK
Loading