1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
# Configuration file for the 'lit' test runner.
import os
import lit.formats
# Tell pylint that we know config and lit_config exist somewhere.
if 'PYLINT_IMPORT' in os.environ:
config = object()
lit_config = object()
# Use the CUDA device as suggested by the env
if 'CUDA_VISIBLE_DEVICES' in os.environ:
config.environment['CUDA_VISIBLE_DEVICES'] = os.environ['CUDA_VISIBLE_DEVICES']
# Use the ROCR device as suggested by the env
if 'ROCR_VISIBLE_DEVICES' in os.environ:
config.environment['ROCR_VISIBLE_DEVICES'] = os.environ['ROCR_VISIBLE_DEVICES']
# Allow running the tests with omptarget debug output
if 'LIBOMPTARGET_DEBUG' in os.environ:
config.environment['LIBOMPTARGET_DEBUG'] = os.environ['LIBOMPTARGET_DEBUG']
if 'OMP_TARGET_OFFLOAD' in os.environ:
config.environment['OMP_TARGET_OFFLOAD'] = os.environ['OMP_TARGET_OFFLOAD']
def append_dynamic_library_path(name, value, sep):
if name in config.environment:
config.environment[name] = value + sep + config.environment[name]
else:
config.environment[name] = value
# name: The name of this test suite.
config.name = 'libomptarget :: ' + config.libomptarget_current_target
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.c', '.cpp', '.cc']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root object directory where output is placed
config.test_exec_root = config.libomptarget_obj_root
# test format
config.test_format = lit.formats.ShTest()
# compiler flags
config.test_flags = " -I " + config.test_source_root + \
" -I " + config.omp_header_directory + \
" -L " + config.library_dir;
if config.omp_host_rtl_directory:
config.test_flags = config.test_flags + " -L " + \
config.omp_host_rtl_directory
config.test_flags = config.test_flags + " " + config.test_extra_flags
# Allow REQUIRES / UNSUPPORTED / XFAIL to work
config.target_triple = [ ]
for feature in config.test_compiler_features:
config.available_features.add(feature)
if config.libomptarget_debug:
config.available_features.add('libomptarget-debug')
config.available_features.add(config.libomptarget_current_target)
# Determine whether the test system supports unified memory.
# For CUDA, this is the case with compute capability 70 (Volta) or higher.
# For all other targets, we currently assume it is.
supports_unified_shared_memory = True
if config.libomptarget_current_target.startswith('nvptx'):
try:
cuda_arch = int(config.cuda_test_arch)
if cuda_arch < 70:
supports_unified_shared_memory = False
except ValueError:
# If the architecture is invalid, assume it is supported.
supports_unified_shared_memory = True
if config.libomptarget_current_target.startswith('amdgcn'):
supports_unified_shared_memory = False
if supports_unified_shared_memory:
config.available_features.add('unified_shared_memory')
# Setup environment to find dynamic library at runtime
# Disable the implicit path to increase certainty over which library is picked up
config.test_flags += " -fno-openmp-implicit-rpath"
if config.operating_system == 'Windows':
append_dynamic_library_path('PATH', config.library_dir, ";")
append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";")
elif config.operating_system == 'Darwin':
append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
append_dynamic_library_path('DYLD_LIBRARY_PATH', \
config.omp_host_rtl_directory, ";")
config.test_flags += " -Wl,-rpath," + config.library_dir
config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
else: # Unices
config.test_flags += " -Wl,-rpath," + config.library_dir
config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
config.test_flags += " -Wl,-rpath," + config.llvm_lib_directory
if config.cuda_libdir:
config.test_flags += " -Wl,-rpath," + config.cuda_libdir
if config.libomptarget_current_target.startswith('amdgcn'):
config.test_flags += " --libomptarget-amdgcn-bc-path=" + config.library_dir
if config.libomptarget_current_target.startswith('nvptx'):
config.test_flags += " --libomptarget-nvptx-bc-path=" + config.library_dir
if config.libomptarget_current_target.endswith('-oldDriver'):
config.test_flags += " -fno-openmp-new-driver"
if config.libomptarget_current_target.endswith('-LTO'):
config.test_flags += " -foffload-lto"
def remove_suffix_if_present(name):
if name.endswith('-oldDriver'):
return name[:-10]
if name.endswith('-LTO'):
return name[:-4]
else:
return name
# substitutions
# - for targets that exist in the system create the actual command.
# - for valid targets that do not exist in the system, return false, so that the
# same test can be used for different targets.
# Scan all the valid targets.
for libomptarget_target in config.libomptarget_all_targets:
# Is this target in the current system? If so create a compile, run and test
# command. Otherwise create command that return false.
if libomptarget_target == config.libomptarget_current_target:
config.substitutions.append(("%libomptarget-compilexx-run-and-check-generic",
"%libomptarget-compilexx-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-run-and-check-generic",
"%libomptarget-compile-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-and-run-generic",
"%libomptarget-compilexx-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-and-run-generic",
"%libomptarget-compile-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-generic",
"%libomptarget-compilexx-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-generic",
"%libomptarget-compile-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-generic",
"%libomptarget-compileoptxx-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileopt-run-and-check-generic",
"%libomptarget-compileopt-run-and-check-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileoptxx-and-run-generic",
"%libomptarget-compileoptxx-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileopt-and-run-generic",
"%libomptarget-compileopt-and-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileoptxx-generic",
"%libomptarget-compileoptxx-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileopt-generic",
"%libomptarget-compileopt-" + libomptarget_target))
config.substitutions.append(("%libomptarget-run-generic",
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-run-fail-generic",
"%libomptarget-run-fail-" + libomptarget_target))
config.substitutions.append(("%clangxx-generic",
"%clangxx-" + libomptarget_target))
config.substitutions.append(("%clang-generic",
"%clang-" + libomptarget_target))
config.substitutions.append(("%fcheck-generic",
config.libomptarget_filecheck + " %s"))
config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
libomptarget_target, \
"%libomptarget-compilexx-and-run-" + libomptarget_target + \
" | " + config.libomptarget_filecheck + " %s"))
config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
libomptarget_target, \
"%libomptarget-compile-and-run-" + libomptarget_target + \
" | " + config.libomptarget_filecheck + " %s"))
config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
libomptarget_target, \
"%libomptarget-compilexx-" + libomptarget_target + " && " + \
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compile-and-run-" + \
libomptarget_target, \
"%libomptarget-compile-" + libomptarget_target + " && " + \
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compilexx-" + \
libomptarget_target, \
"%clangxx-" + libomptarget_target + " %s -o %t"))
config.substitutions.append(("%libomptarget-compile-" + \
libomptarget_target, \
"%clang-" + libomptarget_target + " %s -o %t"))
config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \
libomptarget_target, \
"%libomptarget-compileoptxx-and-run-" + libomptarget_target + \
" | " + config.libomptarget_filecheck + " %s"))
config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \
libomptarget_target, \
"%libomptarget-compileopt-and-run-" + libomptarget_target + \
" | " + config.libomptarget_filecheck + " %s"))
config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \
libomptarget_target, \
"%libomptarget-compileoptxx-" + libomptarget_target + " && " + \
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileopt-and-run-" + \
libomptarget_target, \
"%libomptarget-compileopt-" + libomptarget_target + " && " + \
"%libomptarget-run-" + libomptarget_target))
config.substitutions.append(("%libomptarget-compileoptxx-" + \
libomptarget_target, \
"%clangxx-" + libomptarget_target + " -O3 %s -o %t"))
config.substitutions.append(("%libomptarget-compileopt-" + \
libomptarget_target, \
"%clang-" + libomptarget_target + " -O3 %s -o %t"))
config.substitutions.append(("%libomptarget-run-" + \
libomptarget_target, \
"%t"))
config.substitutions.append(("%libomptarget-run-fail-" + \
libomptarget_target, \
"%not --crash %t"))
config.substitutions.append(("%clangxx-" + libomptarget_target, \
"%clangxx %openmp_flags %cuda_flags %flags -fopenmp-targets=" +\
remove_suffix_if_present(libomptarget_target)))
config.substitutions.append(("%clang-" + libomptarget_target, \
"%clang %openmp_flags %cuda_flags %flags -fopenmp-targets=" +\
remove_suffix_if_present(libomptarget_target)))
config.substitutions.append(("%fcheck-" + libomptarget_target, \
config.libomptarget_filecheck + " %s"))
else:
config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compile-and-run-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compilexx-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compile-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileopt-and-run-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileoptxx-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-compileopt-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-run-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%libomptarget-run-fail-" + \
libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%clang-" + libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%clangxx-" + libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%fcheck-" + libomptarget_target, \
"echo ignored-command"))
config.substitutions.append(("%clangxx", config.test_cxx_compiler))
config.substitutions.append(("%clang", config.test_c_compiler))
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
if config.libomptarget_current_target.startswith('nvptx') and config.cuda_path:
config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path))
else:
config.substitutions.append(("%cuda_flags", ""))
config.substitutions.append(("%flags", config.test_flags))
config.substitutions.append(("%not", config.libomptarget_not))
|