File tree Expand file tree Collapse file tree 11 files changed +61
-38
lines changed
Expand file tree Collapse file tree 11 files changed +61
-38
lines changed Original file line number Diff line number Diff line change @@ -637,6 +637,13 @@ if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
637637 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/runner_util)
638638endif ()
639639
640+ if (EXECUTORCH_BUILD_PTHREADPOOL
641+ AND EXECUTORCH_BUILD_CPUINFO
642+ AND CMAKE_CXX_STANDARD GREATER_EQUAL 14
643+ )
644+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/threadpool)
645+ endif ()
646+
640647if (EXECUTORCH_BUILD_PYBIND)
641648 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /third-party/pybind11)
642649
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ et_cxx_test(
3434 SOURCES
3535 ${_test_srcs}
3636 EXTRA_LIBS
37+ extension_threadpool
3738 xnnpack_backend
3839 XNNPACK
3940 pthreadpool
Original file line number Diff line number Diff line change @@ -25,9 +25,11 @@ find_package(executorch CONFIG REQUIRED)
2525enable_testing ()
2626find_package (GTest CONFIG REQUIRED)
2727
28+ target_link_options_shared_lib(cpuinfo)
2829target_link_options_shared_lib(extension_data_loader)
2930target_link_options_shared_lib(portable_kernels)
3031target_link_options_shared_lib(portable_ops_lib)
32+ target_link_options_shared_lib(pthreadpool)
3133target_link_options_shared_lib(quantized_ops_lib)
3234
3335# Add code coverage flags to supported compilers
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ set(lib_list
4646 extension_module
4747 extension_module_static
4848 extension_runner_util
49+ extension_threadpool
4950 xnnpack_backend
5051 XNNPACK
5152 cpuinfo
Original file line number Diff line number Diff line change @@ -125,22 +125,15 @@ set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
125125# Extra compile option and include dir for pthreadpool
126126if (EXECUTORCH_BUILD_PTHREADPOOL)
127127 list (APPEND _common_compile_options -DET_USE_THREADPOOL)
128- list (APPEND link_libraries pthreadpool)
129- # These 2 source files are included in xnnpack_backend
130- if (NOT TARGET xnnpack_backend)
131- list (APPEND _srcs ${EXECUTORCH_ROOT} /extension/threadpool/threadpool.cpp
132- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool_guard.cpp
133- )
134- endif ()
128+ list (APPEND link_libraries extension_threadpool pthreadpool)
135129 list (APPEND _common_include_directories
136130 ${XNNPACK_ROOT} /third-party/pthreadpool/include
137131 )
138132endif ()
139133
140134# Extra sources for cpuinfo
141135if (EXECUTORCH_BUILD_CPUINFO)
142- list (APPEND link_libraries cpuinfo)
143- list (APPEND _srcs ${EXECUTORCH_ROOT} /extension/threadpool/cpuinfo_utils.cpp)
136+ list (APPEND link_libraries extension_threadpool cpuinfo)
144137 list (APPEND _common_include_directories
145138 ${XNNPACK_ROOT} /third-party/cpuinfo/include
146139 )
Original file line number Diff line number Diff line change @@ -127,22 +127,15 @@ set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
127127# Extra compile option and include dir for pthreadpool
128128if (EXECUTORCH_BUILD_PTHREADPOOL)
129129 list (APPEND _common_compile_options -DET_USE_THREADPOOL)
130- list (APPEND link_libraries pthreadpool)
131- # These 2 source files are included in xnnpack_backend
132- if (NOT TARGET xnnpack_backend)
133- list (APPEND _srcs ${EXECUTORCH_ROOT} /extension/threadpool/threadpool.cpp
134- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool_guard.cpp
135- )
136- endif ()
130+ list (APPEND link_libraries extension_threadpool pthreadpool)
137131 list (APPEND _common_include_directories
138132 ${XNNPACK_ROOT} /third-party/pthreadpool/include
139133 )
140134endif ()
141135
142136# Extra sources for cpuinfo
143137if (EXECUTORCH_BUILD_CPUINFO)
144- list (APPEND link_libraries cpuinfo)
145- list (APPEND _srcs ${EXECUTORCH_ROOT} /extension/threadpool/cpuinfo_utils.cpp)
138+ list (APPEND link_libraries extension_threadpool cpuinfo)
146139 list (APPEND _common_include_directories
147140 ${XNNPACK_ROOT} /third-party/cpuinfo/include
148141 )
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ find_package(executorch CONFIG REQUIRED)
3232target_link_options_shared_lib(executorch)
3333
3434set (link_libraries )
35- list (APPEND link_libraries extension_data_loader extension_module executorch
35+ list (APPEND link_libraries extension_data_loader extension_module extension_threadpool executorch
3636 fbjni
3737)
3838
@@ -93,13 +93,7 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
9393
9494 target_link_options_shared_lib(quantized_ops_lib)
9595
96- if (TARGET pthreadpool)
97- set (LLAMA_JNI_SRCS jni/jni_layer_llama.cpp
98- ../../extension/threadpool/cpuinfo_utils.cpp
99- )
100- else ()
101- set (LLAMA_JNI_SRCS jni/jni_layer_llama.cpp)
102- endif ()
96+ set (LLAMA_JNI_SRCS jni/jni_layer_llama.cpp)
10397 add_library (executorch_llama_jni SHARED ${LLAMA_JNI_SRCS} )
10498 if (TARGET pthreadpool)
10599 target_compile_definitions (executorch_llama_jni PRIVATE ET_USE_THREADPOOL=1)
Original file line number Diff line number Diff line change @@ -47,17 +47,10 @@ list(APPEND custom_ops_libs eigen_blas)
4747
4848list (TRANSFORM _custom_ops__srcs PREPEND "${EXECUTORCH_ROOT} /" )
4949
50- # TODO: Consider moving xnnpack/threadpool in a separate lib since it's now used
51- # by custom ops too.
5250if (NOT EXECUTORCH_BUILD_XNNPACK)
53- list (
54- APPEND
55- _custom_ops__srcs
56- "${CMAKE_CURRENT_SOURCE_DIR} /../../../extension/threadpool/threadpool.cpp"
57- "${CMAKE_CURRENT_SOURCE_DIR} /../../../extension/threadpool/threadpool_guard.cpp"
58- )
51+ list (APPEND custom_ops_libs extension_threadpool)
5952else ()
60- list (APPEND custom_ops_libs xnnpack_backend)
53+ list (APPEND custom_ops_libs extension_threadpool xnnpack_backend)
6154endif ()
6255
6356add_library (custom_ops ${_custom_ops__srcs} )
Original file line number Diff line number Diff line change @@ -23,12 +23,10 @@ include(${EXECUTORCH_ROOT}/build/Test.cmake)
2323
2424set (_test_srcs
2525 thread_parallel_test.cpp ../thread_parallel.cpp
26- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool.cpp
27- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool_guard.cpp
2826)
2927
3028et_cxx_test(
31- extension_parallel_test SOURCES ${_test_srcs} EXTRA_LIBS pthreadpool cpuinfo
29+ extension_parallel_test SOURCES ${_test_srcs} EXTRA_LIBS pthreadpool cpuinfo extension_threadpool
3230)
3331target_include_directories (
3432 extension_parallel_test
Original file line number Diff line number Diff line change 1+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2+ # All rights reserved.
3+ #
4+ # This source code is licensed under the BSD-style license found in the
5+ # LICENSE file in the root directory of this source tree.
6+
7+ # Please this file formatted by running:
8+ # ~~~
9+ # cmake-format -i CMakeLists.txt
10+ # ~~~
11+
12+ cmake_minimum_required (VERSION 3.19)
13+
14+ # Source root directory for executorch.
15+ if (NOT EXECUTORCH_ROOT)
16+ set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /../..)
17+ endif ()
18+
19+ if (NOT CMAKE_CXX_STANDARD)
20+ set (CMAKE_CXX_STANDARD 17)
21+ endif ()
22+
23+ add_library (extension_threadpool threadpool.cpp threadpool_guard.cpp cpuinfo_utils.cpp)
24+ target_link_libraries (extension_threadpool PUBLIC executorch cpuinfo pthreadpool)
25+ target_include_directories (extension_threadpool PUBLIC ${EXECUTORCH_ROOT} /..)
26+ target_include_directories (
27+ extension_threadpool
28+ PUBLIC
29+ ${EXECUTORCH_ROOT} /backends/xnnpack/third-party/cpuinfo/include
30+ ${EXECUTORCH_ROOT} /backends/xnnpack/third-party/pthreadpool/include
31+ )
32+ target_compile_options (extension_threadpool PUBLIC ${_common_compile_options} )
33+
34+ # Install libraries
35+ install (
36+ TARGETS extension_threadpool
37+ DESTINATION lib
38+ INCLUDES
39+ DESTINATION ${_common_include_directories}
40+ )
You can’t perform that action at this time.
0 commit comments