Skip to content

Commit 67c6ae5

Browse files
valerydmitv-klochkov
authored andcommitted
[SYCL] Add OpenCL headers installation and implement deploy target (#567)
Added OpenCL headers to "install". Implemented deploy target. Minor build scripts cleanup. Signed-off-by: Valery N Dmitriev <[email protected]>
1 parent 8cc087e commit 67c6ae5

File tree

4 files changed

+88
-16
lines changed

4 files changed

+88
-16
lines changed

sycl/CMakeLists.txt

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ if( NOT OpenCL_LIBRARIES )
7171
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/icd_build"
7272
CONFIGURE_COMMAND ${CMAKE_COMMAND} "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/icd" -DCMAKE_INSTALL_LIBDIR:PATH=lib -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
7373
BUILD_COMMAND make C_INCLUDE_PATH=${CMAKE_CURRENT_BINARY_DIR}/OpenCL/inc
74-
INSTALL_COMMAND make install
74+
INSTALL_COMMAND make install
7575
STEP_TARGETS configure,build,install
7676
DEPENDS ocl-headers
7777
)
@@ -84,6 +84,16 @@ endif()
8484

8585
set(OPENCL_INCLUDE "${OpenCL_INCLUDE_DIRS}")
8686

87+
add_library (OpenCL-Headers INTERFACE)
88+
add_library (OpenCL::Headers ALIAS OpenCL-Headers)
89+
target_include_directories(OpenCL-Headers
90+
INTERFACE ${OPENCL_INCLUDE}
91+
)
92+
install(DIRECTORY ${OPENCL_INCLUDE}/CL
93+
DESTINATION ${LLVM_INST_INC_DIRECTORY}
94+
COMPONENT opencl-headers
95+
)
96+
8797
# Configure SYCL version macro
8898
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
8999
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
@@ -98,10 +108,6 @@ COMMENT "Copying SYCL headers ...")
98108
# Configure SYCL headers
99109
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)
100110

101-
# Configure OpenCL header and ICD loader
102-
include_directories(AFTER "${sycl_inc_dir}" "${OpenCL_INCLUDE_DIRS}")
103-
link_libraries(${OpenCL_LIBRARIES})
104-
105111
# SYCL runtime library
106112
add_subdirectory(source)
107113

@@ -126,3 +132,51 @@ add_custom_target( sycl-toolchain
126132
add_subdirectory( test )
127133
add_subdirectory( unittests )
128134
add_subdirectory( tools )
135+
136+
# Package deploy support
137+
# Listed here are component names contributing the package
138+
set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
139+
clang
140+
clang-offload-wrapper
141+
clang-offload-bundler
142+
llc
143+
llvm-as
144+
llvm-ar
145+
llvm-dis
146+
llvm-no-spir-kernel
147+
llvm-spirv
148+
llvm-link
149+
llvm-objcopy
150+
opt
151+
clang-resource-headers
152+
opencl-headers
153+
sycl-headers
154+
)
155+
156+
# Use it as fake dependency in order to force another command(s) to execute.
157+
add_custom_command(OUTPUT __force_it
158+
COMMAND "${CMAKE_COMMAND}" -E echo
159+
)
160+
#Serialize installation to avoid missing components due to build race conditions
161+
set(__chain_dep __force_it)
162+
163+
set(manifest_list)
164+
foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} )
165+
message( STATUS "Adding component ${comp} to deploy")
166+
167+
set (manifest_file ${CMAKE_CURRENT_BINARY_DIR}/install_manifest_${comp}.txt)
168+
add_custom_command(OUTPUT ${manifest_file}
169+
COMMAND "${CMAKE_COMMAND}"
170+
"-DCMAKE_INSTALL_COMPONENT=${comp}"
171+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
172+
DEPENDS ${__chain_dep}
173+
COMMENT "Deploying component ${comp}"
174+
USES_TERMINAL
175+
)
176+
list(APPEND manifest_list ${manifest_file})
177+
set(__chain_dep ${manifest_file})
178+
endforeach( comp )
179+
180+
add_custom_target(deploy-sycl-toolchain
181+
DEPENDS sycl-toolchain ${manifest_list}
182+
)

sycl/source/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#cmake_policy(SET CMP0057 NEW)
55
#include(AddLLVM)
66

7-
if(MSVC)
8-
add_definitions(-D__SYCL_BUILD_SYCL_DLL)
9-
endif()
10-
117
add_library(sycl SHARED
128
"${sycl_inc_dir}/CL/sycl.hpp"
139
"detail/builtins_common.cpp"
@@ -69,6 +65,14 @@ add_dependencies(sycl
6965

7066
set_target_properties(sycl PROPERTIES LINKER_LANGUAGE CXX)
7167

68+
if (MSVC)
69+
target_compile_definitions(sycl PRIVATE __SYCL_BUILD_SYCL_DLL )
70+
endif()
71+
target_include_directories(sycl PRIVATE "${sycl_inc_dir}")
72+
target_link_libraries(sycl
73+
PRIVATE OpenCL::Headers
74+
PRIVATE ${OpenCL_LIBRARIES}
75+
)
7276
if (SYCL_USE_LIBCXX)
7377
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
7478
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
@@ -88,9 +92,12 @@ else()
8892
# More information https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
8993
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
9094
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
91-
target_link_libraries(sycl gcc_s gcc)
95+
target_link_libraries(sycl PRIVATE gcc_s gcc)
9296
endif()
9397

9498
endif()
9599

96-
install(TARGETS sycl DESTINATION "lib" COMPONENT sycl)
100+
install(TARGETS sycl
101+
ARCHIVE DESTINATION "lib" COMPONENT sycl
102+
LIBRARY DESTINATION "lib" COMPONENT sycl
103+
RUNTIME DESTINATION "bin" COMPONENT sycl)

sycl/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ configure_lit_site_cfg(
2020
add_lit_testsuite(check-sycl "Running the SYCL regression tests"
2121
${CMAKE_CURRENT_BINARY_DIR}
2222
ARGS ${RT_TEST_ARGS}
23-
DEPENDS sycl-toolchain FileCheck get_device_count_by_type
23+
DEPENDS sycl-toolchain FileCheck get_device_count_by_type llvm-config
2424
)
2525
set_target_properties(check-sycl PROPERTIES FOLDER "SYCL tests")

sycl/tools/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ set(CMAKE_CXX_EXTENSIONS OFF)
44

55
add_executable(get_device_count_by_type get_device_count_by_type.cpp)
66
add_dependencies(get_device_count_by_type ocl-headers ocl-icd)
7-
#Minimum supported version of Intel's OCL GPU and CPU devices
8-
add_definitions(-D MIN_INTEL_OCL_GPU_VERSION=\\"18.47.11882\\")
9-
add_definitions(-D MIN_INTEL_OCL_CPU_VERSION=\\"18.1.0.0901\\",\\"7.6.0.1202\\")
7+
target_link_libraries(get_device_count_by_type
8+
PRIVATE OpenCL::Headers
9+
PRIVATE ${OpenCL_LIBRARIES}
10+
)
1011

1112
add_executable(sycl-check sycl-check.cpp)
1213
add_dependencies(sycl-check sycl)
13-
target_link_libraries(sycl-check sycl)
14+
target_include_directories(sycl-check PRIVATE "${sycl_inc_dir}")
15+
target_link_libraries(sycl-check
16+
PRIVATE sycl
17+
PRIVATE OpenCL::Headers
18+
PRIVATE ${OpenCL_LIBRARIES})
19+
20+
#Minimum supported version of Intel's OCL GPU and CPU devices
21+
target_compile_definitions(sycl-check
22+
PRIVATE MIN_INTEL_OCL_GPU_VERSION=\"18.47.11882\"
23+
PRIVATE MIN_INTEL_OCL_CPU_VERSION=\"18.1.0.0901\",\"7.6.0.1202\"
24+
)

0 commit comments

Comments
 (0)