Skip to content

Move threadpool to extension #4954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/xnnpack/runtime/XNNCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <executorch/backends/xnnpack/runtime/XNNCompiler.h>
#include <executorch/backends/xnnpack/runtime/XNNHeader.h>
#include <executorch/backends/xnnpack/serialization/schema_generated.h>
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/threadpool/threadpool.h>
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
#include <unordered_map>

Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def define_common_targets():
deps = [
third_party_dep("XNNPACK"),
"//executorch/backends/xnnpack/serialization:xnnpack_flatbuffer_header",
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/extension/threadpool:threadpool",
"//executorch/runtime/core/exec_aten/util:tensor_util",
],
# XnnpackBackend.cpp needs to compile with executor as whole
Expand Down
6 changes: 4 additions & 2 deletions backends/xnnpack/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs # We can't put runtime/test_runtime_utils.cpp because we don't
# build aten
runtime/test_xnnexecutor.cpp ../threadpool/threadpool.cpp
../threadpool/threadpool_guard.cpp ../threadpool/test/threadpool_test.cpp
runtime/test_xnnexecutor.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool_guard.cpp
${EXECUTORCH_ROOT}/extension/threadpool/test/threadpool_test.cpp
)

et_cxx_test(
Expand Down
2 changes: 1 addition & 1 deletion configurations/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def define_common_targets():
runtime.cxx_library(
name = "executor_cpu_optimized",
exported_deps = [
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/extension/threadpool:threadpool",
] + get_all_cpu_backend_targets(),
visibility = [
"//executorch/test/...",
Expand Down
6 changes: 3 additions & 3 deletions examples/models/llama2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
list(APPEND link_libraries pthreadpool)
# These 2 source files are included in xnnpack_backend
if(NOT TARGET xnnpack_backend)
list(APPEND _srcs ${XNNPACK_ROOT}/threadpool/threadpool.cpp
${XNNPACK_ROOT}/threadpool/threadpool_guard.cpp
list(APPEND _srcs ${EXECUTORCH_ROOT}/extension/threadpool/threadpool.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool_guard.cpp
)
endif()
list(APPEND _common_include_directories
Expand All @@ -159,7 +159,7 @@ endif()
# Extra sources for cpuinfo
if(EXECUTORCH_BUILD_CPUINFO)
list(APPEND link_libraries cpuinfo)
list(APPEND _srcs ${XNNPACK_ROOT}/threadpool/cpuinfo_utils.cpp)
list(APPEND _srcs ${EXECUTORCH_ROOT}/extension/threadpool/cpuinfo_utils.cpp)
list(APPEND _common_include_directories
${XNNPACK_ROOT}/third-party/cpuinfo/include
)
Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <executorch/examples/models/llama2/runner/runner.h>

#if defined(ET_USE_THREADPOOL)
#include <executorch/backends/xnnpack/threadpool/cpuinfo_utils.h>
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/threadpool/cpuinfo_utils.h>
#include <executorch/extension/threadpool/threadpool.h>
#endif

DEFINE_string(
Expand Down
4 changes: 2 additions & 2 deletions examples/models/llama2/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def define_common_targets():
deps = [
"//executorch/examples/models/llama2/runner:runner" + aten_suffix,
"//executorch/extension/evalue_util:print_evalue",
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/backends/xnnpack/threadpool:cpuinfo_utils",
"//executorch/extension/threadpool:threadpool",
"//executorch/extension/threadpool:cpuinfo_utils",
],
external_deps = [
"gflags",
Expand Down
6 changes: 3 additions & 3 deletions examples/models/llava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
list(APPEND link_libraries pthreadpool)
# These 2 source files are included in xnnpack_backend
if(NOT TARGET xnnpack_backend)
list(APPEND _srcs ${XNNPACK_ROOT}/threadpool/threadpool.cpp
${XNNPACK_ROOT}/threadpool/threadpool_guard.cpp
list(APPEND _srcs ${EXECUTORCH_ROOT}/extension/threadpool/threadpool.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool_guard.cpp
)
endif()
list(APPEND _common_include_directories
Expand All @@ -143,7 +143,7 @@ endif()
# Extra sources for cpuinfo
if(EXECUTORCH_BUILD_CPUINFO)
list(APPEND link_libraries cpuinfo)
list(APPEND _srcs ${XNNPACK_ROOT}/threadpool/cpuinfo_utils.cpp)
list(APPEND _srcs ${EXECUTORCH_ROOT}/extension/threadpool/cpuinfo_utils.cpp)
list(APPEND _common_include_directories
${XNNPACK_ROOT}/third-party/cpuinfo/include
)
Expand Down
4 changes: 2 additions & 2 deletions examples/models/llava/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <torch/torch.h>

#if defined(ET_USE_THREADPOOL)
#include <executorch/backends/xnnpack/threadpool/cpuinfo_utils.h>
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/threadpool/cpuinfo_utils.h>
#include <executorch/extension/threadpool/threadpool.h>
#endif

DEFINE_string(
Expand Down
2 changes: 1 addition & 1 deletion extension/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)

if(TARGET pthreadpool)
set(LLAMA_JNI_SRCS jni/jni_layer_llama.cpp
../../backends/xnnpack/threadpool/cpuinfo_utils.cpp
../../extension/threadpool/cpuinfo_utils.cpp
)
else()
set(LLAMA_JNI_SRCS jni/jni_layer_llama.cpp)
Expand Down
4 changes: 2 additions & 2 deletions extension/android/jni/jni_layer_llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <executorch/runtime/platform/runtime.h>

#if defined(ET_USE_THREADPOOL)
#include <executorch/backends/xnnpack/threadpool/cpuinfo_utils.h>
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/threadpool/cpuinfo_utils.h>
#include <executorch/extension/threadpool/threadpool.h>
#endif

#include <fbjni/ByteBuffer.h>
Expand Down
4 changes: 2 additions & 2 deletions extension/llm/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ if(NOT EXECUTORCH_BUILD_XNNPACK)
list(
APPEND
_custom_ops__srcs
"${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack/threadpool/threadpool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../backends/xnnpack/threadpool/threadpool_guard.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../extension/threadpool/threadpool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../extension/threadpool/threadpool_guard.cpp"
)
else()
list(APPEND custom_ops_libs xnnpack_backend)
Expand Down
2 changes: 1 addition & 1 deletion extension/llm/custom_ops/op_sdpa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <vector>

#ifdef ET_USE_THREADPOOL
#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/parallel/thread_parallel.h>
#include <executorch/extension/threadpool/threadpool.h>
#endif
#include <executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h>

Expand Down
2 changes: 1 addition & 1 deletion extension/llm/custom_ops/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def define_common_targets():
"//executorch/kernels/optimized:libvec",
"//executorch/extension/kernel_util:kernel_util",
"//executorch/extension/parallel:thread_parallel",
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/extension/threadpool:threadpool",
],
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"],
visibility = [
Expand Down
2 changes: 1 addition & 1 deletion extension/parallel/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def define_common_targets():
"@EXECUTORCH_CLIENTS",
],
deps = [
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/extension/threadpool:threadpool",
"//executorch/runtime/core:core",
"//executorch/runtime/core/exec_aten/util:tensor_util" + aten_suffix,
],
Expand Down
4 changes: 2 additions & 2 deletions extension/parallel/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs
thread_parallel_test.cpp ../thread_parallel.cpp
${EXECUTORCH_ROOT}/backends/xnnpack/threadpool/threadpool.cpp
${EXECUTORCH_ROOT}/backends/xnnpack/threadpool/threadpool_guard.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool.cpp
${EXECUTORCH_ROOT}/extension/threadpool/threadpool_guard.cpp
)

et_cxx_test(
Expand Down
2 changes: 1 addition & 1 deletion extension/parallel/thread_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <tuple>

#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/extension/parallel/thread_parallel.h>
#include <executorch/extension/threadpool/threadpool.h>
#include <executorch/runtime/core/exec_aten/util/tensor_util.h>
#include <executorch/runtime/platform/assert.h>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def define_common_targets():
name = "threadpool_test",
srcs = _THREADPOOL_TESTS,
deps = [
"//executorch/backends/xnnpack/threadpool:threadpool",
"//executorch/extension/threadpool:threadpool",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <numeric>
#include <random>

#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/backends/xnnpack/threadpool/threadpool_guard.h>
#include <executorch/extension/threadpool/threadpool.h>
#include <executorch/extension/threadpool/threadpool_guard.h>

using namespace ::testing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/

#include <executorch/backends/xnnpack/threadpool/threadpool.h>
#include <executorch/backends/xnnpack/threadpool/threadpool_guard.h>
#include <executorch/extension/threadpool/threadpool.h>
#include <executorch/extension/threadpool/threadpool_guard.h>
#include <executorch/runtime/platform/assert.h>
#include <algorithm>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include <executorch/backends/xnnpack/threadpool/threadpool_guard.h>
#include <executorch/extension/threadpool/threadpool_guard.h>

namespace torch {
namespace executorch {
Expand Down
Loading