]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.oacc-c/c.exp
[libgomp] Clarify difference between offload target, offload plugin, and OpenACC...
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.oacc-c / c.exp
1 # This whole file adapted from libgomp.c/c.exp.
2
3 if [info exists lang_library_path] then {
4 unset lang_library_path
5 unset lang_link_flags
6 }
7 if [info exists lang_test_file] then {
8 unset lang_test_file
9 }
10 if [info exists lang_include_flags] then {
11 unset lang_include_flags
12 }
13
14 load_lib libgomp-dg.exp
15 load_gcc_lib gcc-dg.exp
16 load_gcc_lib torture-options.exp
17
18 proc check_effective_target_c { } {
19 return 1
20 }
21 proc check_effective_target_c++ { } {
22 return 0
23 }
24
25 # Initialize dg.
26 dg-init
27 torture-init
28
29 # Turn on OpenACC.
30 lappend ALWAYS_CFLAGS "additional_flags=-fopenacc"
31
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]]]
36
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
40
41 # Test with available OpenACC device types.
42 set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS"
43 global openacc_device_type
44 foreach openacc_device_type $openacc_device_types_s {
45 set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS"
46 set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1"
47
48 switch $openacc_device_type {
49 host {
50 set acc_mem_shared 1
51 }
52 nvidia {
53 if { ![check_effective_target_openacc_nvidia_accel_present] } {
54 # Don't bother; execution testing is going to FAIL.
55 untested "$subdir $openacc_device_type offloading: supported, but hardware not accessible"
56 continue
57 }
58
59 # Copy ptx file (TEMPORARY)
60 remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx
61
62 # Where timer.h lives
63 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common"
64
65 set acc_mem_shared 0
66 }
67 default {
68 error "Unknown OpenACC device type: $openacc_device_type"
69 }
70 }
71 set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
72
73 setenv ACC_DEVICE_TYPE $openacc_device_type
74
75 # To get better test coverage for device-specific code that is only
76 # ever used in offloading configurations, we'd like more thorough
77 # testing for test cases that deal with offloading, which most of all
78 # OpenACC test cases are. We enable torture testing, but limit it to
79 # -O0 and -O2 only, to avoid testing times exploding too much, under
80 # the assumption that between -O0 and -O[something] there is the
81 # biggest difference in the overall structure of the generated code.
82 switch $openacc_device_type {
83 host {
84 set-torture-options [list \
85 { -O2 } ]
86 }
87 default {
88 set-torture-options [list \
89 { -O0 } \
90 { -O2 } ]
91 }
92 }
93
94 gcc-dg-runtest $tests "$tagopt" ""
95 }
96
97 # All done.
98 torture-finish
99 dg-finish