diff --git a/extension/parallel/targets.bzl b/extension/parallel/targets.bzl index dbfb3ff160c..3a2d6f354ef 100644 --- a/extension/parallel/targets.bzl +++ b/extension/parallel/targets.bzl @@ -17,6 +17,6 @@ def define_common_targets(): "@EXECUTORCH_CLIENTS", ], deps = [ - "//executorch/runtime/kernel:thread_parallel_interface", + "//executorch/extension/threadpool:threadpool", ], ) diff --git a/extension/threadpool/targets.bzl b/extension/threadpool/targets.bzl index 1c34dbbc7d4..5e7cf2c7dae 100644 --- a/extension/threadpool/targets.bzl +++ b/extension/threadpool/targets.bzl @@ -20,7 +20,7 @@ def define_common_targets(): ] + (["fb/threadpool_use_n_threads.h"] if not runtime.is_oss else []) runtime.cxx_library( - name = "threadpool", + name = "threadpool_lib", srcs = _THREADPOOL_SRCS, deps = [ "//executorch/runtime/core:core", @@ -45,6 +45,38 @@ def define_common_targets(): ], ) + runtime.cxx_library( + name = "threadpool", + # TODO: OSS doesn't have os:iphoneos. Sync buck2 prelude + # update to add it and remove duplication. + exported_deps = (select({ + # Major operating systems should be able to use threadpool. + "ovr_config//os:linux": [":threadpool_lib"], + "ovr_config//os:macos": [":threadpool_lib"], + "ovr_config//os:windows": [":threadpool_lib"], + "ovr_config//os:android": [":threadpool_lib"], + "ovr_config//os:iphoneos": [":threadpool_lib"], + # Machines without an operating system shouldn't. + "ovr_config//os:none": ["//executorch/runtime/kernel:thread_parallel_interface"], + # If we don't know what it is, disable threadpool out of caution. + "DEFAULT": ["//executorch/runtime/kernel:thread_parallel_interface"], + }) if not runtime.is_oss else select({ + # Major operating systems should be able to use threadpool. + "ovr_config//os:linux": [":threadpool_lib"], + "ovr_config//os:macos": [":threadpool_lib"], + "ovr_config//os:windows": [":threadpool_lib"], + "ovr_config//os:android": [":threadpool_lib"], + # Machines without an operating system shouldn't. + "ovr_config//os:none": ["//executorch/runtime/kernel:thread_parallel_interface"], + # If we don't know what it is, disable threadpool out of caution. + "DEFAULT": ["//executorch/runtime/kernel:thread_parallel_interface"], + })), + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + ) + runtime.cxx_library( name = "cpuinfo_utils", srcs = [ diff --git a/kernels/optimized/cpu/targets.bzl b/kernels/optimized/cpu/targets.bzl index 017dff8a127..8dadd5a49e6 100644 --- a/kernels/optimized/cpu/targets.bzl +++ b/kernels/optimized/cpu/targets.bzl @@ -99,8 +99,8 @@ _OPTIMIZED_ATEN_OPS = ( op_target( name = "op_where", deps = [ + "//executorch/extension/threadpool:threadpool", "//executorch/kernels/portable/cpu/util:elementwise_util", - "//executorch/runtime/kernel:thread_parallel_interface", ], ), ) diff --git a/kernels/optimized/lib_defs.bzl b/kernels/optimized/lib_defs.bzl index 6e884457e35..85886365a01 100644 --- a/kernels/optimized/lib_defs.bzl +++ b/kernels/optimized/lib_defs.bzl @@ -232,9 +232,9 @@ def define_libs(is_fbcode=False): "DEFAULT": [], }) + LIBBLAS_DEPS, exported_deps = [ + "//executorch/extension/threadpool:threadpool", "//executorch/kernels/optimized:libutils", "//executorch/runtime/core/exec_aten:lib", - "//executorch/runtime/kernel:thread_parallel_interface", ], **get_apple_framework_deps_kwargs(is_fbcode), ) diff --git a/kernels/portable/cpu/util/targets.bzl b/kernels/portable/cpu/util/targets.bzl index a623b9d4d7a..e756a9bf282 100644 --- a/kernels/portable/cpu/util/targets.bzl +++ b/kernels/portable/cpu/util/targets.bzl @@ -12,6 +12,7 @@ def define_common_targets(): runtime.cxx_library( name = "all_deps", deps = [ + "//executorch/extension/threadpool:threadpool", "//executorch/kernels/portable/cpu/util:functional_util", "//executorch/kernels/portable/cpu/util:broadcast_util", "//executorch/kernels/portable/cpu/util:kernel_ops_util", @@ -32,7 +33,6 @@ def define_common_targets(): "//executorch/kernels/portable/cpu/util:slice_util", "//executorch/kernels/portable/cpu/util:elementwise_util", "//executorch/kernels/portable/cpu/util:upsample_util", - "//executorch/runtime/kernel:thread_parallel_interface", ], visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"], ) @@ -111,7 +111,7 @@ def define_common_targets(): ":broadcast_util", ":dtype_util", "//executorch/runtime/kernel:kernel_runtime_context", - "//executorch/runtime/kernel:thread_parallel_interface", + "//executorch/extension/threadpool:threadpool", ], deps = [ "//executorch/kernels/portable/cpu:scalar_utils", @@ -245,7 +245,7 @@ def define_common_targets(): srcs = [], exported_headers = ["functional_util.h"], exported_deps = [ - "//executorch/runtime/kernel:thread_parallel_interface", + "//executorch/extension/threadpool:threadpool", ], deps = [ "//executorch/runtime/kernel:kernel_includes", @@ -319,7 +319,7 @@ def define_common_targets(): "//executorch/runtime/core/exec_aten/util:tensor_util{}".format(suffix), ], exported_deps = [ - "//executorch/runtime/kernel:thread_parallel_interface", + "//executorch/extension/threadpool:threadpool", ], exported_preprocessor_flags = ["-DUSE_ATEN_LIB"] if aten_mode else [], visibility = [ diff --git a/runtime/kernel/targets.bzl b/runtime/kernel/targets.bzl index 0726752d3dd..b6aa9d7a95e 100644 --- a/runtime/kernel/targets.bzl +++ b/runtime/kernel/targets.bzl @@ -59,9 +59,9 @@ def define_common_targets(): "//executorch/runtime/core/portable_type/c10/c10:c10", "//executorch/runtime/platform:platform", ], + # Don't depend on this target, depend on //executorch/extension/threadpool:threadpool. visibility = [ - "//executorch/...", - "@EXECUTORCH_CLIENTS", + "//executorch/extension/threadpool/...", ], )