Mercurial > hg > CbC > CbC_gcc
annotate libgomp/testsuite/lib/libgomp.exp @ 143:76e1cf5455ef
add cbc_gc test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 23 Dec 2018 19:24:05 +0900 |
parents | 84e7813d76e9 |
children | 1830386684a0 |
rev | line source |
---|---|
0 | 1 # Damn dejagnu for not having proper library search paths for load_lib. |
2 # We have to explicitly load everything that gcc-dg.exp wants to load. | |
3 | |
4 proc load_gcc_lib { filename } { | |
5 global srcdir loaded_libs | |
6 | |
7 load_file $srcdir/../../gcc/testsuite/lib/$filename | |
8 set loaded_libs($filename) "" | |
9 } | |
10 | |
11 load_lib dg.exp | |
111 | 12 |
13 # Required to use gcc-dg.exp - however, the latter should NOT be | |
14 # loaded until ${tool}_target_compile is defined since it uses that | |
15 # to determine default LTO options. | |
16 | |
17 load_gcc_lib multiline.exp | |
18 load_gcc_lib prune.exp | |
19 load_gcc_lib target-libpath.exp | |
20 load_gcc_lib wrapper.exp | |
21 load_gcc_lib target-supports.exp | |
22 load_gcc_lib target-utils.exp | |
23 load_gcc_lib gcc-defs.exp | |
24 load_gcc_lib timeout.exp | |
0 | 25 load_gcc_lib file-format.exp |
26 load_gcc_lib target-supports-dg.exp | |
27 load_gcc_lib scanasm.exp | |
28 load_gcc_lib scandump.exp | |
111 | 29 load_gcc_lib scanlang.exp |
0 | 30 load_gcc_lib scanrtl.exp |
31 load_gcc_lib scantree.exp | |
131 | 32 load_gcc_lib scanltranstree.exp |
33 load_gcc_lib scanoffloadtree.exp | |
0 | 34 load_gcc_lib scanipa.exp |
131 | 35 load_gcc_lib scanwpaipa.exp |
111 | 36 load_gcc_lib timeout-dg.exp |
0 | 37 load_gcc_lib torture-options.exp |
111 | 38 load_gcc_lib fortran-modules.exp |
39 | |
40 # Try to load a test support file, built during libgomp configuration. | |
41 load_file libgomp-test-support.exp | |
42 | |
43 # Populate offload_targets_s (offloading targets separated by a space), and | |
44 # offload_targets_s_openacc (the same, but with OpenACC names; OpenACC spells | |
45 # some of them a little differently). | |
46 set offload_targets_s [split $offload_targets ","] | |
47 set offload_targets_s_openacc {} | |
48 foreach offload_target_openacc $offload_targets_s { | |
49 # Translate to OpenACC names, or skip if not yet supported. | |
50 switch $offload_target_openacc { | |
51 intelmic { | |
52 continue | |
53 } | |
54 nvptx { | |
55 set offload_target_openacc "nvidia" | |
56 } | |
57 hsa { | |
58 continue | |
59 } | |
60 } | |
61 lappend offload_targets_s_openacc "$offload_target_openacc" | |
62 } | |
63 lappend offload_targets_s_openacc "host" | |
0 | 64 |
65 set dg-do-what-default run | |
66 | |
67 # | |
68 # GCC_UNDER_TEST is the compiler under test. | |
69 # | |
70 | |
71 set libgomp_compile_options "" | |
72 | |
73 # | |
74 # libgomp_init | |
75 # | |
76 | |
77 if [info exists TOOL_OPTIONS] { | |
78 set multilibs [get_multilibs $TOOL_OPTIONS] | |
79 } else { | |
80 set multilibs [get_multilibs] | |
81 } | |
82 | |
83 proc libgomp_init { args } { | |
84 global srcdir blddir objdir tool_root_dir | |
85 global libgomp_initialized | |
86 global tmpdir | |
87 global blddir | |
88 global gluefile wrap_flags | |
89 global ALWAYS_CFLAGS | |
90 global CFLAGS | |
91 global TOOL_EXECUTABLE TOOL_OPTIONS | |
92 global GCC_UNDER_TEST | |
93 global TESTING_IN_BUILD_TREE | |
94 global target_triplet | |
95 global always_ld_library_path | |
96 | |
97 set blddir [lookfor_file [get_multilibs] libgomp] | |
98 | |
99 # We set LC_ALL and LANG to C so that we get the same error | |
100 # messages as expected. | |
101 setenv LC_ALL C | |
102 setenv LANG C | |
103 | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
104 # Many hosts now default to a non-ASCII C locale, however, so |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
105 # they can set a charset encoding here if they need. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
106 if { [ishost "*-*-cygwin*"] } { |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
107 setenv LC_ALL C.ASCII |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
108 setenv LANG C.ASCII |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
109 } |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
110 |
0 | 111 if ![info exists GCC_UNDER_TEST] then { |
112 if [info exists TOOL_EXECUTABLE] { | |
113 set GCC_UNDER_TEST $TOOL_EXECUTABLE | |
114 } else { | |
115 set GCC_UNDER_TEST "[find_gcc]" | |
116 } | |
117 } | |
118 | |
119 if ![info exists tmpdir] { | |
120 set tmpdir "/tmp" | |
121 } | |
122 | |
123 if [info exists gluefile] { | |
124 unset gluefile | |
125 } | |
126 | |
127 if {![info exists CFLAGS]} { | |
128 set CFLAGS "" | |
129 } | |
130 | |
131 # Locate libgcc.a so we don't need to account for different values of | |
132 # SHLIB_EXT on different platforms | |
133 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] | |
134 if {$gccdir != ""} { | |
135 set gccdir [file dirname $gccdir] | |
136 } | |
137 | |
138 # Compute what needs to be put into LD_LIBRARY_PATH | |
139 set always_ld_library_path ".:${blddir}/.libs" | |
140 | |
111 | 141 # Add liboffloadmic build directory in LD_LIBRARY_PATH to support |
142 # non-fallback testing for Intel MIC targets | |
143 global offload_targets | |
144 if { [string match "*,intelmic,*" ",$offload_targets,"] } { | |
145 append always_ld_library_path ":${blddir}/../liboffloadmic/.libs" | |
146 append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs" | |
147 # libstdc++ is required by liboffloadmic | |
148 append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs" | |
149 # libgcc_s is required by libstdc++ | |
150 append always_ld_library_path ":${blddir}/../libgcc" | |
151 } | |
152 | |
153 global offload_additional_lib_paths | |
154 if { $offload_additional_lib_paths != "" } { | |
155 append always_ld_library_path "${offload_additional_lib_paths}" | |
156 } | |
157 | |
0 | 158 # Compute what needs to be added to the existing LD_LIBRARY_PATH. |
159 if {$gccdir != ""} { | |
160 # Add AIX pthread directory first. | |
161 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } { | |
162 append always_ld_library_path ":${gccdir}/pthread" | |
163 } | |
164 append always_ld_library_path ":${gccdir}" | |
165 set compiler [lindex $GCC_UNDER_TEST 0] | |
166 | |
167 if { [is_remote host] == 0 && [which $compiler] != 0 } { | |
168 foreach i "[exec $compiler --print-multi-lib]" { | |
169 set mldir "" | |
170 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir | |
171 set mldir [string trimright $mldir "\;@"] | |
172 if { "$mldir" == "." } { | |
173 continue | |
174 } | |
175 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { | |
176 append always_ld_library_path ":${gccdir}/${mldir}" | |
177 } | |
178 } | |
179 } | |
180 } | |
181 | |
182 set ALWAYS_CFLAGS "" | |
183 if { $blddir != "" } { | |
184 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
185 # targets that use libgomp.a%s in their specs need a -B option |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
186 # for uninstalled testing. |
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
187 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs" |
0 | 188 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" |
189 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" | |
190 } | |
131 | 191 # The top-level include directory, for gomp-constants.h. |
192 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include" | |
0 | 193 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." |
111 | 194 |
195 # For build-tree testing, also consider the library paths used for builing. | |
196 # For installed testing, we assume all that to be provided in the sysroot. | |
197 if { $blddir != "" } { | |
198 global cuda_driver_include | |
199 global cuda_driver_lib | |
200 if { $cuda_driver_include != "" } { | |
201 # Stop gfortran from freaking out: | |
202 # Warning: Nonexistent include directory "[...]" | |
203 if {[file exists $cuda_driver_include]} { | |
204 lappend ALWAYS_CFLAGS "additional_flags=-I$cuda_driver_include" | |
205 } | |
206 } | |
207 if { $cuda_driver_lib != "" } { | |
208 lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib" | |
209 append always_ld_library_path ":$cuda_driver_lib" | |
210 } | |
211 global hsa_runtime_lib | |
212 if { $hsa_runtime_lib != "" } { | |
213 append always_ld_library_path ":$hsa_runtime_lib" | |
214 } | |
215 } | |
0 | 216 |
217 # We use atomic operations in the testcases to validate results. | |
218 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) | |
111 | 219 && [check_effective_target_ia32] } { |
0 | 220 lappend ALWAYS_CFLAGS "additional_flags=-march=i486" |
221 } | |
222 | |
223 if [istarget *-*-darwin*] { | |
224 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc" | |
225 } | |
226 | |
227 if [istarget sparc*-*-*] { | |
228 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9" | |
229 } | |
230 | |
231 if [info exists TOOL_OPTIONS] { | |
232 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS" | |
233 } | |
234 | |
235 # Make sure that lines are not wrapped. That can confuse the | |
236 # error-message parsing machinery. | |
237 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0" | |
238 | |
111 | 239 # Disable caret |
240 lappend ALWAYS_CFLAGS "additional_flags=-fno-diagnostics-show-caret" | |
241 | |
242 # Disable HSA warnings by default. | |
243 lappend ALWAYS_CFLAGS "additional_flags=-Wno-hsa" | |
244 | |
245 # Disable color diagnostics | |
246 lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never" | |
247 | |
248 # Used for support non-fallback offloading. | |
249 # Help GCC to find target mkoffload. | |
250 global offload_additional_options | |
251 if { $offload_additional_options != "" } { | |
252 lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}" | |
253 } | |
0 | 254 } |
255 | |
256 # | |
257 # libgomp_target_compile -- compile a source file | |
258 # | |
259 | |
260 proc libgomp_target_compile { source dest type options } { | |
261 global blddir | |
262 global libgomp_compile_options | |
263 global gluefile wrap_flags | |
264 global ALWAYS_CFLAGS | |
265 global GCC_UNDER_TEST | |
266 global lang_test_file | |
267 global lang_library_path | |
268 global lang_link_flags | |
111 | 269 global lang_include_flags |
270 global lang_source_re | |
0 | 271 |
272 if { [info exists lang_test_file] } { | |
273 if { $blddir != "" } { | |
274 # Some targets use libgfortran.a%s in their specs, so they need | |
275 # a -B option for uninstalled testing. | |
276 lappend options "additional_flags=-B${blddir}/${lang_library_path}" | |
277 lappend options "ldflags=-L${blddir}/${lang_library_path}" | |
278 } | |
279 lappend options "ldflags=${lang_link_flags}" | |
111 | 280 if { [info exists lang_include_flags] \ |
281 && [regexp ${lang_source_re} ${source}] } { | |
282 lappend options "additional_flags=${lang_include_flags}" | |
283 } | |
0 | 284 } |
285 | |
286 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { | |
287 lappend options "libs=${gluefile}" | |
288 lappend options "ldflags=${wrap_flags}" | |
289 } | |
290 | |
291 lappend options "additional_flags=[libio_include_flags]" | |
292 lappend options "timeout=[timeout_value]" | |
293 lappend options "compiler=$GCC_UNDER_TEST" | |
294 | |
295 set options [concat $libgomp_compile_options $options] | |
296 | |
297 if [info exists ALWAYS_CFLAGS] { | |
298 set options [concat "$ALWAYS_CFLAGS" $options] | |
299 } | |
300 | |
301 set options [dg-additional-files-options $options $source] | |
302 | |
303 set result [target_compile $source $dest $type $options] | |
304 | |
305 return $result | |
306 } | |
307 | |
308 proc libgomp_option_help { } { | |
309 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n" | |
310 } | |
311 | |
312 proc libgomp_option_proc { option } { | |
313 if [regexp "^--additional_options," $option] { | |
314 global libgomp_compile_options | |
315 regsub "--additional_options," $option "" option | |
316 foreach x [split $option ","] { | |
317 lappend libgomp_compile_options "additional_flags=$x" | |
318 } | |
319 return 1 | |
320 } else { | |
321 return 0 | |
322 } | |
323 } | |
111 | 324 |
325 # Return 1 if offload device is available. | |
326 proc check_effective_target_offload_device { } { | |
327 return [check_runtime_nocache offload_device_available_ { | |
328 #include <omp.h> | |
329 int main () | |
330 { | |
331 int a; | |
332 #pragma omp target map(from: a) | |
333 a = omp_is_initial_device (); | |
334 return a; | |
335 } | |
336 } ] | |
337 } | |
338 | |
339 # Return 1 if offload device is available and it has non-shared address space. | |
340 proc check_effective_target_offload_device_nonshared_as { } { | |
341 return [check_runtime_nocache offload_device_nonshared_as { | |
342 int main () | |
343 { | |
344 int a = 8; | |
345 #pragma omp target map(to: a) | |
346 a++; | |
347 return a != 8; | |
348 } | |
349 } ] | |
350 } | |
351 | |
352 # Return 1 if offload device is available and it has shared address space. | |
353 proc check_effective_target_offload_device_shared_as { } { | |
354 return [check_runtime_nocache offload_device_shared_as { | |
355 int main () | |
356 { | |
357 int x = 10; | |
358 #pragma omp target map(to: x) | |
359 x++; | |
360 return x == 10; | |
361 } | |
362 } ] | |
363 } | |
364 | |
365 # Return 1 if configured for nvptx offloading. | |
366 | |
367 proc check_effective_target_openacc_nvidia_accel_configured { } { | |
368 global offload_targets | |
369 if { ![string match "*,nvptx,*" ",$offload_targets,"] } { | |
370 return 0 | |
371 } | |
372 # PR libgomp/65099: Currently, we only support offloading in 64-bit | |
373 # configurations. | |
374 return [is-effective-target lp64] | |
375 } | |
376 | |
377 # Return 1 if at least one nvidia board is present. | |
378 | |
379 proc check_effective_target_openacc_nvidia_accel_present { } { | |
380 return [check_runtime openacc_nvidia_accel_present { | |
381 #include <openacc.h> | |
382 int main () { | |
383 return !(acc_get_num_devices (acc_device_nvidia) > 0); | |
384 } | |
385 } "" ] | |
386 } | |
387 | |
388 # Return 1 if at least one nvidia board is present, and the nvidia device type | |
389 # is selected by default by means of setting the environment variable | |
390 # ACC_DEVICE_TYPE. | |
391 | |
392 proc check_effective_target_openacc_nvidia_accel_selected { } { | |
393 if { ![check_effective_target_openacc_nvidia_accel_present] } { | |
394 return 0; | |
395 } | |
396 global offload_target_openacc | |
397 if { $offload_target_openacc == "nvidia" } { | |
398 return 1; | |
399 } | |
400 return 0; | |
401 } | |
402 | |
403 # Return 1 if the host target is selected for offloaded | |
404 | |
405 proc check_effective_target_openacc_host_selected { } { | |
406 global offload_target_openacc | |
407 if { $offload_target_openacc == "host" } { | |
408 return 1; | |
409 } | |
410 return 0; | |
411 } | |
412 | |
413 # Return 1 if the selected OMP device is actually a HSA device | |
414 | |
415 proc check_effective_target_hsa_offloading_selected_nocache {} { | |
416 global tool | |
417 | |
418 set src { | |
419 int main () { | |
420 int v = 1; | |
421 #pragma omp target map(from:v) | |
422 v = 0; | |
423 return v; | |
424 } | |
425 } | |
426 | |
427 set result [check_compile hsa_offloading_src executable $src] | |
428 set lines [lindex $result 0] | |
429 set exe [lindex $result 1] | |
430 | |
431 set ok 0 | |
432 if { [string match "" $lines] } { | |
433 # No error messages, let us switch on HSA debugging output and run it | |
434 set prev_HSA_DEBUG [getenv HSA_DEBUG] | |
435 setenv HSA_DEBUG "1" | |
436 set result [remote_load target "./$exe"] | |
437 if { [string match "" $prev_HSA_DEBUG] } { | |
438 unsetenv HSA_DEBUG | |
439 } else { | |
440 setenv HSA_DEBUG $prev_HSA_DEBUG | |
441 } | |
442 set status [lindex $result 0] | |
443 if { $status != "pass" } { | |
444 remote_file build delete $exe | |
445 verbose "HSA availability test failed" | |
446 return 0 | |
447 } | |
448 set output [lindex $result 1] | |
449 if { [string match "*HSA debug: Going to dispatch kernel*" $output] } { | |
450 verbose "HSA availability detected" | |
451 set ok 1 | |
452 } | |
453 } | |
454 remote_file build delete $exe | |
455 return $ok | |
456 } | |
457 | |
458 # Return 1 if the selected OMP device is actually a HSA device and | |
459 # cache the result | |
460 | |
461 proc check_effective_target_hsa_offloading_selected {} { | |
462 return [check_cached_effective_target hsa_offloading_selected { | |
463 check_effective_target_hsa_offloading_selected_nocache | |
464 }] | |
465 } |