| 1 |
# This whole file adapted from libgomp.fortran/fortran.exp. |
| 2 |
|
| 3 |
load_lib libgomp-dg.exp |
| 4 |
load_gcc_lib gcc-dg.exp |
| 5 |
load_gcc_lib gfortran-dg.exp |
| 6 |
|
| 7 |
if { $blddir != "" } { |
| 8 |
set libgfortran_library_path "../libgfortran/.libs" |
| 9 |
set shlib_ext [get_shlib_extension] |
| 10 |
if { ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.a"] |
| 11 |
&& ![file exists "${blddir}/${libgfortran_library_path}/libgfortran.${shlib_ext}"] } { |
| 12 |
verbose -log "No libgfortran library found, will not execute fortran tests" |
| 13 |
unset libgfortran_library_path |
| 14 |
return |
| 15 |
} |
| 16 |
lappend lang_library_paths $libgfortran_library_path |
| 17 |
|
| 18 |
set libquadmath_library_path "../libquadmath/.libs" |
| 19 |
if { [file exists "${blddir}/${libquadmath_library_path}/libquadmath.a"] |
| 20 |
|| [file exists "${blddir}/${libquadmath_library_path}/libquadmath.${shlib_ext}"] } { |
| 21 |
lappend lang_library_paths $libquadmath_library_path |
| 22 |
} else { |
| 23 |
set libquadmath_library_path "" |
| 24 |
} |
| 25 |
} elseif { ![info exists GFORTRAN_UNDER_TEST] } { |
| 26 |
verbose -log "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests" |
| 27 |
return |
| 28 |
} |
| 29 |
if { $blddir != "" } { |
| 30 |
set lang_source_re {^.*\.[fF](|90|95|03|08)$} |
| 31 |
set lang_include_flags "-fintrinsic-modules-path=${blddir}" |
| 32 |
} |
| 33 |
lappend ALWAYS_CFLAGS "compiler=$GFORTRAN_UNDER_TEST" |
| 34 |
|
| 35 |
# Initialize dg. |
| 36 |
dg-init |
| 37 |
|
| 38 |
# Turn on OpenACC. |
| 39 |
lappend ALWAYS_CFLAGS "additional_flags=-fopenacc" |
| 40 |
|
| 41 |
|
| 42 |
# Gather a list of all tests. |
| 43 |
set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]] |
| 44 |
|
| 45 |
set ld_library_path $always_ld_library_path |
| 46 |
if { $blddir != "" } { |
| 47 |
append ld_library_path ":${blddir}/${libgfortran_library_path}" |
| 48 |
|
| 49 |
if { $libquadmath_library_path != "" } { |
| 50 |
append ld_library_path ":${blddir}/${libquadmath_library_path}" |
| 51 |
} |
| 52 |
} |
| 53 |
append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] |
| 54 |
set_ld_library_path_env_vars |
| 55 |
|
| 56 |
# Test with all available offload targets, and with offloading disabled. |
| 57 |
foreach offload_target [concat [split $offload_targets ","] "disable"] { |
| 58 |
global openacc_device_type |
| 59 |
set openacc_device_type [offload_target_to_openacc_device_type $offload_target] |
| 60 |
set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1" |
| 61 |
|
| 62 |
switch $openacc_device_type { |
| 63 |
"" { |
| 64 |
unsupported "$subdir $offload_target offloading" |
| 65 |
continue |
| 66 |
} |
| 67 |
host { |
| 68 |
set acc_mem_shared 1 |
| 69 |
} |
| 70 |
nvidia { |
| 71 |
if { ![check_effective_target_openacc_nvidia_accel_present] } { |
| 72 |
# Don't bother; execution testing is going to FAIL. |
| 73 |
untested "$subdir $offload_target offloading: supported, but hardware not accessible" |
| 74 |
continue |
| 75 |
} |
| 76 |
|
| 77 |
set acc_mem_shared 0 |
| 78 |
} |
| 79 |
radeon { |
| 80 |
if { ![check_effective_target_openacc_radeon_accel_present] } { |
| 81 |
# Don't bother; execution testing is going to FAIL. |
| 82 |
untested "$subdir $offload_target offloading: supported, but hardware not accessible" |
| 83 |
continue |
| 84 |
} |
| 85 |
|
| 86 |
set acc_mem_shared 0 |
| 87 |
} |
| 88 |
default { |
| 89 |
error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)" |
| 90 |
} |
| 91 |
} |
| 92 |
set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared" |
| 93 |
|
| 94 |
# To avoid compilation overhead, and to keep simple '-foffload=[...]' |
| 95 |
# handling in test cases, by default only build for the offload target |
| 96 |
# that we're actually going to test. |
| 97 |
set tagopt "$tagopt -foffload=$offload_target" |
| 98 |
# Force usage of the corresponding OpenACC device type. |
| 99 |
setenv ACC_DEVICE_TYPE $openacc_device_type |
| 100 |
|
| 101 |
# For Fortran we're doing torture testing, as Fortran has far more tests |
| 102 |
# with arrays etc. that testing just -O0 or -O2 is insufficient, that is |
| 103 |
# typically not the case for C/C++. |
| 104 |
gfortran-dg-runtest $tests "$tagopt" "" |
| 105 |
} |
| 106 |
unset offload_target |
| 107 |
|
| 108 |
if { $blddir != "" } { |
| 109 |
unset lang_source_re |
| 110 |
unset lang_include_flags |
| 111 |
unset libgfortran_library_path |
| 112 |
unset libquadmath_library_path |
| 113 |
unset lang_library_paths |
| 114 |
} |
| 115 |
|
| 116 |
# All done. |
| 117 |
dg-finish |