mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-10 16:32:11 +01:00
30 lines
576 B
Fortran
30 lines
576 B
Fortran
! @@name: declare_target.7
|
|
! @@type: F-free
|
|
! @@operation: link
|
|
! @@expect: success
|
|
! @@version: omp_5.2
|
|
module subs
|
|
|
|
contains
|
|
subroutine foo()
|
|
!$omp declare target enter(foo) device_type(nohost)
|
|
!$omp declare variant(foo_onhost) match(device={kind(host)})
|
|
! device specific computation
|
|
end subroutine
|
|
|
|
subroutine foo_onhost()
|
|
print *,' On host.'
|
|
end subroutine
|
|
|
|
end module
|
|
|
|
program main
|
|
|
|
use subs
|
|
!$omp target
|
|
call foo ! calls foo() on device
|
|
! or foo_onhost() in case of host fallback
|
|
!$omp end target
|
|
|
|
end program
|