forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_async_target.2.f90
More file actions
45 lines (36 loc) · 1.06 KB
/
Example_async_target.2.f90
File metadata and controls
45 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
! @@name: async_target.2f
! @@type: F-free
! @@compilable: yes
! @@linkable: no
! @@expect: success
subroutine mult(p, N, idev)
use omp_lib, ONLY: omp_is_initial_device
real :: p(N)
real,allocatable :: v1(:), v2(:)
integer :: i, idev
!$omp declare target (init)
!$omp target data map(v1,v2)
!$omp task shared(v1,v2) depend(out: N)
!$omp target device(idev)
if( omp_is_initial_device() ) &
stop "not executing on target device"
allocate(v1(N), v2(N))
call init(v1,v2,N)
!$omp end target
!$omp end task
call foo() ! execute other work asychronously
!$omp task shared(v1,v2,p) depend(in: N)
!$omp target device(idev) map(from: p)
if( omp_is_initial_device() ) &
stop "not executing on target device"
!$omp parallel do
do i = 1,N
p(i) = v1(i) * v2(i)
end do
deallocate(v1,v2)
!$omp end target
!$omp end task
!$omp taskwait
!$omp end target data
call output(p, N)
end subroutine