2016-01-14 Edward Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / fortran.exp
blob2d6b647af227a9e84f791843284fb658a8a0a34b
1 # This whole file adapted from libgomp.fortran/fortran.exp.
3 load_lib libgomp-dg.exp
4 load_gcc_lib gcc-dg.exp
5 load_gcc_lib gfortran-dg.exp
7 global shlib_ext
8 global ALWAYS_CFLAGS
10 set shlib_ext [get_shlib_extension]
11 set lang_library_path "../libgfortran/.libs"
12 set lang_link_flags "-lgfortran"
13 if [info exists lang_include_flags] then {
14 unset lang_include_flags
16 set lang_test_file_found 0
17 set quadmath_library_path "../libquadmath/.libs"
20 # Initialize dg.
21 dg-init
23 # Turn on OpenACC.
24 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
26 if { $blddir != "" } {
27 set lang_source_re {^.*\.[fF](|90|95|03|08)$}
28 set lang_include_flags "-fintrinsic-modules-path=${blddir}"
29 # Look for a static libgfortran first.
30 if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
31 set lang_test_file "${lang_library_path}/libgfortran.a"
32 set lang_test_file_found 1
33 # We may have a shared only build, so look for a shared libgfortran.
34 } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
35 set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
36 set lang_test_file_found 1
37 } else {
38 puts "No libgfortran library found, will not execute fortran tests"
40 } elseif [info exists GFORTRAN_UNDER_TEST] {
41 set lang_test_file_found 1
42 # Needs to exist for libgomp.exp.
43 set lang_test_file ""
44 } else {
45 puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
48 if { $lang_test_file_found } {
49 # Gather a list of all tests.
50 set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
52 if { $blddir != "" } {
53 if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
54 || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
55 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
56 # Allow for spec subsitution.
57 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
58 set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
59 } else {
60 set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
62 } else {
63 set ld_library_path "$always_ld_library_path"
65 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
66 set_ld_library_path_env_vars
68 # Test OpenACC with available accelerators.
69 foreach offload_target_openacc $offload_targets_s_openacc {
70 set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
72 switch $offload_target_openacc {
73 host {
74 set acc_mem_shared 1
76 nvidia {
77 if { ![check_effective_target_openacc_nvidia_accel_present] } {
78 # Don't bother; execution testing is going to FAIL.
79 untested "$subdir $offload_target_openacc offloading"
80 continue
83 set acc_mem_shared 0
85 default {
86 set acc_mem_shared 0
89 set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
91 setenv ACC_DEVICE_TYPE $offload_target_openacc
93 # For Fortran we're doing torture testing, as Fortran has far more tests
94 # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
95 # typically not the case for C/C++.
96 gfortran-dg-runtest $tests "$tagopt" ""
100 # All done.
101 dg-finish