Skip to content

Commit 39501f6

Browse files
authored
[SYCL] Move SYCL headers from standard clang location (#1308)
SYCL headers were moved from default clang include directory (lib/clang/11.0.0/include) to (include/sycl) to support mixed compilers (e.g. gcc for host code and clang for device code) during build of SYCL application. Clang driver adds new directory to system include search path. For non-clang compilers the user should add option below to compiler command line to let it find SYCL headers: -I <path_to_sycl_compiler>/include/sycl Additional diagnostic can be raised depending on compiler which is used (see examples for clang below). It can be ignored. /localdisk2/bbsycl/res/include/sycl/CL/__spirv/spirv_ops.hpp:74:8: error: SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer parameter type [-Wsycl-strict] extern SYCL_EXTERNAL __ocl_event_t __spirv_GroupAsyncCopy( /localdisk2/bbsycl/res/include/sycl/CL/sycl/ordered_queue.hpp:267:37: warning: 'ordered_queue' is deprecated: Replaced by in_order queue property [-Wdeprecated-declarations] size_t operator()(const cl::sycl::ordered_queue &q) const { Signed-off-by: Vladimir Lazarev [email protected]
1 parent 6314bef commit 39501f6

35 files changed

+56
-50
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ SYCLToolChain::GetCXXStdlibType(const ArgList &Args) const {
532532

533533
void SYCLToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
534534
ArgStringList &CC1Args) const {
535+
SmallString<128> P(getDriver().getInstalledDir());
536+
llvm::sys::path::append(P, "..");
537+
llvm::sys::path::append(P, "include");
538+
llvm::sys::path::append(P, "sycl");
539+
CC1Args.push_back("-internal-isystem");
540+
CC1Args.push_back(DriverArgs.MakeArgString(P));
535541
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
536542
}
537543

clang/test/Driver/sycl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED
88

99
// ENABLED: "-cc1"{{.*}} "-fsycl-is-device"
10+
// ENABLED: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"
1011
// DISABLED-NOT: "-fsycl-is-device"
1112

1213
// RUN: %clang -### -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT

sycl/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ endif()
5454
# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
5555
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
5656

57-
set(LLVM_INST_INC_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include")
58-
set(dst_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
59-
set(dst_deploy_dir ${CMAKE_INSTALL_PREFIX}/lib/clang/${CLANG_VERSION}/include)
57+
set(SYCL_INCLUDE_DIR "include/sycl")
58+
set(SYCL_INCLUDE_BUILD_DIR ${LLVM_BINARY_DIR}/${SYCL_INCLUDE_DIR})
59+
set(SYCL_INCLUDE_DEPLOY_DIR ${CMAKE_INSTALL_PREFIX}/${SYCL_INCLUDE_DIR})
6060

6161
# Find OpenCL headers and libraries installed in the system and use them to
6262
# build SYCL runtime.
@@ -78,15 +78,15 @@ if( NOT OpenCL_INCLUDE_DIRS )
7878
GIT_TAG origin/master
7979
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/inc"
8080
CONFIGURE_COMMAND ""
81-
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${dst_dir}/CL
81+
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/CL
8282
INSTALL_COMMAND ""
8383
STEP_TARGETS build
8484
COMMENT "Downloading OpenCL headers."
8585
)
8686
else()
8787
add_custom_target( ocl-headers ALL
8888
DEPENDS ${OpenCL_INCLUDE_DIRS}
89-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${dst_dir}/CL
89+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${OpenCL_INCLUDE_DIRS}/CL ${SYCL_INCLUDE_BUILD_DIR}/CL
9090
COMMENT "Copying OpenCL headers ..."
9191
)
9292
endif()
@@ -137,7 +137,7 @@ target_include_directories(OpenCL-Headers
137137
INTERFACE ${OPENCL_INCLUDE}
138138
)
139139
install(DIRECTORY ${OPENCL_INCLUDE}/CL
140-
DESTINATION ${LLVM_INST_INC_DIRECTORY}
140+
DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR}
141141
COMPONENT opencl-headers
142142
)
143143

@@ -155,11 +155,11 @@ configure_file("${version_header}.in" "${version_header}")
155155

156156
# Copy SYCL headers
157157
add_custom_target(sycl-headers ALL
158-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${dst_dir}/CL
158+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${sycl_inc_dir}/CL ${SYCL_INCLUDE_BUILD_DIR}/CL
159159
COMMENT "Copying SYCL headers ...")
160160

161161
# Configure SYCL headers
162-
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)
162+
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION ${SYCL_INCLUDE_DEPLOY_DIR} COMPONENT sycl-headers)
163163

164164
set(SYCL_RT_LIBS sycl)
165165
if (MSVC)

sycl/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin/")
22

33
get_target_property(SYCL_BINARY_DIR sycl-toolchain BINARY_DIR)
44

5-
set(SYCL_INCLUDE "${dst_dir}")
5+
set(SYCL_INCLUDE "${SYCL_INCLUDE_BUILD_DIR}")
66

77
set(RT_TEST_ARGS ${RT_TEST_ARGS} "-v")
8-
set(DEPLOY_RT_TEST_ARGS ${DEPLOY_RT_TEST_ARGS} "-v -D SYCL_TOOLS_DIR=${CMAKE_INSTALL_PREFIX}/bin -D SYCL_LIBS_DIR=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX} -D SYCL_INCLUDE=${dst_deploy_dir}")
8+
set(DEPLOY_RT_TEST_ARGS ${DEPLOY_RT_TEST_ARGS} "-v -D SYCL_TOOLS_DIR=${CMAKE_INSTALL_PREFIX}/bin -D SYCL_LIBS_DIR=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX} -D SYCL_INCLUDE=${SYCL_INCLUDE_BUILD_DIR}")
99

1010
configure_lit_site_cfg(
1111
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in

sycl/test/basic_tests/buffer/buffer.cpp

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

3-
// RUN: %clangxx %s -o %t1.out -lsycl
3+
// RUN: %clangxx %s -o %t1.out -lsycl -I %sycl_include
44
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
55
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
66
// RUN: env SYCL_DEVICE_TYPE=HOST %t2.out

sycl/test/basic_tests/buffer/buffer_ctad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s
1+
// RUN: %clangxx -std=c++17 -fsyntax-only -Xclang -verify %s -I %sycl_include -Xclang -verify-ignore-unexpected=note,warning
22
// expected-no-diagnostics
33
//==------------------- buffer_ctad.cpp - SYCL buffer CTAD test ----------------==//
44
//

sycl/test/basic_tests/buffer/buffer_dev_to_dev.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/basic_tests/buffer/buffer_full_copy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clangxx %s -o %t1.out -lsycl
1+
// RUN: %clangxx %s -o %t1.out -lsycl -I %sycl_include
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
3-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
44
// RUN: env SYCL_DEVICE_TYPE=HOST %t2.out
55
// RUN: %CPU_RUN_PLACEHOLDER %t2.out
66
// RUN: %GPU_RUN_PLACEHOLDER %t2.out

sycl/test/basic_tests/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl
1+
// RUN: %clangxx %s -o %t.out -lsycl -I %sycl_include
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33

44
//==--------------- context.cpp - SYCL context test ------------------------==//

sycl/test/basic_tests/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx %s -o %t.out -lsycl
1+
// RUN: %clangxx %s -o %t.out -I %sycl_include -lsycl
22
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
33

44
//==--------------- device.cpp - SYCL device test --------------------------==//

0 commit comments

Comments
 (0)