| 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 1 |
| 9 |
} |
| 10 |
proc check_effective_target_c++ { } { |
| 11 |
return 0 |
| 12 |
} |
| 13 |
|
| 14 |
# Initialize dg. |
| 15 |
dg-init |
| 16 |
torture-init |
| 17 |
|
| 18 |
lappend ALWAYS_CFLAGS "compiler=$GCC_UNDER_TEST" |
| 19 |
|
| 20 |
# Turn on OpenACC. |
| 21 |
lappend ALWAYS_CFLAGS "additional_flags=-fopenacc" |
| 22 |
|
| 23 |
# Gather a list of all tests. |
| 24 |
set tests [lsort [concat \ |
| 25 |
[find $srcdir/$subdir *.c] \ |
| 26 |
[find $srcdir/$subdir/../libgomp.oacc-c-c++-common *.c]]] |
| 27 |
|
| 28 |
set ld_library_path $always_ld_library_path |
| 29 |
append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] |
| 30 |
set_ld_library_path_env_vars |
| 31 |
|
| 32 |
# Test with all available offload targets, and with offloading disabled. |
| 33 |
set SAVE_ALWAYS_CFLAGS "$ALWAYS_CFLAGS" |
| 34 |
foreach offload_target [concat [split $offload_targets ","] "disable"] { |
| 35 |
set ALWAYS_CFLAGS "$SAVE_ALWAYS_CFLAGS" |
| 36 |
global openacc_device_type |
| 37 |
set openacc_device_type [offload_target_to_openacc_device_type $offload_target] |
| 38 |
set tagopt "-DACC_DEVICE_TYPE_$openacc_device_type=1" |
| 39 |
|
| 40 |
switch $openacc_device_type { |
| 41 |
"" { |
| 42 |
unsupported "$subdir $offload_target offloading" |
| 43 |
continue |
| 44 |
} |
| 45 |
host { |
| 46 |
set acc_mem_shared 1 |
| 47 |
} |
| 48 |
nvidia { |
| 49 |
if { ![check_effective_target_openacc_nvidia_accel_present] } { |
| 50 |
# Don't bother; execution testing is going to FAIL. |
| 51 |
untested "$subdir $offload_target offloading: supported, but hardware not accessible" |
| 52 |
continue |
| 53 |
} |
| 54 |
|
| 55 |
# Copy ptx file (TEMPORARY) |
| 56 |
remote_download host $srcdir/libgomp.oacc-c-c++-common/subr.ptx |
| 57 |
|
| 58 |
# Where timer.h lives |
| 59 |
lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/libgomp.oacc-c-c++-common" |
| 60 |
|
| 61 |
set acc_mem_shared 0 |
| 62 |
} |
| 63 |
radeon { |
| 64 |
if { ![check_effective_target_openacc_radeon_accel_present] } { |
| 65 |
# Don't bother; execution testing is going to FAIL. |
| 66 |
untested "$subdir $offload_target offloading: supported, but hardware not accessible" |
| 67 |
continue |
| 68 |
} |
| 69 |
|
| 70 |
set acc_mem_shared 0 |
| 71 |
} |
| 72 |
default { |
| 73 |
error "Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)" |
| 74 |
} |
| 75 |
} |
| 76 |
set tagopt "$tagopt -DACC_MEM_SHARED=$acc_mem_shared" |
| 77 |
|
| 78 |
# To avoid compilation overhead, and to keep simple '-foffload=[...]' |
| 79 |
# handling in test cases, by default only build for the offload target |
| 80 |
# that we're actually going to test. |
| 81 |
set tagopt "$tagopt -foffload=$offload_target" |
| 82 |
# Force usage of the corresponding OpenACC device type. |
| 83 |
setenv ACC_DEVICE_TYPE $openacc_device_type |
| 84 |
|
| 85 |
# To get better test coverage for device-specific code that is only |
| 86 |
# ever used in offloading configurations, we'd like more thorough |
| 87 |
# testing for test cases that deal with offloading, which most of all |
| 88 |
# OpenACC test cases are. We enable torture testing, but limit it to |
| 89 |
# -O0 and -O2 only, to avoid testing times exploding too much, under |
| 90 |
# the assumption that between -O0 and -O[something] there is the |
| 91 |
# biggest difference in the overall structure of the generated code. |
| 92 |
switch -glob $offload_target { |
| 93 |
disable { |
| 94 |
set-torture-options [list \ |
| 95 |
{ -O2 } ] |
| 96 |
} |
| 97 |
default { |
| 98 |
set-torture-options [list \ |
| 99 |
{ -O0 } \ |
| 100 |
{ -O2 } ] |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
gcc-dg-runtest $tests "$tagopt" "" |
| 105 |
} |
| 106 |
unset offload_target |
| 107 |
|
| 108 |
# All done. |
| 109 |
torture-finish |
| 110 |
dg-finish |