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" 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 OpenACC with available accelerators. 69 foreach offload_target_openacc $offload_targets_s_openacc { 70 set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1" 71 72 switch $offload_target_openacc { 73 host { 74 set acc_mem_shared 1 75 } 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 81 } 82 83 set acc_mem_shared 0 84 } 85 default { 86 set acc_mem_shared 0 87 } 88 } 89 set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared" 90 91 setenv ACC_DEVICE_TYPE $offload_target_openacc 92 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" "" 97 } 98} 99 100# All done. 101dg-finish 102