From 64b461b58fd9322764c07696b44515462d121a85 Mon Sep 17 00:00:00 2001 From: Vlad Romanov Date: Thu, 2 Sep 2021 17:53:55 +0300 Subject: [PATCH 1/2] Use sycl.hpp workaround only if compiler doesn't have it --- SYCL/lit.cfg.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/SYCL/lit.cfg.py b/SYCL/lit.cfg.py index b4c078a3b9..e0002ec312 100644 --- a/SYCL/lit.cfg.py +++ b/SYCL/lit.cfg.py @@ -188,10 +188,22 @@ else: arch_flag = "" -# extra_include points to sycl/sycl.hpp location to workaround compiler -# versions which supports only CL/sycl.hpp -config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + ' ' + ( "/I" if cl_options else "-I") + config.extra_include ) ) -config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + ( "/I" if cl_options else "-I") + config.extra_include ) ) +# Add an extra include directory which points to a fake sycl/sycl.hpp (which just points to CL/sycl.hpp) +# location to workaround compiler versions which do not provide this header +check_sycl_hpp_file='sycl_hpp_include.cpp' +with open(check_sycl_hpp_file, 'w') as fp: + fp.write('#include \n') + fp.write('int main() {}') + +extra_sycl_include = "" +sycl_hpp_available = subprocess.getstatusoutput(config.dpcpp_compiler+' -fsycl ' + check_sycl_hpp_file) +if sp[0] != 0: + extra_sycl_include = " " + ("/I" if cl_options else "-I") + config.extra_include + + +config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + extra_sycl_include) ) +config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + extra_sycl_include) ) + config.substitutions.append( ('%threads_lib', config.sycl_threads_lib) ) # Configure device-specific substitutions based on availability of corresponding From 464d8ae1bb0ca331e1b342e286aad45ee2fa89bc Mon Sep 17 00:00:00 2001 From: Vlad Romanov Date: Thu, 2 Sep 2021 20:36:44 +0300 Subject: [PATCH 2/2] fix --- SYCL/lit.cfg.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SYCL/lit.cfg.py b/SYCL/lit.cfg.py index e0002ec312..4aae079fef 100644 --- a/SYCL/lit.cfg.py +++ b/SYCL/lit.cfg.py @@ -197,10 +197,9 @@ extra_sycl_include = "" sycl_hpp_available = subprocess.getstatusoutput(config.dpcpp_compiler+' -fsycl ' + check_sycl_hpp_file) -if sp[0] != 0: +if sycl_hpp_available != 0: extra_sycl_include = " " + ("/I" if cl_options else "-I") + config.extra_include - config.substitutions.append( ('%clangxx', ' '+ config.dpcpp_compiler + ' ' + config.cxx_flags + ' ' + arch_flag + extra_sycl_include) ) config.substitutions.append( ('%clang', ' ' + config.dpcpp_compiler + ' ' + config.c_flags + extra_sycl_include) )