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)
637
637
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /extension/runner_util )
638
638
endif ()
639
639
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
+
640
647
if (EXECUTORCH_BUILD_PYBIND )
641
648
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /third-party/pybind11 )
642
649
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ et_cxx_test(
34
34
SOURCES
35
35
${_test_srcs}
36
36
EXTRA_LIBS
37
+ extension_threadpool
37
38
xnnpack_backend
38
39
XNNPACK
39
40
pthreadpool
Original file line number Diff line number Diff line change @@ -25,9 +25,11 @@ find_package(executorch CONFIG REQUIRED)
25
25
enable_testing ()
26
26
find_package (GTest CONFIG REQUIRED )
27
27
28
+ target_link_options_shared_lib (cpuinfo )
28
29
target_link_options_shared_lib (extension_data_loader )
29
30
target_link_options_shared_lib (portable_kernels )
30
31
target_link_options_shared_lib (portable_ops_lib )
32
+ target_link_options_shared_lib (pthreadpool )
31
33
target_link_options_shared_lib (quantized_ops_lib )
32
34
33
35
# Add code coverage flags to supported compilers
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ set(lib_list
46
46
extension_module
47
47
extension_module_static
48
48
extension_runner_util
49
+ extension_threadpool
49
50
xnnpack_backend
50
51
XNNPACK
51
52
cpuinfo
Original file line number Diff line number Diff line change @@ -125,22 +125,15 @@ set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
125
125
# Extra compile option and include dir for pthreadpool
126
126
if (EXECUTORCH_BUILD_PTHREADPOOL )
127
127
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 )
135
129
list (APPEND _common_include_directories
136
130
${XNNPACK_ROOT} /third-party/pthreadpool/include
137
131
)
138
132
endif ()
139
133
140
134
# Extra sources for cpuinfo
141
135
if (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 )
144
137
list (APPEND _common_include_directories
145
138
${XNNPACK_ROOT} /third-party/cpuinfo/include
146
139
)
Original file line number Diff line number Diff line change @@ -127,22 +127,15 @@ set(XNNPACK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack)
127
127
# Extra compile option and include dir for pthreadpool
128
128
if (EXECUTORCH_BUILD_PTHREADPOOL )
129
129
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 )
137
131
list (APPEND _common_include_directories
138
132
${XNNPACK_ROOT} /third-party/pthreadpool/include
139
133
)
140
134
endif ()
141
135
142
136
# Extra sources for cpuinfo
143
137
if (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 )
146
139
list (APPEND _common_include_directories
147
140
${XNNPACK_ROOT} /third-party/cpuinfo/include
148
141
)
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ find_package(executorch CONFIG REQUIRED)
32
32
target_link_options_shared_lib (executorch )
33
33
34
34
set (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
36
36
fbjni
37
37
)
38
38
@@ -93,13 +93,7 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
93
93
94
94
target_link_options_shared_lib (quantized_ops_lib )
95
95
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 )
103
97
add_library (executorch_llama_jni SHARED ${LLAMA_JNI_SRCS} )
104
98
if (TARGET pthreadpool )
105
99
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)
47
47
48
48
list (TRANSFORM _custom_ops__srcs PREPEND "${EXECUTORCH_ROOT} /" )
49
49
50
- # TODO: Consider moving xnnpack/threadpool in a separate lib since it's now used
51
- # by custom ops too.
52
50
if (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 )
59
52
else ()
60
- list (APPEND custom_ops_libs xnnpack_backend )
53
+ list (APPEND custom_ops_libs extension_threadpool xnnpack_backend )
61
54
endif ()
62
55
63
56
add_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)
23
23
24
24
set (_test_srcs
25
25
thread_parallel_test.cpp ../thread_parallel.cpp
26
- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool.cpp
27
- ${EXECUTORCH_ROOT} /extension/threadpool/threadpool_guard.cpp
28
26
)
29
27
30
28
et_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
32
30
)
33
31
target_include_directories (
34
32
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
+ )
Original file line number Diff line number Diff line change 14
14
#include < cpuinfo.h>
15
15
16
16
#include < atomic>
17
+ #include < memory>
17
18
18
19
namespace torch {
19
20
namespace executorch {
You can’t perform that action at this time.
0 commit comments