Commit 72d50b2
authored
Add EXECUTORCH_THREADPOOL_SIZE options, default to using only performance cores (#14090)
### Summary
Allow build-time configuration of the thread pool size and default to a
performance heuristic.
There are 2 modes that we want to support:
* Heuristic-based. Choose the number of threads according to a
performance heuristic. Use threads equal to the number of detected
performance cores, but we can continue to iterate on this by adding
fine-grained heuristics for specific chipsets in the future.
* All cores (threads=cores). This is the current behavior. We need to
maintain this as an option for some use cases.
With this PR, the default (for OSS) is to use performance cores. From
testing with CV models on ~10 representative devices across the
performance spectrum, this gives anywhere from parity with the existing
perf to up to a 13x speedup (measured on Pixel 6). Many common devices
(S20, S22, iPhone 15 Pro) show a 2-4x speedup.
#### Specifying Threadpool Size
To specify the threadpool size, I've added two preprocessor options (and
corresponding CMake options):
* `EXECUTORCH_THREADPOOL_USE_PERFORMANCE_CORES`- Use threads = detected
perf cores.
* `EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES` - Use threads = logical
cores.
### Test plan
I've verified that logic functions correctly in OSS by building the
executor_runner on M1 Mac and observing the existing logging in
cpuinfo_utils.
Measuring MobileNet V3 (exported from examples) on XNNPACK, time to run
100 iterations drops from ~450ms to ~230ms on M1 Pro with this change.1 parent f2eb38e commit 72d50b2
File tree
6 files changed
+101
-2
lines changed- extension/threadpool
- test
- tools/cmake/preset
6 files changed
+101
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
| |||
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
39 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| 117 | + | |
| 118 | + | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| |||
144 | 149 | | |
145 | 150 | | |
146 | 151 | | |
| 152 | + | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
| |||
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
| 183 | + | |
| 184 | + | |
176 | 185 | | |
177 | 186 | | |
178 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
20 | 38 | | |
21 | 39 | | |
22 | 40 | | |
| |||
96 | 114 | | |
97 | 115 | | |
98 | 116 | | |
| 117 | + | |
| 118 | + | |
99 | 119 | | |
100 | 120 | | |
101 | 121 | | |
102 | 122 | | |
103 | 123 | | |
104 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
105 | 136 | | |
106 | 137 | | |
107 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
17 | 33 | | |
18 | 34 | | |
19 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
179 | 209 | | |
180 | 210 | | |
181 | 211 | | |
| |||
0 commit comments