From d0b11e8bb47dacb6e200ac8b0e2609626ccee0f3 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 11:35:29 -0800 Subject: [PATCH 1/6] Update [ghstack-poisoned] --- CMakeLists.txt | 2 +- build/cmake_deps.toml | 18 ++++++++++++++++++ kernels/optimized/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de941663a88..73b89b6171e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -749,9 +749,9 @@ endif() if(EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO - AND CMAKE_CXX_STANDARD GREATER_EQUAL 14 ) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/threadpool) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/parallel) endif() if(EXECUTORCH_BUILD_PYBIND) diff --git a/build/cmake_deps.toml b/build/cmake_deps.toml index 4b22a09cb5b..4bbfd636a96 100644 --- a/build/cmake_deps.toml +++ b/build/cmake_deps.toml @@ -73,6 +73,7 @@ excludes = [ deps = [ "executorch", "executorch_core", + "extension_parallel", "extension_threadpool", "portable_kernels", ] @@ -115,6 +116,7 @@ excludes = [ deps = [ "executorch_core", "executorch", + "extension_parallel", ] [targets.optimized_native_cpu_ops] @@ -129,6 +131,8 @@ excludes = [ deps = [ "executorch_core", "executorch", + "extension_parallel", + "extension_threadpool", "portable_kernels", ] # ---------------------------------- core end ---------------------------------- @@ -208,6 +212,19 @@ deps = [ "extension_runner_util", ] +[targets.extension_parallel] +buck_targets = [ + "//extension/parallel:thread_parallel", +] +filters = [ + ".cpp$", +] +deps = [ + "executorch", + "executorch_core", + "extension_threadpool", +] + [targets.extension_tensor] buck_targets = [ "//extension/tensor:tensor", @@ -395,6 +412,7 @@ deps = [ "executorch", "executorch_core", "optimized_kernels", + "extension_parallel", "extension_threadpool", "xnnpack_backend", ] diff --git a/kernels/optimized/CMakeLists.txt b/kernels/optimized/CMakeLists.txt index 235c6738d9a..d9b19d4f9c2 100644 --- a/kernels/optimized/CMakeLists.txt +++ b/kernels/optimized/CMakeLists.txt @@ -43,7 +43,7 @@ endif() list(TRANSFORM _optimized_cpublas__srcs PREPEND "${EXECUTORCH_ROOT}/") add_library(cpublas STATIC ${_optimized_cpublas__srcs}) target_link_libraries( - cpublas PRIVATE executorch_core eigen_blas extension_threadpool + cpublas PRIVATE executorch_core eigen_blas extension_parallel extension_threadpool ) target_compile_options(cpublas PUBLIC ${_common_compile_options}) From 9437be1e7055d5705540d3544955b5d30f72be43 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 12:29:58 -0800 Subject: [PATCH 2/6] Update [ghstack-poisoned] --- extension/parallel/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 extension/parallel/CMakeLists.txt diff --git a/extension/parallel/CMakeLists.txt b/extension/parallel/CMakeLists.txt new file mode 100644 index 00000000000..7f727aafe46 --- /dev/null +++ b/extension/parallel/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Please keep this file formatted by running: +# ~~~ +# cmake-format -i CMakeLists.txt +# ~~~ + +if(NOT (EXECUTORCH_BUILD_PTHREADPOOL AND EXECUTORCH_BUILD_CPUINFO)) + message(FATAL_ERROR "extension/parallel requires extension/threadpool") +endif() + +add_library(extension_parallel thread_parallel.cpp) + +target_link_libraries(extension_parallel PUBLIC executorch_core extension_threadpool) +target_compile_options(extension_parallel PUBLIC ${_common_compile_options}) + +install( + TARGETS extension_parallel + DESTINATION lib + INCLUDES + DESTINATION ${_common_include_directories}) From 643e10ee081b1ea34f0f5fb49f7df44a9f2f666b Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 14:54:47 -0800 Subject: [PATCH 3/6] Update [ghstack-poisoned] --- build/executorch-config.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/executorch-config.cmake b/build/executorch-config.cmake index d14a1227cd9..539c7c2960e 100644 --- a/build/executorch-config.cmake +++ b/build/executorch-config.cmake @@ -67,6 +67,7 @@ set(lib_list portable_ops_lib extension_module extension_module_static + extension_parallel extension_runner_util extension_tensor extension_threadpool @@ -114,3 +115,7 @@ foreach(lib ${lib_list}) list(APPEND EXECUTORCH_LIBRARIES ${lib}) endif() endforeach() + +# TODO: investigate use of install(EXPORT) to cleanly handle +# target_compile_options/target_compile_definitions for everything. +target_link_libraries(cpublas INTERFACE extension_parallel) From a92958a1f6fbfbc154ec24c6b4ee6c6ebd41aea8 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 18:41:25 -0800 Subject: [PATCH 4/6] Update [ghstack-poisoned] --- build/executorch-config.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build/executorch-config.cmake b/build/executorch-config.cmake index 1a2da26416e..8f64c502b47 100644 --- a/build/executorch-config.cmake +++ b/build/executorch-config.cmake @@ -118,6 +118,8 @@ endforeach() # TODO: investigate use of install(EXPORT) to cleanly handle # target_compile_options/target_compile_definitions for everything. -set_target_properties( - cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel -) +if (TARGET cpublas) + set_target_properties( + cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel + ) +endif() From 3bd64370f6454f9523b6cc51d05d377fed8a77fb Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 19:54:10 -0800 Subject: [PATCH 5/6] Update [ghstack-poisoned] --- build/executorch-config.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/executorch-config.cmake b/build/executorch-config.cmake index 8f64c502b47..2c459b66ac8 100644 --- a/build/executorch-config.cmake +++ b/build/executorch-config.cmake @@ -118,7 +118,12 @@ endforeach() # TODO: investigate use of install(EXPORT) to cleanly handle # target_compile_options/target_compile_definitions for everything. -if (TARGET cpublas) +if(TARGET extension_parallel) + set_target_properties( + extension_parallel PROPERTIES INTERFACE_LINK_LIBRARIES extension_threadpool + ) +endif() +if(TARGET cpublas) set_target_properties( cpublas PROPERTIES INTERFACE_LINK_LIBRARIES extension_parallel ) From 9fdebee5a3e9a439895df57b49343816fcceee86 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Tue, 4 Mar 2025 21:11:25 -0800 Subject: [PATCH 6/6] Update [ghstack-poisoned] --- build/cmake_deps.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/build/cmake_deps.toml b/build/cmake_deps.toml index 4bbfd636a96..4811563269c 100644 --- a/build/cmake_deps.toml +++ b/build/cmake_deps.toml @@ -449,6 +449,7 @@ deps = [ "executorch_core", "extension_data_loader", "extension_module", + "extension_parallel", "portable_kernels", "quantized_kernels", "xnnpack_backend",