forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtargets.bzl
More file actions
88 lines (81 loc) · 3.49 KB
/
targets.bzl
File metadata and controls
88 lines (81 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
load("@fbsource//xplat/executorch/build:build_variables.bzl", "THREADPOOL_SRCS")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
def define_common_targets():
"""Defines targets that should be shared between fbcode and xplat.
The directory containing this targets.bzl file should also contain both
TARGETS and BUCK files that call this function.
"""
_THREADPOOL_SRCS = THREADPOOL_SRCS + (
["fb/threadpool_use_n_threads.cpp"] if not runtime.is_oss else []
)
_THREADPOOL_HEADERS = [
"threadpool.h",
"threadpool_guard.h",
] + (["fb/threadpool_use_n_threads.h"] if not runtime.is_oss else [])
runtime.cxx_library(
name = "threadpool_lib",
srcs = _THREADPOOL_SRCS,
deps = [
":cpuinfo_utils",
"//executorch/runtime/core:core",
"//executorch/runtime/core/portable_type/c10/c10:c10",
],
exported_headers = _THREADPOOL_HEADERS,
exported_deps = [
third_party_dep("pthreadpool"),
third_party_dep("cpuinfo"),
# Allow users to use the header without an extra deps entry.
"//executorch/runtime/kernel:thread_parallel_interface",
],
exported_preprocessor_flags = [
"-DET_USE_THREADPOOL",
],
visibility = ["PUBLIC"],
)
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"],
"ovr_config//runtime:wasm-emscripten": [":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 = ["PUBLIC"],
)
runtime.cxx_library(
name = "cpuinfo_utils",
srcs = [
"cpuinfo_utils.cpp",
],
deps = [
"//executorch/runtime/core:core",
],
exported_headers = [
"cpuinfo_utils.h",
],
exported_deps = [
third_party_dep("pthreadpool"),
third_party_dep("cpuinfo"),
],
visibility = ["PUBLIC"],
)