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

Commit 64b461b

Browse files
committed
Use sycl.hpp workaround only if compiler doesn't have it
1 parent b405c81 commit 64b461b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

SYCL/lit.cfg.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,22 @@
188188
else:
189189
arch_flag = ""
190190

191-
# extra_include points to sycl/sycl.hpp location to workaround compiler
192-
# versions which supports only CL/sycl.hpp
193-
config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + ' ' + ( "/I" if cl_options else "-I") + config.extra_include ) )
194-
config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + ( "/I" if cl_options else "-I") + config.extra_include ) )
191+
# Add an extra include directory which points to a fake sycl/sycl.hpp (which just points to CL/sycl.hpp)
192+
# location to workaround compiler versions which do not provide this header
193+
check_sycl_hpp_file='sycl_hpp_include.cpp'
194+
with open(check_sycl_hpp_file, 'w') as fp:
195+
fp.write('#include <sycl/sycl.hpp>\n')
196+
fp.write('int main() {}')
197+
198+
extra_sycl_include = ""
199+
sycl_hpp_available = subprocess.getstatusoutput(config.dpcpp_compiler+' -fsycl ' + check_sycl_hpp_file)
200+
if sp[0] != 0:
201+
extra_sycl_include = " " + ("/I" if cl_options else "-I") + config.extra_include
202+
203+
204+
config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + extra_sycl_include) )
205+
config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + extra_sycl_include) )
206+
195207
config.substitutions.append( ('%threads_lib', config.sycl_threads_lib) )
196208

197209
# Configure device-specific substitutions based on availability of corresponding

0 commit comments

Comments
 (0)