fortran.exp 3.3 KB

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