2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c / c.exp
blob4475bf5341fa3438ccd045aa4cfaf7341893416b
1 # This whole file adapted from libgomp.c/c.exp.
3 if [info exists lang_library_path] then {
4 unset lang_library_path
5 unset lang_link_flags
7 if [info exists lang_test_file] then {
8 unset lang_test_file
10 if [info exists lang_include_flags] then {
11 unset lang_include_flags
14 load_lib libgomp-dg.exp
15 load_gcc_lib gcc-dg.exp
16 load_gcc_lib torture-options.exp
18 proc check_effective_target_c { } {
19 return 1
21 proc check_effective_target_c++ { } {
22 return 0
25 # Initialize dg.
26 dg-init
27 torture-init
29 # Turn on OpenACC.
30 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
32 # Gather a list of all tests.
33 set tests [lsort [concat \
34 [find $srcdir/$subdir *.c] \
35 [find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]]
37 set ld_library_path $always_ld_library_path
38 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
39 set_ld_library_path_env_vars
41 # Test OpenACC with available accelerators.
42 set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
43 foreach offload_target_openacc $offload_targets_s_openacc {
44 set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
45 set tagopt "-DACC_DEVICE_TYPE_$offload_target_openacc=1"
47 switch $offload_target_openacc {
48 host {
49 set acc_mem_shared 1
51 nvidia {
52 if { ![check_effective_target_openacc_nvidia_accel_present] } {
53 # Don't bother; execution testing is going to FAIL.
54 untested "$subdir $offload_target_openacc offloading"
55 continue
58 # Copy ptx file (TEMPORARY)
59 remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
61 # Where timer.h lives
62 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
64 set acc_mem_shared 0
66 default {
67 set acc_mem_shared 0
70 set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
72 setenv ACC_DEVICE_TYPE $offload_target_openacc
74 # To get better test coverage for device-specific code that is only
75 # ever used in offloading configurations, we'd like more thorough
76 # testing for test cases that deal with offloading, which most of all
77 # OpenACC test cases are. We enable torture testing, but limit it to
78 # -O0 and -O2 only, to avoid testing times exploding too much, under
79 # the assumption that between -O0 and -O[something] there is the
80 # biggest difference in the overall structure of the generated code.
81 switch $offload_target_openacc {
82 host {
83 set-torture-options [list \
84 { -O2 } ]
86 default {
87 set-torture-options [list \
88 { -O0 } \
89 { -O2 } ]
93 gcc-dg-runtest $tests "$tagopt" ""
96 # All done.
97 torture-finish
98 dg-finish