Skip to content

Commit 2748b36

Browse files
committed
Revert "Split & remove extension_parallel (#8983)"
This reverts commit 2889483. ghstack-source-id: d44d019b3745260fe311b4eab570257050c782b7 ghstack-comment-id: 2718557885 Pull Request resolved: #9189
1 parent 498795b commit 2748b36

25 files changed

+194
-191
lines changed

.lintrunner.toml

-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ exclude_patterns = [
218218
'examples/**',
219219
'extension/**',
220220
'kernels/optimized/**',
221-
# Justified <functional> include.
222-
'runtime/kernel/thread_parallel_interface.h',
223221
'scripts/**',
224222
'third-party/**',
225223
'util/**',

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ 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)
754755
endif()
755756

756757
if(EXECUTORCH_BUILD_PYBIND)

Test.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ 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)
1617
add_subdirectory(extension/pytree/test)
1718
add_subdirectory(kernels/portable/cpu/util/test)
1819
add_subdirectory(kernels/prim_ops/test)

build/cmake_deps.toml

+18-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ excludes = [
8888
deps = [
8989
"executorch",
9090
"executorch_core",
91+
"extension_parallel",
9192
"extension_threadpool",
9293
"portable_kernels",
9394
]
@@ -130,7 +131,7 @@ excludes = [
130131
deps = [
131132
"executorch_core",
132133
"executorch",
133-
"extension_threadpool",
134+
"extension_parallel",
134135
]
135136

136137
[targets.optimized_native_cpu_ops]
@@ -145,6 +146,7 @@ excludes = [
145146
deps = [
146147
"executorch_core",
147148
"executorch",
149+
"extension_parallel",
148150
"extension_threadpool",
149151
"portable_kernels",
150152
]
@@ -225,6 +227,19 @@ deps = [
225227
"extension_runner_util",
226228
]
227229

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+
228243
[targets.extension_tensor]
229244
buck_targets = [
230245
"//extension/tensor:tensor",
@@ -364,7 +379,6 @@ excludes = [
364379
deps = [
365380
"executorch",
366381
"executorch_core",
367-
"extension_threadpool",
368382
"xnnpack_backend",
369383
"portable_kernels",
370384
]
@@ -379,7 +393,6 @@ filters = [
379393
deps = [
380394
"executorch",
381395
"executorch_core",
382-
"extension_threadpool",
383396
]
384397

385398
[targets.xnnpack_schema]
@@ -414,6 +427,7 @@ deps = [
414427
"executorch",
415428
"executorch_core",
416429
"optimized_kernels",
430+
"extension_parallel",
417431
"extension_threadpool",
418432
"reduce_util",
419433
"xnnpack_backend",
@@ -451,7 +465,7 @@ deps = [
451465
"executorch_core",
452466
"extension_data_loader",
453467
"extension_module",
454-
"extension_threadpool",
468+
"extension_parallel",
455469
"portable_kernels",
456470
"quantized_kernels",
457471
"xnnpack_backend",

build/executorch-config.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ set(lib_list
7575
custom_ops
7676
extension_module
7777
extension_module_static
78+
extension_parallel
7879
extension_runner_util
7980
extension_tensor
8081
extension_threadpool
@@ -130,9 +131,14 @@ endforeach()
130131

131132
# TODO: investigate use of install(EXPORT) to cleanly handle
132133
# 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()
133139
if(TARGET cpublas)
134140
set_target_properties(
135-
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_threadpool
141+
cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel
136142
)
137143
endif()
138144
if(TARGET extension_threadpool)

extension/llm/custom_ops/op_sdpa.cpp

+1-1
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>
2223
#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

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ 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",
4041
"//executorch/extension/threadpool:threadpool",
4142
],
4243
deps = [

extension/parallel/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 keep this file formatted by running:
8+
# ~~~
9+
# cmake-format -i CMakeLists.txt
10+
# ~~~
11+
12+
if(NOT (EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO))
13+
message(FATAL_ERROR "extension/parallel requires extension/threadpool")
14+
endif()
15+
16+
add_library(extension_parallel thread_parallel.cpp)
17+
18+
target_link_libraries(extension_parallel PUBLIC executorch_core extension_threadpool)
19+
target_compile_options(extension_parallel PUBLIC ${_common_compile_options})
20+
21+
install(
22+
TARGETS extension_parallel
23+
DESTINATION lib
24+
INCLUDES
25+
DESTINATION ${_common_include_directories})

extension/parallel/TARGETS

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Any targets that should be shared between fbcode and xplat must be defined in
2+
# targets.bzl. This file can contain fbcode-only targets.
3+
4+
load(":targets.bzl", "define_common_targets")
5+
6+
oncall("executorch")
7+
8+
define_common_targets()

extension/parallel/targets.bzl

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
6+
The directory containing this targets.bzl file should also contain both
7+
TARGETS and BUCK files that call this function.
8+
"""
9+
10+
runtime.cxx_library(
11+
name = "thread_parallel",
12+
srcs = [
13+
"thread_parallel.cpp",
14+
],
15+
exported_headers = [
16+
"thread_parallel.h",
17+
],
18+
visibility = [
19+
"//executorch/...",
20+
"@EXECUTORCH_CLIENTS",
21+
],
22+
deps = [
23+
"//executorch/extension/threadpool:threadpool",
24+
"//executorch/runtime/core:core",
25+
],
26+
)

extension/threadpool/test/CMakeLists.txt renamed to extension/parallel/test/CMakeLists.txt

+16-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
# @generated by test/utils/generate_gtest_cmakelists.py
8-
#
97
# This file should be formatted with
108
# ~~~
119
# cmake-format -i CMakeLists.txt
@@ -14,14 +12,28 @@
1412
#
1513

1614
cmake_minimum_required(VERSION 3.19)
15+
project(extension_parallel_test)
16+
17+
# Use C++17 for test.
18+
set(CMAKE_CXX_STANDARD 17)
1719

1820
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
1921

2022
include(${EXECUTORCH_ROOT}/build/Test.cmake)
2123

22-
set(_test_srcs thread_parallel_test.cpp threadpool_test.cpp)
24+
set(_test_srcs thread_parallel_test.cpp ../thread_parallel.cpp)
2325

2426
et_cxx_test(
25-
extension_threadpool_test SOURCES ${_test_srcs} EXTRA_LIBS
27+
extension_parallel_test
28+
SOURCES
29+
${_test_srcs}
30+
EXTRA_LIBS
31+
pthreadpool
32+
cpuinfo
2633
extension_threadpool
2734
)
35+
target_include_directories(
36+
extension_parallel_test
37+
PRIVATE ${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
38+
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
39+
)

extension/parallel/test/TARGETS

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Any targets that should be shared between fbcode and xplat must be defined in
2+
# targets.bzl. This file can contain fbcode-only targets.
3+
4+
load(":targets.bzl", "define_common_targets")
5+
6+
oncall("executorch")
7+
8+
define_common_targets()

extension/parallel/test/targets.bzl

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets():
4+
"""Defines targets that should be shared between fbcode and xplat.
5+
6+
The directory containing this targets.bzl file should also contain both
7+
TARGETS and BUCK files that call this function.
8+
"""
9+
10+
runtime.cxx_test(
11+
name = "thread_parallel_test",
12+
srcs = [
13+
"thread_parallel_test.cpp",
14+
],
15+
deps = [
16+
"//executorch/extension/parallel:thread_parallel",
17+
"//executorch/runtime/platform:platform",
18+
],
19+
)

0 commit comments

Comments
 (0)