1 # This whole file adapted from libgomp.c++/c++.exp.
3 load_lib libgomp-dg.exp
4 load_gcc_lib gcc-dg.exp
5 load_gcc_lib torture-options.exp
7 proc check_effective_target_c { } {
10 proc check_effective_target_c++ { } {
16 set shlib_ext [get_shlib_extension]
17 set lang_link_flags "-lstdc++"
18 set lang_test_file_found 0
19 set lang_library_path "../libstdc++-v3/src/.libs"
20 if [info exists lang_include_flags] then {
21 unset lang_include_flags
29 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
31 # Switch into C++ mode. Otherwise, the libgomp.oacc-c-c++-common/*.c
32 # files would be compiled as C files.
33 set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
34 set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
36 set blddir [lookfor_file [get_multilibs] libgomp]
39 if { $blddir != "" } {
40 # Look for a static libstdc++ first.
41 if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] {
42 set lang_test_file "${lang_library_path}/libstdc++.a"
43 set lang_test_file_found 1
44 # We may have a shared only build, so look for a shared libstdc++.
45 } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] {
46 set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}"
47 set lang_test_file_found 1
49 puts "No libstdc++ library found, will not execute c++ tests"
51 } elseif { [info exists GXX_UNDER_TEST] } {
52 set lang_test_file_found 1
53 # Needs to exist for libgomp.exp.
56 puts "GXX_UNDER_TEST not defined, will not execute c++ tests"
59 if { $lang_test_file_found } {
60 # Gather a list of all tests.
61 set tests [lsort [concat \
62 [find $srcdir/$subdir *.C] \
63 [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
65 if { $blddir != "" } {
66 set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
68 set ld_library_path "$always_ld_library_path"
70 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
71 set_ld_library_path_env_vars
73 set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags"
74 if { [file exists $flags_file] } {
75 set libstdcxx_includes [exec sh $flags_file --build-includes]
77 set libstdcxx_includes ""
80 # Test with all available offload targets, and with offloading disabled.
81 foreach offload_target [concat [split $offload_targets ","] "disable"] {
82 global openacc_device_type
83 set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
84 set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
86 switch $openacc_device_type {
88 unsupported "$subdir $offload_target offloading"
92 if { ![check_effective_target_openacc_amdgcn_accel_present] } {
93 # Don't bother; execution testing is going to FAIL.
94 untested "$subdir $offload_target offloading: supported, but hardware not accessible"
104 if { ![check_effective_target_openacc_nvidia_accel_present] } {
105 # Don't bother; execution testing is going to FAIL.
106 untested "$subdir $offload_target offloading: supported, but hardware not accessible"
110 # Copy ptx file (TEMPORARY)
111 remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
113 # Where timer.h lives
114 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
119 error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
122 set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
124 # To avoid compilation overhead, and to keep simple '-foffload=[...]'
125 # handling in test cases, by default only build for the offload target
126 # that we're actually going to test.
127 set tagopt "$tagopt -foffload=$offload_target"
128 # Force usage of the corresponding OpenACC device type.
129 setenv ACC_DEVICE_TYPE $openacc_device_type
131 # To get better test coverage for device-specific code that is only
132 # ever used in offloading configurations, we'd like more thorough
133 # testing for test cases that deal with offloading, which most of all
134 # OpenACC test cases are. We enable torture testing, but limit it to
135 # -O0 and -O2 only, to avoid testing times exploding too much, under
136 # the assumption that between -O0 and -O[something] there is the
137 # biggest difference in the overall structure of the generated code.
138 switch -glob $offload_target {
140 set-torture-options [list \
144 set-torture-options [list \
150 gcc-dg-runtest $tests "$tagopt" "$libstdcxx_includes"
153 # Call this once, which placates the subsequent torture-finish.
154 set-torture-options [list \
159 set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"