Skip to content

Commit 2889483

Browse files
authored
Split & remove extension_parallel (#8983)
As per plan in #8932, we want to be able to include thread_parallel.h to build libraries that are capable of parallelization, but don't require it. So, we move the header to ExecuTorch core and add a fallback implementation (with tests!) of parallel_for that just does a regular for loop. Then, targets that link extension_threadpool will get parallelization automagically. This PR doesn't add any optionally-parallelized code; that will be in the next PR.
1 parent 594b03d commit 2889483

25 files changed

+191
-194
lines changed

.lintrunner.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ exclude_patterns = [
218218
'examples/**',
219219
'extension/**',
220220
'kernels/optimized/**',
221+
# Justified <functional> include.
222+
'runtime/kernel/thread_parallel_interface.h',
221223
'scripts/**',
222224
'third-party/**',
223225
'util/**',

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL
751751
AND EXECUTORCH_BUILD_CPUINFO
752752
)
753753
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool)
754-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/parallel)
755754
endif()
756755

757756
if(EXECUTORCH_BUILD_PYBIND)

Test.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if(BUILD_TESTING)
1313
add_subdirectory(extension/evalue_util/test)
1414
add_subdirectory(extension/kernel_util/test)
1515
add_subdirectory(extension/memory_allocator/test)
16-
add_subdirectory(extension/parallel/test)
1716
add_subdirectory(extension/pytree/test)
1817
add_subdirectory(kernels/portable/cpu/util/test)
1918
add_subdirectory(kernels/prim_ops/test)

build/cmake_deps.toml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ excludes = [
8888
deps = [
8989
"executorch",
9090
"executorch_core",
91-
"extension_parallel",
9291
"extension_threadpool",
9392
"portable_kernels",
9493
]
@@ -131,7 +130,7 @@ excludes = [
131130
deps = [
132131
"executorch_core",
133132
"executorch",
134-
"extension_parallel",
133+
"extension_threadpool",
135134
]
136135

137136
[targets.optimized_native_cpu_ops]
@@ -146,7 +145,6 @@ excludes = [
146145
deps = [
147146
"executorch_core",
148147
"executorch",
149-
"extension_parallel",
150148
"extension_threadpool",
151149
"portable_kernels",
152150
]
@@ -227,19 +225,6 @@ deps = [
227225
"extension_runner_util",
228226
]
229227

230-
[targets.extension_parallel]
231-
buck_targets = [
232-
"//extension/parallel:thread_parallel",
233-
]
234-
filters = [
235-
".cpp$",
236-
]
237-
deps = [
238-
"executorch",
239-
"executorch_core",
240-
"extension_threadpool",
241-
]
242-
243228
[targets.extension_tensor]
244229
buck_targets = [
245230
"//extension/tensor:tensor",
@@ -379,6 +364,7 @@ excludes = [
379364
deps = [
380365
"executorch",
381366
"executorch_core",
367+
"extension_threadpool",
382368
"xnnpack_backend",
383369
"portable_kernels",
384370
]
@@ -393,6 +379,7 @@ filters = [
393379
deps = [
394380
"executorch",
395381
"executorch_core",
382+
"extension_threadpool",
396383
]
397384

398385
[targets.xnnpack_schema]
@@ -427,7 +414,6 @@ deps = [
427414
"executorch",
428415
"executorch_core",
429416
"optimized_kernels",
430-
"extension_parallel",
431417
"extension_threadpool",
432418
"reduce_util",
433419
"xnnpack_backend",
@@ -465,7 +451,7 @@ deps = [
465451
"executorch_core",
466452
"extension_data_loader",
467453
"extension_module",
468-
"extension_parallel",
454+
"extension_threadpool",
469455
"portable_kernels",
470456
"quantized_kernels",
471457
"xnnpack_backend",

build/executorch-config.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ set(lib_list
7575
custom_ops
7676
extension_module
7777
extension_module_static
78-
extension_parallel
7978
extension_runner_util
8079
extension_tensor
8180
extension_threadpool
@@ -131,14 +130,9 @@ endforeach()
131130

132131
# TODO: investigate use of install(EXPORT) to cleanly handle
133132
# target_compile_options/target_compile_definitions for everything.
134-
if(TARGET extension_parallel)
135-
set_target_properties(
136-
extension_parallel PROPERTIES INTERFACE_LINK_LIBRARIES extension_threadpool
137-
)
138-
endif()
139133
if(TARGET cpublas)
140134
set_target_properties(
141-
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel
135+
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_threadpool
142136
)
143137
endif()
144138
if(TARGET extension_threadpool)

extension/llm/custom_ops/op_sdpa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <vector>
2020

2121
#ifdef ET_USE_THREADPOOL
22-
#include <executorch/extension/parallel/thread_parallel.h>
2322
#include <executorch/extension/threadpool/threadpool.h>
23+
#include <executorch/runtime/kernel/thread_parallel_interface.h>
2424
#endif
2525
#include <executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h>
2626

extension/llm/custom_ops/targets.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def define_common_targets():
3737
"//executorch/kernels/optimized:libblas{}".format(mkl_dep),
3838
"//executorch/kernels/optimized:libvec",
3939
"//executorch/extension/kernel_util:kernel_util",
40-
"//executorch/extension/parallel:thread_parallel",
4140
"//executorch/extension/threadpool:threadpool",
4241
],
4342
deps = [

extension/parallel/CMakeLists.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.

extension/parallel/TARGETS

Lines changed: 0 additions & 8 deletions
This file was deleted.

extension/parallel/targets.bzl

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)