|
27 | 27 | config.suffixes = ['.c', '.cpp', '.dump'] #add .spv. Currently not clear what to do with those
|
28 | 28 |
|
29 | 29 | # feature tests are considered not so lightweight, so, they are excluded by default
|
30 |
| -config.excludes = ['Inputs', 'feature-tests'] |
| 30 | +config.excludes = ['Inputs', 'feature-tests', 'on-device'] |
31 | 31 |
|
32 | 32 | # test_source_root: The root path where tests are located.
|
33 | 33 | config.test_source_root = os.path.dirname(__file__)
|
|
75 | 75 |
|
76 | 76 | llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])
|
77 | 77 |
|
78 |
| -backend=lit_config.params.get('SYCL_PLUGIN', "opencl") |
79 |
| -lit_config.note("Backend: {}".format(backend)) |
80 |
| -config.substitutions.append( ('%sycl_be', { 'opencl': 'PI_OPENCL', 'cuda': 'PI_CUDA', 'level_zero': 'PI_LEVEL_ZERO'}[backend]) ) |
81 |
| -config.substitutions.append( ('%BE_RUN_PLACEHOLDER', "env SYCL_DEVICE_FILTER={SYCL_PLUGIN} ".format(SYCL_PLUGIN=backend)) ) |
82 | 78 | config.substitutions.append( ('%RUN_ON_HOST', "env SYCL_DEVICE_FILTER=host ") )
|
83 | 79 |
|
84 |
| -get_device_count_by_type_path = os.path.join(config.llvm_tools_dir, "get_device_count_by_type") |
85 |
| - |
86 |
| -def getDeviceCount(device_type): |
87 |
| - is_cuda = False; |
88 |
| - is_level_zero = False; |
89 |
| - process = subprocess.Popen([get_device_count_by_type_path, device_type, backend], |
90 |
| - stdout=subprocess.PIPE) |
91 |
| - (output, err) = process.communicate() |
92 |
| - exit_code = process.wait() |
93 |
| - |
94 |
| - if exit_code != 0: |
95 |
| - lit_config.error("getDeviceCount {TYPE} {BACKEND}: Non-zero exit code {CODE}".format( |
96 |
| - TYPE=device_type, BACKEND=backend, CODE=exit_code)) |
97 |
| - return [0,False,False] |
98 |
| - |
99 |
| - result = output.decode().replace('\n', '').split(':', 1) |
100 |
| - try: |
101 |
| - value = int(result[0]) |
102 |
| - except ValueError: |
103 |
| - value = 0 |
104 |
| - lit_config.error("getDeviceCount {TYPE} {BACKEND}: Cannot get value from output: {OUT}".format( |
105 |
| - TYPE=device_type, BACKEND=backend, OUT=result[0])) |
106 |
| - |
107 |
| - # if we have found gpu and there is additional information, let's check |
108 |
| - # whether this is CUDA device or Level Zero device or none of these. |
109 |
| - if device_type == "gpu" and value > 0 and len(result[1]): |
110 |
| - if re.match(r".*cuda", result[1]): |
111 |
| - is_cuda = True; |
112 |
| - if re.match(r".*level zero", result[1]): |
113 |
| - is_level_zero = True; |
114 |
| - |
115 |
| - if err: |
116 |
| - lit_config.warning("getDeviceCount {TYPE} {BACKEND} stderr:{ERR}".format( |
117 |
| - TYPE=device_type, BACKEND=backend, ERR=err)) |
118 |
| - return [value,is_cuda,is_level_zero] |
119 |
| - |
120 | 80 | # Every SYCL implementation provides a host implementation.
|
121 | 81 | config.available_features.add('host')
|
122 |
| - |
123 |
| -# Configure device-specific substitutions based on availability of corresponding |
124 |
| -# devices/runtimes |
125 |
| - |
126 |
| -found_at_least_one_device = False |
127 |
| - |
128 |
| -cpu_run_substitute = "true" |
129 |
| -cpu_run_on_linux_substitute = "true " |
130 |
| -cpu_check_substitute = "" |
131 |
| -cpu_check_on_linux_substitute = "" |
132 |
| - |
133 |
| -if getDeviceCount("cpu")[0]: |
134 |
| - found_at_least_one_device = True |
135 |
| - lit_config.note("Found available CPU device") |
136 |
| - cpu_run_substitute = "env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:cpu ".format(SYCL_PLUGIN=backend) |
137 |
| - cpu_check_substitute = "| FileCheck %s" |
138 |
| - config.available_features.add('cpu') |
139 |
| - if platform.system() == "Linux": |
140 |
| - cpu_run_on_linux_substitute = "env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:cpu ".format(SYCL_PLUGIN=backend) |
141 |
| - cpu_check_on_linux_substitute = "| FileCheck %s" |
142 |
| -else: |
143 |
| - lit_config.warning("CPU device not found") |
144 |
| - |
145 |
| -config.substitutions.append( ('%CPU_RUN_PLACEHOLDER', cpu_run_substitute) ) |
146 |
| -config.substitutions.append( ('%CPU_RUN_ON_LINUX_PLACEHOLDER', cpu_run_on_linux_substitute) ) |
147 |
| -config.substitutions.append( ('%CPU_CHECK_PLACEHOLDER', cpu_check_substitute) ) |
148 |
| -config.substitutions.append( ('%CPU_CHECK_ON_LINUX_PLACEHOLDER', cpu_check_on_linux_substitute) ) |
149 |
| - |
150 |
| -gpu_run_substitute = "true" |
151 |
| -gpu_run_on_linux_substitute = "true " |
152 |
| -gpu_check_substitute = "" |
153 |
| -gpu_check_on_linux_substitute = "" |
154 |
| - |
155 |
| -cuda = False |
156 |
| -level_zero = False |
157 |
| -[gpu_count, cuda, level_zero] = getDeviceCount("gpu") |
158 |
| - |
159 |
| -if gpu_count > 0: |
160 |
| - found_at_least_one_device = True |
161 |
| - lit_config.note("Found available GPU device") |
162 |
| - gpu_run_substitute = " env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:gpu ".format(SYCL_PLUGIN=backend) |
163 |
| - gpu_check_substitute = "| FileCheck %s" |
164 |
| - config.available_features.add('gpu') |
165 |
| - if cuda: |
166 |
| - config.available_features.add('cuda') |
167 |
| - elif level_zero: |
168 |
| - config.available_features.add('level_zero') |
169 |
| - |
170 |
| - if platform.system() == "Linux": |
171 |
| - gpu_run_on_linux_substitute = "env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:gpu ".format(SYCL_PLUGIN=backend) |
172 |
| - gpu_check_on_linux_substitute = "| FileCheck %s" |
173 |
| - # ESIMD-specific setup. Requires OpenCL for now. |
174 |
| - esimd_run_substitute = " env SYCL_DEVICE_FILTER=opencl:gpu SYCL_PROGRAM_COMPILE_OPTIONS=-vc-codegen" |
175 |
| - config.substitutions.append( ('%ESIMD_RUN_PLACEHOLDER', esimd_run_substitute) ) |
176 |
| - config.substitutions.append( ('%clangxx-esimd', "clang++ -fsycl-explicit-simd" ) ) |
177 |
| -else: |
178 |
| - lit_config.warning("GPU device not found") |
179 |
| - |
180 |
| -config.substitutions.append( ('%GPU_RUN_PLACEHOLDER', gpu_run_substitute) ) |
181 |
| -config.substitutions.append( ('%GPU_RUN_ON_LINUX_PLACEHOLDER', gpu_run_on_linux_substitute) ) |
182 |
| -config.substitutions.append( ('%GPU_CHECK_PLACEHOLDER', gpu_check_substitute) ) |
183 |
| -config.substitutions.append( ('%GPU_CHECK_ON_LINUX_PLACEHOLDER', gpu_check_on_linux_substitute) ) |
184 |
| - |
185 |
| -acc_run_substitute = "true" |
186 |
| -acc_check_substitute = "" |
187 |
| -if getDeviceCount("accelerator")[0]: |
188 |
| - found_at_least_one_device = True |
189 |
| - lit_config.note("Found available accelerator device") |
190 |
| - acc_run_substitute = " env SYCL_DEVICE_FILTER={SYCL_PLUGIN}:acc ".format(SYCL_PLUGIN=backend) |
191 |
| - acc_check_substitute = "| FileCheck %s" |
192 |
| - config.available_features.add('accelerator') |
193 |
| -else: |
194 |
| - lit_config.warning("Accelerator device not found") |
195 |
| -config.substitutions.append( ('%ACC_RUN_PLACEHOLDER', acc_run_substitute) ) |
196 |
| -config.substitutions.append( ('%ACC_CHECK_PLACEHOLDER', acc_check_substitute) ) |
197 |
| - |
198 |
| -# LIT testing either supports OpenCL or CUDA or Level Zero. |
199 |
| -if not cuda and not level_zero and found_at_least_one_device: |
200 |
| - config.available_features.add('opencl') |
201 |
| - |
202 |
| -if cuda: |
203 |
| - config.substitutions.append( ('%sycl_triple', "nvptx64-nvidia-cuda-sycldevice" ) ) |
204 |
| -else: |
205 |
| - config.substitutions.append( ('%sycl_triple', "spir64-unknown-linux-sycldevice" ) ) |
206 |
| - |
207 |
| -if "opencl-aot" in config.llvm_enable_projects: |
208 |
| - lit_config.note("Using opencl-aot version which is built as part of the project") |
209 |
| - config.available_features.add("opencl-aot") |
210 |
| - llvm_config.add_tool_substitutions(['opencl-aot'], [config.sycl_tools_dir]) |
211 |
| - |
212 |
| -# Device AOT compilation tools aren't part of the SYCL project, |
213 |
| -# so they need to be pre-installed on the machine |
214 |
| -aot_tools = ["ocloc", "aoc"] |
215 |
| -if "opencl-aot" not in config.llvm_enable_projects: |
216 |
| - aot_tools.append('opencl-aot') |
217 |
| - |
218 |
| -for aot_tool in aot_tools: |
219 |
| - if find_executable(aot_tool) is not None: |
220 |
| - lit_config.note("Found pre-installed AOT device compiler " + aot_tool) |
221 |
| - config.available_features.add(aot_tool) |
222 |
| - else: |
223 |
| - lit_config.warning("Couldn't find pre-installed AOT device compiler " + aot_tool) |
| 82 | +triple=lit_config.params.get('SYCL_TRIPLE', 'spir64-unknown-linux-sycldevice') |
| 83 | +lit_config.note("Triple: {}".format(triple)) |
| 84 | +config.substitutions.append( ('%sycl_triple', triple ) ) |
224 | 85 |
|
225 | 86 | # Set timeout for test = 10 mins
|
226 | 87 | try:
|
|
0 commit comments