c.exp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # This whole file adapted from libgomp.c/c.exp.
  2. if [info exists lang_library_path] then {
  3. unset lang_library_path
  4. unset lang_link_flags
  5. }
  6. if [info exists lang_test_file] then {
  7. unset lang_test_file
  8. }
  9. if [info exists lang_include_flags] then {
  10. unset lang_include_flags
  11. }
  12. load_lib libgomp-dg.exp
  13. load_gcc_lib gcc-dg.exp
  14. # If a testcase doesn't have special options, use these.
  15. if ![info exists DEFAULT_CFLAGS] then {
  16. set DEFAULT_CFLAGS "-O2"
  17. }
  18. # Initialize dg.
  19. dg-init
  20. # Turn on OpenACC.
  21. lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
  22. # Gather a list of all tests.
  23. set tests [lsort [concat \
  24. [find $srcdir/$subdir *.c] \
  25. [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
  26. set ld_library_path $always_ld_library_path
  27. append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
  28. set_ld_library_path_env_vars
  29. # Test OpenACC with available accelerators.
  30. set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
  31. foreach offload_target_openacc $offload_targets_s_openacc {
  32. set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
  33. set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
  34. switch $offload_target_openacc {
  35. host {
  36. set acc_mem_shared 1
  37. }
  38. host_nonshm {
  39. set acc_mem_shared 0
  40. }
  41. nvidia {
  42. if { ![check_effective_target_openacc_nvidia_accel_present] } {
  43. # Don't bother; execution testing is going to FAIL.
  44. untested "$subdir $offload_target_openacc offloading"
  45. continue
  46. }
  47. # Copy ptx file (TEMPORARY)
  48. remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
  49. # Where timer.h lives
  50. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
  51. set acc_mem_shared 0
  52. }
  53. default {
  54. set acc_mem_shared 0
  55. }
  56. }
  57. set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
  58. setenv ACC_DEVICE_TYPE $offload_target_openacc
  59. dg-runtest $tests "$tagopt" $DEFAULT_CFLAGS
  60. }
  61. # All done.
  62. dg-finish