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