Skip to content

Commit ee0706a

Browse files
ergawyronlieb
authored andcommitted
[flang][do concurent] Add saxpy offload tests for OpenMP mapping
1 parent 3424d57 commit ee0706a

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
! REQUIRES: flang, amdgpu
2+
3+
! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device
4+
! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic
5+
module saxpymod
6+
use iso_fortran_env
7+
public :: saxpy
8+
contains
9+
10+
subroutine saxpy(a, x, y, n, m)
11+
use iso_fortran_env
12+
implicit none
13+
integer,intent(in) :: n, m
14+
real(kind=real32),intent(in) :: a
15+
real(kind=real32), dimension(:,:),intent(in) :: x
16+
real(kind=real32), dimension(:,:),intent(inout) :: y
17+
integer :: i, j
18+
19+
do concurrent(i=1:n, j=1:m)
20+
y(i,j) = a * x(i,j) + y(i,j)
21+
end do
22+
23+
write(*,*) "plausibility check:"
24+
write(*,'("y(1,1) ",f8.6)') y(1,1)
25+
write(*,'("y(n,m) ",f8.6)') y(n,m)
26+
end subroutine saxpy
27+
28+
end module saxpymod
29+
30+
program main
31+
use iso_fortran_env
32+
use saxpymod, ONLY:saxpy
33+
implicit none
34+
35+
integer,parameter :: n = 1000, m=10000
36+
real(kind=real32), allocatable, dimension(:,:) :: x, y
37+
real(kind=real32) :: a
38+
integer :: i
39+
40+
allocate(x(1:n,1:m), y(1:n,1:m))
41+
a = 2.0_real32
42+
x(:,:) = 1.0_real32
43+
y(:,:) = 2.0_real32
44+
45+
call saxpy(a, x, y, n, m)
46+
47+
deallocate(x,y)
48+
end program main
49+
50+
! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}}
51+
! CHECK: plausibility check:
52+
! CHECK: y(1,1) 4.0
53+
! CHECK: y(n,m) 4.0
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
! REQUIRES: flang, amdgpu
2+
3+
! RUN: %libomptarget-compile-fortran-generic -fdo-concurrent-to-openmp=device
4+
! RUN: env LIBOMPTARGET_INFO=16 %libomptarget-run-generic 2>&1 | %fcheck-generic
5+
module saxpymod
6+
use iso_fortran_env
7+
public :: saxpy
8+
contains
9+
10+
subroutine saxpy(a, x, y, n)
11+
use iso_fortran_env
12+
implicit none
13+
integer,intent(in) :: n
14+
real(kind=real32),intent(in) :: a
15+
real(kind=real32), dimension(:),intent(in) :: x
16+
real(kind=real32), dimension(:),intent(inout) :: y
17+
integer :: i
18+
19+
do concurrent(i=1:n)
20+
y(i) = a * x(i) + y(i)
21+
end do
22+
23+
write(*,*) "plausibility check:"
24+
write(*,'("y(1) ",f8.6)') y(1)
25+
write(*,'("y(n) ",f8.6)') y(n)
26+
end subroutine saxpy
27+
28+
end module saxpymod
29+
30+
program main
31+
use iso_fortran_env
32+
use saxpymod, ONLY:saxpy
33+
implicit none
34+
35+
integer,parameter :: n = 10000000
36+
real(kind=real32), allocatable, dimension(:) :: x, y
37+
real(kind=real32) :: a
38+
integer :: i
39+
40+
allocate(x(1:n), y(1:n))
41+
a = 2.0_real32
42+
x(:) = 1.0_real32
43+
y(:) = 2.0_real32
44+
45+
call saxpy(a, x, y, n)
46+
47+
deallocate(x,y)
48+
end program main
49+
50+
! CHECK: "PluginInterface" device {{[0-9]+}} info: Launching kernel {{.*}}
51+
! CHECK: plausibility check:
52+
! CHECK: y(1) 4.0
53+
! CHECK: y(n) 4.0

0 commit comments

Comments
 (0)