Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit e2f949c

Browse files
authored
[SYCL] Make LIT use compiler provided by user (#69)
%clangxx and %clang were always set to clang which is not expected. After the fix the substitutions above are set to the compiler passed by the user. The change exposed several issues with existing change which were fixed: * Fix build of tests requiring OpenCL ICD loader * Fix windows specific test * Disable unsupported tests * Fix tests which are not functional with clang-cl
1 parent 3774ac0 commit e2f949c

19 files changed

+60
-31
lines changed

SYCL/Basic/device_code_dae.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE A temporary test before this compilation flow is enabled by default in
22
// driver
3-
// UNSUPPORTED: cuda
3+
// UNSUPPORTED: cuda,cl_options
44
// CUDA does not support SPIR-V.
55
// RUN: %clangxx -fsycl-device-only -Xclang -fenable-sycl-dae -Xclang -fsycl-int-header=int_header.h %s -c -o device_code.bc -I %sycl_include -Wno-sycl-strict
66
// RUN: %clangxx -include int_header.h -g -c %s -o host_code.o -I %sycl_include -Wno-sycl-strict

SYCL/Basic/fpga_tests/fpga_aocx_win.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
//===----------------------------------------------------------------------===//
88

99
// REQUIRES: aoc, accelerator
10-
// REQUIRES: system-windows
10+
// REQUIRES: system-windows, cl_options
1111

1212
/// E2E test for AOCX creation/use/run for FPGA
1313
// Produce an archive with device (AOCX) image. To avoid appending objects to
1414
// leftover archives, remove one if exists.
1515
// RUN: rm %t_image.a || true
16-
// RUN: %clang_cl -fsycl -fintelfpga -fsycl-link=image %S/Inputs/fpga_device.cpp -o %t_image.lib
16+
// RUN: %clangxx -fsycl -fintelfpga -fsycl-link=image %S/Inputs/fpga_device.cpp -o %t_image.lib
1717
// Produce a host object
18-
// RUN: %clang_cl -fsycl -fintelfpga -DHOST_PART %S/Inputs/fpga_host.cpp -c -o %t.obj
18+
// RUN: %clangxx -fsycl -fintelfpga -DHOST_PART %S/Inputs/fpga_host.cpp -c -o %t.obj
1919

2020
// AOCX with source
21-
// RUN: %clang_cl -fsycl -fintelfpga -DHOST_PART %S/Inputs/fpga_host.cpp %t_image.lib -o %t_aocx_src.out
21+
// RUN: %clangxx -fsycl -fintelfpga -DHOST_PART %S/Inputs/fpga_host.cpp %t_image.lib -o %t_aocx_src.out
2222
// AOCX with object
23-
// RUN: %clang_cl -fsycl -fintelfpga %t.obj %t_image.lib -o %t_aocx_obj.out
23+
// RUN: %clangxx -fsycl -fintelfpga %t.obj %t_image.lib -o %t_aocx_obj.out
2424
//
2525
// RUN: env SYCL_DEVICE_TYPE=ACC %t_aocx_src.out
2626
// RUN: env SYCL_DEVICE_TYPE=ACC %t_aocx_obj.out

SYCL/Basic/fpga_tests/fpga_queue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// REQUIRES: opencl
1+
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
44
// RUN: %HOST_RUN_PLACEHOLDER %t.out
55
// RUN: %ACC_RUN_PLACEHOLDER %t.out
66
// RUN: %CPU_RUN_PLACEHOLDER %t.out

SYCL/Basic/handler/interop_task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// REQUIRES: opencl
2-
// RUN: %clangxx -fsycl %s -o %t.out -L %opencl_libs_dir -lOpenCL
1+
// REQUIRES: opencl, opencl_icd
2+
// RUN: %clangxx -fsycl %s -o %t.out %opencl_lib
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out
55

SYCL/Basic/sampler/sampler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-dead-args-optimization %s -o %t.out -L %opencl_libs_dir -lOpenCL
1+
// REQUIRES: opencl, opencl_icd
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-dead-args-optimization %s -o %t.out %opencl_lib
23
// RUN: %HOST_RUN_PLACEHOLDER %t.out
34
// RUN: %CPU_RUN_PLACEHOLDER %t.out
45
// RUN: %GPU_RUN_PLACEHOLDER %t.out

SYCL/Basic/sampler/sampler_ocl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// REQUIRES: opencl
1+
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out
66
// RUN: %ACC_RUN_PLACEHOLDER %t.out

SYCL/Config/kernel_from_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// UNSUPPORTED: cuda
1+
// UNSUPPORTED: cuda,cl_options
22
// CUDA does not support SPIR-V.
33

44
// RUN: %clangxx -fsycl-device-only -fno-sycl-use-bitcode -Xclang -fsycl-int-header=%t.h -c %s -o %t.spv -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning -Wno-sycl-strict

SYCL/DeviceLib/separate_compile_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
// RUN: %clangxx %t_fp64_host.o %t_fp64_device.o -o %t_fp64.out -lsycl
1414
// RUN: %CPU_RUN_PLACEHOLDER %t_fp64.out
1515
// RUN: %ACC_RUN_PLACEHOLDER %t_fp64.out
16+
// UNSUPPORTED: cl_options

SYCL/InorderQueue/in_order_buffs_ocl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: opencl_icd,opencl
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
33
// RUN: %ACC_RUN_PLACEHOLDER %t.out
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t.out

SYCL/InorderQueue/in_order_dmemll_ocl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: opencl_icd,opencl
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out -L %opencl_libs_dir -lOpenCL
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out %opencl_lib
33
// RUN: %CPU_RUN_PLACEHOLDER %t1.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t1.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t1.out

SYCL/InorderQueue/prop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: opencl_icd,opencl
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out -L %opencl_libs_dir -lOpenCL
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out %opencl_lib
33
// RUN: %CPU_RUN_PLACEHOLDER %t1.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t1.out
55
// RUN: %GPU_RUN_PLACEHOLDER %t1.out

SYCL/KernelAndProgram/kernel-and-program-interop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// REQUIRES: opencl, opencl_icd
22

3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -L %opencl_libs_dir -lOpenCL
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
44
// RUN: %HOST_RUN_PLACEHOLDER %t.out
55
// RUN: %CPU_RUN_PLACEHOLDER %t.out
66
// RUN: %GPU_RUN_PLACEHOLDER %t.out

SYCL/Regression/cache_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %GPU_RUN_PLACEHOLDER %t.out
33

44
// REQUIRES: level_zero
5+
// UNSUPPORTED: cl_options
56

67
#include <algorithm>
78
#include <level_zero/ze_api.h>

SYCL/Regression/msvc_crt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// RUN: %clang_cl -fsycl /MD -o %t1.exe %s
1+
// RUN: %clangxx -fsycl /MD -o %t1.exe %s
22
// RUN: %HOST_RUN_PLACEHOLDER %t1.exe
33
// RUN: %CPU_RUN_PLACEHOLDER %t1.exe
44
// RUN: %GPU_RUN_PLACEHOLDER %t1.exe
55
// RUN: %ACC_RUN_PLACEHOLDER %t1.exe
6-
// RUN: %clang_cl -fsycl /MDd -o %t2.exe %s
6+
// RUN: %clangxx -fsycl /MDd -o %t2.exe %s
77
// RUN: %HOST_RUN_PLACEHOLDER %t2.exe
88
// RUN: %CPU_RUN_PLACEHOLDER %t2.exe
99
// RUN: %GPU_RUN_PLACEHOLDER %t2.exe
1010
// RUN: %ACC_RUN_PLACEHOLDER %t2.exe
11-
// REQUIRES: system-windows
11+
// REQUIRES: system-windows, cl_options
1212
//==-------------- msvc_crt.cpp - SYCL MSVC CRT test -----------------------==//
1313
//
1414
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

SYCL/SeparateCompile/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// UNSUPPORTED: cuda
1+
// UNSUPPORTED: cuda,cl_options
22
// CUDA does not support SPIR-V.
33
//
44
// >> ---- compile src1

SYCL/USM/source_kernel_indirect_access.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -lOpenCL %s -o %t1.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %opencl_lib %s -o %t1.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t1.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t1.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t1.out
5-
// REQUIRES: opencl
5+
// REQUIRES: opencl,opencl_icd
66

77
#include <CL/cl.h>
88
#include <CL/sycl.hpp>

SYCL/lit.cfg.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@
3434
# test_exec_root: The root path where tests should be run.
3535
config.test_exec_root = config.sycl_obj_root
3636

37-
llvm_config.use_clang()
37+
# Cleanup environment variables which may affect tests
38+
possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
39+
'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
40+
'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
41+
'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
42+
'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
43+
'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
44+
'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
45+
'LIBCLANG_RESOURCE_USAGE',
46+
'LIBCLANG_CODE_COMPLETION_LOGGING']
47+
# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
48+
if platform.system() != 'Windows':
49+
possibly_dangerous_env_vars.append('INCLUDE')
50+
51+
for name in possibly_dangerous_env_vars:
52+
if name in llvm_config.config.environment:
53+
del llvm_config.config.environment[name]
3854

3955
# Propagate some variables from the host environment.
4056
llvm_config.with_system_environment(['PATH', 'OCL_ICD_FILENAMES',
@@ -77,9 +93,20 @@
7793

7894
config.substitutions.append( ('%sycl_libs_dir', config.sycl_libs_dir ) )
7995
config.substitutions.append( ('%sycl_include', config.sycl_include ) )
96+
97+
# check if compiler supports CL command line options
98+
cl_options=False
99+
sp = subprocess.getstatusoutput(config.dpcpp_compiler+' /help')
100+
if sp[0] == 0:
101+
cl_options=True
102+
config.available_features.add('cl_options')
103+
80104
if config.opencl_libs_dir:
81-
config.substitutions.append( ('%opencl_libs_dir', config.opencl_libs_dir) )
82-
config.available_features.add('opencl_icd')
105+
if cl_options:
106+
config.substitutions.append( ('%opencl_lib', ' '+config.opencl_libs_dir+'/OpenCL.lib') )
107+
else:
108+
config.substitutions.append( ('%opencl_lib', '-L'+config.opencl_libs_dir+' -lOpenCL') )
109+
config.available_features.add('opencl_icd')
83110
config.substitutions.append( ('%opencl_include_dir', config.opencl_include_dir) )
84111

85112
llvm_config.add_tool_substitutions(['llvm-spirv'], [config.sycl_tools_dir])
@@ -108,15 +135,14 @@
108135

109136
esimd_run_substitute = "env SYCL_BE={SYCL_BE} SYCL_DEVICE_TYPE=GPU SYCL_PROGRAM_COMPILE_OPTIONS=-vc-codegen".format(SYCL_BE=config.sycl_be)
110137
config.substitutions.append( ('%ESIMD_RUN_PLACEHOLDER', esimd_run_substitute) )
138+
111139
config.substitutions.append( ('%clangxx-esimd', config.dpcpp_compiler +
112140
' ' + '-fsycl-explicit-simd' + ' ' +
113141
config.cxx_flags ) )
114-
115142
config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags ) )
116143
config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags ) )
117144
config.substitutions.append( ('%threads_lib', config.sycl_threads_lib) )
118145

119-
120146
# Configure device-specific substitutions based on availability of corresponding
121147
# devices/runtimes
122148

cmake/caches/clang_fsycl.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Default open source clang configuration with SYCL support.
22

33
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
4-
set(CMAKE_CXX_FLAGS "-fsycl" CACHE STRING "")
4+
set(CMAKE_CXX_FLAGS "" CACHE STRING "")

cmake/caches/clang_fsycl_cuda.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Default open source clang configuration with SYCL support.
22

33
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
4-
set(CMAKE_CXX_FLAGS "-fsycl -fsycl-targets=nvptx64-nvidia-cuda-sycldevice -Xsycl-target-backend --cuda-gpu-arch=sm_32" CACHE STRING "")
4+
set(CMAKE_CXX_FLAGS "-fsycl-targets=nvptx64-nvidia-cuda-sycldevice -Xsycl-target-backend --cuda-gpu-arch=sm_32" CACHE STRING "")

0 commit comments

Comments
 (0)