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