llvm-project

Форк
0
417 строк · 20.2 Кб
1
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2
# Configuration file for the 'lit' test runner.
3

4
import os
5
import lit.formats
6

7
# Tell pylint that we know config and lit_config exist somewhere.
8
if 'PYLINT_IMPORT' in os.environ:
9
    config = object()
10
    lit_config = object()
11

12
# Use the CUDA device as suggested by the env
13
if 'CUDA_VISIBLE_DEVICES' in os.environ:
14
    config.environment['CUDA_VISIBLE_DEVICES'] = os.environ['CUDA_VISIBLE_DEVICES']
15

16
# Use the ROCR device as suggested by the env
17
if 'ROCR_VISIBLE_DEVICES' in os.environ:
18
    config.environment['ROCR_VISIBLE_DEVICES'] = os.environ['ROCR_VISIBLE_DEVICES']
19

20
# Allow running the tests with omptarget debug output
21
if 'LIBOMPTARGET_DEBUG' in os.environ:
22
    config.environment['LIBOMPTARGET_DEBUG'] = os.environ['LIBOMPTARGET_DEBUG']
23

24
# Allow running the tests with nextgen plugins when available
25
if 'LIBOMPTARGET_NEXTGEN_PLUGINS' in os.environ:
26
    config.environment['LIBOMPTARGET_NEXTGEN_PLUGINS'] = os.environ['LIBOMPTARGET_NEXTGEN_PLUGINS']
27

28
if 'LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS' in os.environ:
29
    config.environment['LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS'] = os.environ['LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS']
30

31
if 'OMP_TARGET_OFFLOAD' in os.environ:
32
    config.environment['OMP_TARGET_OFFLOAD'] = os.environ['OMP_TARGET_OFFLOAD']
33

34
if 'HSA_ENABLE_SDMA' in os.environ:
35
    config.environment['HSA_ENABLE_SDMA'] = os.environ['HSA_ENABLE_SDMA']
36

37
# Architectures like gfx942 may or may not be APUs so an additional environment
38
# variable is required as some tests can be APU specific.
39
if 'IS_APU' in os.environ:
40
    config.environment['IS_APU'] = os.environ['IS_APU']
41

42
# set default environment variables for test
43
if 'CHECK_OPENMP_ENV' in os.environ:
44
    test_env = os.environ['CHECK_OPENMP_ENV'].split()
45
    for env in test_env:
46
        name = env.split('=')[0]
47
        value = env.split('=')[1]
48
        config.environment[name] = value
49

50
def append_dynamic_library_path(name, value, sep):
51
    if name in config.environment:
52
        config.environment[name] = value + sep + config.environment[name]
53
    else:
54
        config.environment[name] = value
55

56
# Evaluate the environment variable which is a string boolean value.
57
def evaluate_bool_env(env):
58
    env = env.lower()
59
    possible_true_values = ["on", "true", "1"]
60
    for v in possible_true_values:
61
        if env == v:
62
            return True
63
    return False
64

65
# name: The name of this test suite.
66
config.name = 'libomptarget :: ' + config.libomptarget_current_target
67

68
# suffixes: A list of file extensions to treat as test files.
69
config.suffixes = ['.c', '.cpp', '.cc', '.f90']
70

71
# excludes: A list of directories to exclude from the testuites.
72
config.excludes = ['Inputs']
73

74
# test_source_root: The root path where tests are located.
75
config.test_source_root = os.path.dirname(__file__)
76

77
# test_exec_root: The root object directory where output is placed
78
config.test_exec_root = config.libomptarget_obj_root
79

80
# test format
81
config.test_format = lit.formats.ShTest()
82

83
# compiler flags
84
config.test_flags = " -I " + config.test_source_root + \
85
    " -I " + config.omp_header_directory + \
86
    " -L " + config.library_dir + \
87
    " -L " + config.llvm_lib_directory
88

89
# compiler specific flags
90
config.test_flags_clang = ""
91
config.test_flags_flang = ""
92

93
if config.omp_host_rtl_directory:
94
    config.test_flags = config.test_flags + " -L " + \
95
        config.omp_host_rtl_directory
96

97
config.test_flags = config.test_flags + " " + config.test_extra_flags
98

99
# Allow REQUIRES / UNSUPPORTED / XFAIL to work
100
config.target_triple = [ ]
101
for feature in config.test_compiler_features:
102
    config.available_features.add(feature)
103

104
if config.libomptarget_debug:
105
  config.available_features.add('libomptarget-debug')
106

107
if config.has_libomptarget_ompt:
108
  config.available_features.add('ompt')
109

110
config.available_features.add(config.libomptarget_current_target)
111

112
if config.libomptarget_has_libc:
113
  config.available_features.add('libc')
114

115
# Determine whether the test system supports unified memory.
116
# For CUDA, this is the case with compute capability 70 (Volta) or higher.
117
# For all other targets, we currently assume it is.
118
supports_unified_shared_memory = True
119
supports_apu = False
120
if config.libomptarget_current_target.startswith('nvptx'):
121
  try:
122
    cuda_arch = int(config.cuda_test_arch[:3])
123
    if cuda_arch < 70:
124
      supports_unified_shared_memory = False
125
  except ValueError:
126
    # If the architecture is invalid, assume it is supported.
127
    supports_unified_shared_memory = True
128
elif config.libomptarget_current_target.startswith('amdgcn'):
129
    # amdgpu_test_arch contains a list of AMD GPUs in the system
130
    # only check the first one assuming that we will run the test on it.
131
    if not (config.amdgpu_test_arch.startswith("gfx90a") or
132
            config.amdgpu_test_arch.startswith("gfx940") or
133
            config.amdgpu_test_arch.startswith("gfx942")):
134
       supports_unified_shared_memory = False
135
    # check if AMD architecture is an APU:
136
    if (config.amdgpu_test_arch.startswith("gfx940") or
137
        (config.amdgpu_test_arch.startswith("gfx942") and
138
         evaluate_bool_env(config.environment['IS_APU']))):
139
       supports_apu = True
140
if supports_unified_shared_memory:
141
   config.available_features.add('unified_shared_memory')
142
if supports_apu:
143
   config.available_features.add('apu')
144

145
# Setup environment to find dynamic library at runtime
146
if config.operating_system == 'Windows':
147
    append_dynamic_library_path('PATH', config.library_dir, ";")
148
    append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";")
149
elif config.operating_system == 'Darwin':
150
    append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
151
    append_dynamic_library_path('DYLD_LIBRARY_PATH', \
152
        config.omp_host_rtl_directory, ";")
153
    config.test_flags += " -Wl,-rpath," + config.library_dir
154
    config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
155
else: # Unices
156
    if config.libomptarget_current_target != "nvptx64-nvidia-cuda":
157
        config.test_flags += " -nogpulib"
158
    config.test_flags += " -Wl,-rpath," + config.library_dir
159
    config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
160
    config.test_flags += " -Wl,-rpath," + config.llvm_lib_directory
161
    if config.cuda_libdir:
162
        config.test_flags += " -Wl,-rpath," + config.cuda_libdir
163
    if config.libomptarget_current_target.startswith('nvptx'):
164
        config.test_flags_clang += " --libomptarget-nvptx-bc-path=" + config.library_dir + '/DeviceRTL'
165
    if config.libomptarget_current_target.endswith('-LTO'):
166
        config.test_flags += " -foffload-lto"
167
    if config.libomptarget_current_target.endswith('-JIT-LTO') and evaluate_bool_env(
168
        config.environment['LIBOMPTARGET_NEXTGEN_PLUGINS']
169
    ):
170
        config.test_flags += " -foffload-lto"
171
        config.test_flags += " -Wl,--embed-bitcode"
172

173
def remove_suffix_if_present(name):
174
    if name.endswith('-LTO'):
175
        return name[:-4]
176
    elif name.endswith('-JIT-LTO'):
177
        return name[:-8]
178
    else:
179
        return name
180

181
def add_libraries(source):
182
    if config.libomptarget_has_libc:
183
        if config.libomptarget_current_target.startswith('nvptx'):
184
            return source + " " + config.llvm_library_dir + "/libcgpu-nvptx.a " + \
185
                   config.llvm_library_intdir + "/libomptarget.devicertl.a"
186
        elif config.libomptarget_current_target.startswith('amdgcn'):
187
            return source + " " + config.llvm_library_dir + "/libcgpu-amdgpu.a " + \
188
                   config.llvm_library_intdir + "/libomptarget.devicertl.a"
189
    return source + " " + config.llvm_library_intdir + "/libomptarget.devicertl.a"
190

191
# Add platform targets
192
host_targets = [
193
    "aarch64-unknown-linux-gnu",
194
    "aarch64-unknown-linux-gnu-LTO",
195
    "x86_64-pc-linux-gnu",
196
    "x86_64-pc-linux-gnu-LTO",
197
    "s390x-ibm-linux-gnu",
198
    "s390x-ibm-linux-gnu-LTO",
199
]
200
if config.libomptarget_current_target.startswith('nvptx'):
201
    config.available_features.add('gpu')
202
    config.available_features.add('nvidiagpu')
203
if config.libomptarget_current_target.startswith('amdgcn'):
204
    config.available_features.add('gpu')
205
    config.available_features.add('amdgpu')
206
if config.libomptarget_current_target in host_targets:
207
    config.available_features.add('host')
208

209
# substitutions
210
# - for targets that exist in the system create the actual command.
211
# - for valid targets that do not exist in the system, return false, so that the
212
#   same test can be used for different targets.
213

214
# Scan all the valid targets.
215
for libomptarget_target in config.libomptarget_all_targets:
216
    # Is this target in the current system? If so create a compile, run and test
217
    # command. Otherwise create command that return false.
218
    if libomptarget_target == config.libomptarget_current_target:
219
        config.substitutions.append(("%libomptarget-compilexx-run-and-check-generic",
220
            "%libomptarget-compilexx-run-and-check-" + libomptarget_target))
221
        config.substitutions.append(("%libomptarget-compile-run-and-check-generic",
222
            "%libomptarget-compile-run-and-check-" + libomptarget_target))
223
        config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-generic",
224
            "%libomptarget-compile-fortran-run-and-check-" + libomptarget_target))
225
        config.substitutions.append(("%libomptarget-compilexx-and-run-generic",
226
            "%libomptarget-compilexx-and-run-" + libomptarget_target))
227
        config.substitutions.append(("%libomptarget-compile-and-run-generic",
228
            "%libomptarget-compile-and-run-" + libomptarget_target))
229
        config.substitutions.append(("%libomptarget-compilexx-generic",
230
            "%libomptarget-compilexx-" + libomptarget_target))
231
        config.substitutions.append(("%libomptarget-compilexxx-generic-force-usm",
232
            "%libomptarget-compilexxx-force-usm-" + libomptarget_target))
233
        config.substitutions.append(("%libomptarget-compile-generic",
234
            "%libomptarget-compile-" + libomptarget_target))
235
        config.substitutions.append(("%libomptarget-compile-fortran-generic",
236
            "%libomptarget-compile-fortran-" + libomptarget_target))
237
        config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-generic",
238
            "%libomptarget-compileoptxx-run-and-check-" + libomptarget_target))
239
        config.substitutions.append(("%libomptarget-compileopt-run-and-check-generic",
240
            "%libomptarget-compileopt-run-and-check-" + libomptarget_target))
241
        config.substitutions.append(("%libomptarget-compileoptxx-and-run-generic",
242
            "%libomptarget-compileoptxx-and-run-" + libomptarget_target))
243
        config.substitutions.append(("%libomptarget-compileopt-and-run-generic",
244
            "%libomptarget-compileopt-and-run-" + libomptarget_target))
245
        config.substitutions.append(("%libomptarget-compileoptxx-generic",
246
            "%libomptarget-compileoptxx-" + libomptarget_target))
247
        config.substitutions.append(("%libomptarget-compileopt-generic",
248
            "%libomptarget-compileopt-" + libomptarget_target))
249
        config.substitutions.append(("%libomptarget-run-generic",
250
            "%libomptarget-run-" + libomptarget_target))
251
        config.substitutions.append(("%libomptarget-run-fail-generic",
252
            "%libomptarget-run-fail-" + libomptarget_target))
253
        config.substitutions.append(("%clangxx-generic",
254
            "%clangxx-" + libomptarget_target))
255
        config.substitutions.append(("%clang-generic",
256
            "%clang-" + libomptarget_target))
257
        config.substitutions.append(("%fcheck-generic",
258
            config.libomptarget_filecheck + " %s"))
259
        config.substitutions.append(("%fcheck-plain-generic",
260
            config.libomptarget_filecheck))
261

262

263
        config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
264
            libomptarget_target, \
265
            "%libomptarget-compilexx-and-run-" + libomptarget_target + \
266
            " | " + config.libomptarget_filecheck + " %s"))
267
        config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
268
            libomptarget_target, \
269
            "%libomptarget-compile-and-run-" + libomptarget_target + \
270
            " | " + config.libomptarget_filecheck + " %s"))
271
        config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-" + \
272
            libomptarget_target, \
273
            "%libomptarget-compile-fortran-and-run-" + libomptarget_target + \
274
            " | " + config.libomptarget_filecheck + " %s"))
275
        config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
276
            libomptarget_target, \
277
            "%libomptarget-compilexx-" + libomptarget_target + " && " + \
278
            "%libomptarget-run-" + libomptarget_target))
279
        config.substitutions.append(("%libomptarget-compile-and-run-" + \
280
            libomptarget_target, \
281
            "%libomptarget-compile-" + libomptarget_target + " && " + \
282
            "%libomptarget-run-" + libomptarget_target))
283
        config.substitutions.append(("%libomptarget-compile-fortran-and-run-" + \
284
            libomptarget_target, \
285
            "%libomptarget-compile-fortran-" + libomptarget_target + " && " + \
286
            "%libomptarget-run-" + libomptarget_target))
287
        config.substitutions.append(("%libomptarget-compilexx-" + \
288
            libomptarget_target, \
289
            "%clangxx-" + libomptarget_target + add_libraries(" %s -o %t")))
290
        config.substitutions.append(("%libomptarget-compilexxx-force-usm-" +
291
            libomptarget_target, "%clangxxx-force-usm-" + libomptarget_target + \
292
                                     add_libraries(" %s -o %t")))
293
        config.substitutions.append(("%libomptarget-compile-" + \
294
            libomptarget_target, \
295
            "%clang-" + libomptarget_target + add_libraries(" %s -o %t")))
296
        config.substitutions.append(("%libomptarget-compile-fortran-" + \
297
            libomptarget_target, \
298
            "%flang-" + libomptarget_target + add_libraries(" %s -o %t")))
299
        config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \
300
            libomptarget_target, \
301
            "%libomptarget-compileoptxx-and-run-" + libomptarget_target + \
302
            " | " + config.libomptarget_filecheck + " %s"))
303
        config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \
304
            libomptarget_target, \
305
            "%libomptarget-compileopt-and-run-" + libomptarget_target + \
306
            " | " + config.libomptarget_filecheck + " %s"))
307
        config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \
308
            libomptarget_target, \
309
            "%libomptarget-compileoptxx-" + libomptarget_target + " && " + \
310
            "%libomptarget-run-" + libomptarget_target))
311
        config.substitutions.append(("%libomptarget-compileopt-and-run-" + \
312
            libomptarget_target, \
313
            "%libomptarget-compileopt-" + libomptarget_target + " && " + \
314
            "%libomptarget-run-" + libomptarget_target))
315
        config.substitutions.append(("%libomptarget-compileoptxx-" + \
316
            libomptarget_target, \
317
            "%clangxx-" + libomptarget_target + add_libraries(" -O3 %s -o %t")))
318
        config.substitutions.append(("%libomptarget-compileopt-" + \
319
            libomptarget_target, \
320
            "%clang-" + libomptarget_target + add_libraries(" -O3 %s -o %t")))
321
        config.substitutions.append(("%libomptarget-run-" + \
322
            libomptarget_target, \
323
            "%t"))
324
        config.substitutions.append(("%libomptarget-run-fail-" + \
325
            libomptarget_target, \
326
            "%not --crash %t"))
327
        config.substitutions.append(("%clangxx-" + libomptarget_target, \
328
                                     "%clangxx %openmp_flags %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
329
                                     remove_suffix_if_present(libomptarget_target)))
330
        config.substitutions.append(("%clangxxx-force-usm-" + libomptarget_target, \
331
                                     "%clangxx %openmp_flags -fopenmp-force-usm  %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
332
                                     remove_suffix_if_present(libomptarget_target)))
333
        config.substitutions.append(("%clang-" + libomptarget_target, \
334
                                     "%clang %openmp_flags %cuda_flags %flags %flags_clang -fopenmp-targets=" +\
335
                                     remove_suffix_if_present(libomptarget_target)))
336
        config.substitutions.append(("%flang-" + libomptarget_target, \
337
                                     "%flang %openmp_flags %flags %flags_flang -fopenmp-targets=" +\
338
                                     remove_suffix_if_present(libomptarget_target)))
339
        config.substitutions.append(("%fcheck-" + libomptarget_target, \
340
            config.libomptarget_filecheck + " %s"))
341
    else:
342
        config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
343
            libomptarget_target, \
344
            "echo ignored-command"))
345
        config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-" + \
346
            libomptarget_target, \
347
            "echo ignored-command"))
348
        config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
349
            libomptarget_target, \
350
            "echo ignored-command"))
351
        config.substitutions.append(("%libomptarget-compile-and-run-" + \
352
            libomptarget_target, \
353
            "echo ignored-command"))
354
        config.substitutions.append(("%libomptarget-compile-fortran-and-run-" + \
355
            libomptarget_target, \
356
            "echo ignored-command"))
357
        config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
358
            libomptarget_target, \
359
            "echo ignored-command"))
360
        config.substitutions.append(("%libomptarget-compilexx-" + \
361
            libomptarget_target, \
362
            "echo ignored-command"))
363
        config.substitutions.append(("%libomptarget-compile-" + \
364
            libomptarget_target, \
365
            "echo ignored-command"))
366
        config.substitutions.append(("%libomptarget-compile-fortran-" + \
367
            libomptarget_target, \
368
            "echo ignored-command"))
369
        config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \
370
            libomptarget_target, \
371
            "echo ignored-command"))
372
        config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \
373
            libomptarget_target, \
374
            "echo ignored-command"))
375
        config.substitutions.append(("%libomptarget-compileopt-and-run-" + \
376
            libomptarget_target, \
377
            "echo ignored-command"))
378
        config.substitutions.append(("%libomptarget-compileoptxx-and-run-" + \
379
            libomptarget_target, \
380
            "echo ignored-command"))
381
        config.substitutions.append(("%libomptarget-compileoptxx-" + \
382
            libomptarget_target, \
383
            "echo ignored-command"))
384
        config.substitutions.append(("%libomptarget-compileopt-" + \
385
            libomptarget_target, \
386
            "echo ignored-command"))
387
        config.substitutions.append(("%libomptarget-run-" + \
388
            libomptarget_target, \
389
            "echo ignored-command"))
390
        config.substitutions.append(("%libomptarget-run-fail-" + \
391
            libomptarget_target, \
392
            "echo ignored-command"))
393
        config.substitutions.append(("%clang-" + libomptarget_target, \
394
            "echo ignored-command"))
395
        config.substitutions.append(("%clangxx-" + libomptarget_target, \
396
            "echo ignored-command"))
397
        config.substitutions.append(("%fcheck-" + libomptarget_target, \
398
            "echo ignored-command"))
399
        config.substitutions.append(("%flang-" + libomptarget_target, \
400
            "echo ignored-command"))
401

402
config.substitutions.append(("%clangxx", config.test_cxx_compiler))
403
config.substitutions.append(("%clang", config.test_c_compiler))
404

405
if config.test_fortran_compiler:
406
    config.available_features.add('flang')
407
    config.substitutions.append(("%flang", config.test_fortran_compiler))
408

409
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
410
if config.libomptarget_current_target.startswith('nvptx') and config.cuda_path:
411
    config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path))
412
else:
413
    config.substitutions.append(("%cuda_flags", ""))
414
config.substitutions.append(("%flags_clang", config.test_flags_clang))
415
config.substitutions.append(("%flags_flang", config.test_flags_flang))
416
config.substitutions.append(("%flags", config.test_flags))
417
config.substitutions.append(("%not", config.libomptarget_not))
418

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.