Debian Codegraph @

libgomp/testsuite/libgomp.fortran/examples-4/declare_target-2.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-sources ../on_device_arch.c }
3 ! { dg-additional-options -Wno-complain-wrong-lang }
4
5 program e_53_2
6 !$omp declare target (fib)
7 integer :: x, fib
8 integer :: REC_DEPTH = 25
9
10 interface
11 integer function on_device_arch_nvptx() bind(C)
12 end function on_device_arch_nvptx
13 end interface
14
15 if (on_device_arch_nvptx () /= 0) then
16 ! Reduced from 25 to 23, otherwise execution runs out of thread stack on
17 ! Nvidia Titan V.
18 ! Reduced from 23 to 22, otherwise execution runs out of thread stack on
19 ! Nvidia T400 (2GB variant), when run with GOMP_NVPTX_JIT=-O0.
20 ! Reduced from 22 to 18, otherwise execution runs out of thread stack on
21 ! Nvidia RTX A2000 (6GB variant), when run with GOMP_NVPTX_JIT=-O0.
22 REC_DEPTH = 18
23 end if
24
25 !$omp target map(from: x)
26 x = fib (REC_DEPTH)
27 !$omp end target
28 if (x /= fib (REC_DEPTH)) stop 1
29 end program
30
31 integer recursive function fib (n) result (f)
32 !$omp declare target
33 integer :: n
34 if (n <= 0) then
35 f = 0
36 else if (n == 1) then
37 f = 1
38 else
39 f = fib (n - 1) + fib (n - 2)
40 end if
41 end function