Skip to content

Commit c8a1e67

Browse files
[NFC][CMake] Run SYCL generators only as needed (#7883)
The intent of this change is to reduce incremental build output and time. Use add_custom_target/command pairs to avoid generating build artifacts repeatedly. The artifacts will still be regenerated if an input changes.
1 parent 9314b3a commit c8a1e67

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

sycl/plugins/level_zero/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ endif()
6363

6464
find_package(Python3 REQUIRED)
6565

66-
add_custom_target(ze-api
66+
add_custom_target(ze-api DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ze_api.def)
67+
add_custom_command(
68+
OUTPUT
69+
${CMAKE_CURRENT_BINARY_DIR}/ze_api.def
6770
COMMAND ${Python3_EXECUTABLE}
6871
${CMAKE_CURRENT_SOURCE_DIR}/ze_api_generator.py
6972
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h
70-
BYPRODUCTS
71-
${CMAKE_CURRENT_BINARY_DIR}/ze_api.def
73+
DEPENDS
74+
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h
7275
)
7376

7477
find_package(Threads REQUIRED)

sycl/tools/sycl-trace/CMakeLists.txt

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ add_library(sycl_pi_trace_collector SHARED
3232
find_package(Python3 REQUIRED)
3333

3434
add_custom_target(pi-pretty-printers
35+
DEPENDS
36+
${CMAKE_CURRENT_BINARY_DIR}/pi_printers.def
37+
${CMAKE_CURRENT_BINARY_DIR}/pi_structs.hpp
38+
)
39+
add_custom_command(
40+
OUTPUT
41+
${CMAKE_CURRENT_BINARY_DIR}/pi_printers.def
42+
${CMAKE_CURRENT_BINARY_DIR}/pi_structs.hpp
3543
COMMAND ${Python3_EXECUTABLE}
3644
${CMAKE_CURRENT_SOURCE_DIR}/generate_pi_pretty_printers.py
3745
${sycl_inc_dir}/sycl/detail/pi.h
38-
SOURCES ${sycl_inc_dir}/sycl/detail/pi.h
39-
BYPRODUCTS
40-
${CMAKE_CURRENT_BINARY_DIR}/pi_structs.hpp
41-
${CMAKE_CURRENT_BINARY_DIR}/pi_printers.def
46+
DEPENDS ${sycl_inc_dir}/sycl/detail/pi.h
4247
)
4348

4449
# To get L0 loader
@@ -49,12 +54,17 @@ if ("level_zero" IN_LIST SYCL_ENABLE_PLUGINS)
4954
target_compile_definitions(sycl_pi_trace_collector PRIVATE SYCL_HAS_LEVEL_ZERO)
5055

5156
add_custom_target(ze-pretty-printers
57+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ze_printers.def
58+
)
59+
add_custom_command(
60+
OUTPUT
61+
${CMAKE_CURRENT_BINARY_DIR}/ze_printers.def
5262
COMMAND ${Python3_EXECUTABLE}
5363
${CMAKE_CURRENT_SOURCE_DIR}/generate_ze_pretty_printers.py
5464
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h
55-
DEPENDS pi_level_zero
56-
BYPRODUCTS
57-
${CMAKE_CURRENT_BINARY_DIR}/ze_printers.def
65+
DEPENDS
66+
pi_level_zero
67+
${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h
5868
)
5969

6070
add_dependencies(sycl_pi_trace_collector ze-pretty-printers)
@@ -113,13 +123,16 @@ if(SYCL_BUILD_PI_CUDA)
113123
NO_DEFAULT_PATH)
114124

115125
if( EXISTS "${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h" )
116-
add_custom_target(cuda-pretty-printers
117-
COMMAND ${Python3_EXECUTABLE}
118-
${CMAKE_CURRENT_SOURCE_DIR}/generate_cuda_pretty_printers.py
119-
${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h
120-
DEPENDS pi_cuda
121-
BYPRODUCTS
122-
${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def
126+
add_custom_target(cuda-pretty-printers
127+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def)
128+
add_custom_command(
129+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def
130+
COMMAND ${Python3_EXECUTABLE}
131+
${CMAKE_CURRENT_SOURCE_DIR}/generate_cuda_pretty_printers.py
132+
${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h
133+
DEPENDS
134+
pi_cuda
135+
${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h
123136
)
124137
else()
125138
message(WARNING "generated_cuda_meta.h not FOUND!")

0 commit comments

Comments
 (0)