Debian Codegraph @

libgomp/testsuite/libgomp.oacc-c++/c++.exp

raw
1 # This whole file adapted from libgomp.c++/c++.exp.
2
3 load_lib libgomp-dg.exp
4 load_gcc_lib gcc-dg.exp
5 load_gcc_lib torture-options.exp
6
7 proc check_effective_target_c { } {
8 return 0
9 }
10 proc check_effective_target_c++ { } {
11 return 1
12 }
13
14 if { $blddir != "" } {
15 set libstdc++_library_path "../libstdc++-v3/src/.libs"
16 set shlib_ext [get_shlib_extension]
17 if { ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.a"]
18 && ![file exists "${blddir}/${libstdc++_library_path}/libstdc++.${shlib_ext}"] } {
19 verbose -log "No libstdc++ library found, will not execute c++ tests"
20 unset libstdc++_library_path
21 return
22 }
23 lappend lang_library_paths ${libstdc++_library_path}
24 } elseif { ![info exists GXX_UNDER_TEST] } {
25 verbose -log "GXX_UNDER_TEST not defined, will not execute c++ tests"
26 return
27 }
28 if { $blddir != "" } {
29 set lang_source_re {^.*\.[cC]$}
30 set lang_include_flags [exec sh ${blddir}/../libstdc++-v3/scripts/testsuite_flags --build-includes]
31 }
32 lappend ALWAYS_CFLAGS "compiler=$GXX_UNDER_TEST"
33
34 # Initialize dg.
35 dg-init
36 torture-init
37
38 # Turn on OpenACC.
39 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
40
41 # Gather a list of all tests.
42 set tests [lsort [concat \
43 [find $srcdir/$subdir *.C] \
44 [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
45
46 set ld_library_path $always_ld_library_path
47 if { $blddir != "" } {
48 append ld_library_path ":${blddir}/${libstdc++_library_path}"
49 }
50 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
51 set_ld_library_path_env_vars
52
53 # Test with all available offload targets, and with offloading disabled.
54 foreach offload_target [concat [split $offload_targets ","] "disable"] {
55 global openacc_device_type
56 set openacc_device_type [offload_target_to_openacc_device_type $offload_target]
57 set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
58
59 switch $openacc_device_type {
60 "" {
61 unsupported "$subdir $offload_target offloading"
62 continue
63 }
64 host {
65 set acc_mem_shared 1
66 }
67 nvidia {
68 if { ![check_effective_target_openacc_nvidia_accel_present] } {
69 # Don't bother; execution testing is going to FAIL.
70 untested "$subdir $offload_target offloading: supported, but hardware not accessible"
71 continue
72 }
73
74 # Copy ptx file (TEMPORARY)
75 remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
76
77 # Where timer.h lives
78 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
79
80 set acc_mem_shared 0
81 }
82 radeon {
83 if { ![check_effective_target_openacc_radeon_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 # To get better test coverage for device-specific code that is only
105 # ever used in offloading configurations, we'd like more thorough
106 # testing for test cases that deal with offloading, which most of all
107 # OpenACC test cases are. We enable torture testing, but limit it to
108 # -O0 and -O2 only, to avoid testing times exploding too much, under
109 # the assumption that between -O0 and -O[something] there is the
110 # biggest difference in the overall structure of the generated code.
111 switch -glob $offload_target {
112 disable {
113 set-torture-options [list \
114 { -O2 } ]
115 }
116 default {
117 set-torture-options [list \
118 { -O0 } \
119 { -O2 } ]
120 }
121 }
122
123 gcc-dg-runtest $tests "$tagopt" ""
124 }
125 unset offload_target
126
127 if { $blddir != "" } {
128 unset lang_source_re
129 unset lang_include_flags
130 unset libstdc++_library_path
131 unset lang_library_paths
132 }
133
134 # All done.
135 torture-finish
136 dg-finish