Skip to content

Commit f23971a

Browse files
authored
Properly export ET_USE_THREADPOOL from the threadpool extension (#8947)
We had a bunch of targets that would define this macro ad-hoc. It's supposed to indicate that the threadpool extension is available, so just make sure that we have it as a PUBLIC target_compile_definition in CMake and an exported_preprocessor_flags entry in Buck for extension_threadpool. Test Plan: CI on following NOCOMMIT PR, which fails builds if ET_USE_THREADPOOL is not defined in affected places. Needed for #8932.
1 parent b8f66f9 commit f23971a

File tree

7 files changed

+6
-8
lines changed

7 files changed

+6
-8
lines changed

build/executorch-config.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,6 @@ if(TARGET cpublas)
141141
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel
142142
)
143143
endif()
144+
if(TARGET extension_threadpool)
145+
target_compile_definitions(extension_threadpool INTERFACE ET_USE_THREADPOOL)
146+
endif()

examples/models/llama/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ endif()
131131
set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
132132
# Extra compile option and include dir for pthreadpool
133133
if(EXECUTORCH_BUILD_PTHREADPOOL)
134-
list(APPEND _common_compile_options -DET_USE_THREADPOOL)
135134
list(APPEND link_libraries extension_threadpool pthreadpool)
136135
list(APPEND _common_include_directories
137136
${XNNPACK_ROOT}/third-party/pthreadpool/include

examples/models/llava/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ endif()
130130
set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
131131
# Extra compile option and include dir for pthreadpool
132132
if(EXECUTORCH_BUILD_PTHREADPOOL)
133-
list(APPEND _common_compile_options -DET_USE_THREADPOOL)
134133
list(APPEND link_libraries extension_threadpool pthreadpool)
135134
list(APPEND _common_include_directories
136135
${XNNPACK_ROOT}/third-party/pthreadpool/include

examples/models/llava/targets.bzl

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ def define_common_targets():
77
"main.cpp",
88
],
99
compiler_flags = ["-Wno-global-constructors"],
10-
preprocessor_flags = [
11-
"-DET_USE_THREADPOOL",
12-
],
1310
deps = [
1411
"//executorch/examples/models/llava/runner:runner",
1512
"//executorch/extension/evalue_util:print_evalue",

extension/android/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
119119
endif()
120120

121121
if(TARGET pthreadpool)
122-
target_compile_definitions(executorch_jni PRIVATE ET_USE_THREADPOOL=1)
123122
target_include_directories(
124123
executorch_jni
125124
PUBLIC

extension/llm/custom_ops/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ target_include_directories(
7878
target_link_libraries(custom_ops PUBLIC ${custom_ops_libs} executorch_core)
7979

8080
target_compile_options(
81-
custom_ops PUBLIC ${_common_compile_options} -DET_USE_THREADPOOL
81+
custom_ops PUBLIC ${_common_compile_options}
8282
)
8383

8484
install(TARGETS custom_ops DESTINATION lib)
@@ -130,7 +130,7 @@ if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
130130
target_compile_options(
131131
custom_ops_aot_lib
132132
PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions
133-
${_common_compile_options} -DET_USE_THREADPOOL
133+
${_common_compile_options}
134134
)
135135

136136
install(TARGETS custom_ops_aot_lib

extension/threadpool/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ target_include_directories(
3232
PUBLIC ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
3333
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
3434
)
35+
target_compile_definitions(extension_threadpool PUBLIC ET_USE_THREADPOOL)
3536
target_compile_options(extension_threadpool PUBLIC ${_common_compile_options})
3637

3738
# Install libraries

0 commit comments

Comments
 (0)