|
6 | 6 | * LICENSE file in the root directory of this source tree. |
7 | 7 | */ |
8 | 8 |
|
9 | | -#include <executorch/extension/threadpool/cpuinfo_utils.h> |
10 | 9 | #include <executorch/extension/threadpool/threadpool.h> |
11 | 10 |
|
12 | 11 | #include <algorithm> |
|
15 | 14 |
|
16 | 15 | #include <executorch/extension/threadpool/threadpool_guard.h> |
17 | 16 | #include <executorch/runtime/platform/assert.h> |
18 | | -#include <executorch/runtime/platform/runtime.h> |
19 | 17 |
|
20 | 18 | #include <cpuinfo.h> |
21 | 19 |
|
22 | | -// At most one mode should be set. |
23 | | -#if ( \ |
24 | | - defined(EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES) && \ |
25 | | - defined(EXECUTORCH_THREADPOOL_USE_PERFORMANCE_CORES)) |
26 | | -#error Multiple \ |
27 | | - threadpool size specifiers are set.At most one of \ |
28 | | - EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES, \ |
29 | | - and EXECUTORCH_THREADPOOL_USE_PERFORMANCE_CORES may be defined. |
30 | | -#endif |
31 | | - |
32 | | -// Default to EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES if no mode is set. |
33 | | -#if !defined(EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES) && \ |
34 | | - !defined(EXECUTORCH_THREADPOOL_USE_PERFORMANCE_CORES) |
35 | | -#define EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES 1 |
36 | | -#endif |
37 | | - |
38 | 20 | namespace executorch::extension::threadpool { |
39 | 21 |
|
40 | 22 | #if !(defined(WIN32)) |
@@ -114,25 +96,12 @@ void ThreadPool::run( |
114 | 96 | // get_threadpool is not thread safe due to leak_corrupted_threadpool |
115 | 97 | // Make this part threadsafe: TODO(kimishpatel) |
116 | 98 | ThreadPool* get_threadpool() { |
117 | | - executorch::runtime::runtime_init(); |
118 | | - |
119 | 99 | if (!cpuinfo_initialize()) { |
120 | 100 | ET_LOG(Error, "cpuinfo initialization failed"); |
121 | 101 | return nullptr; // NOLINT(facebook-hte-NullableReturn) |
122 | 102 | } |
123 | 103 |
|
124 | | - // Choose the number of threads according to the EXECUTORCH_THREADPOOL_ |
125 | | - // options. See the description in threadpool.h. |
126 | | - |
127 | | -#if defined(EXECUTORCH_THREADPOOL_USE_ALL_LOGICAL_CORES) |
128 | | - // Use threads=cores. |
129 | | - static int num_threads = cpuinfo_get_processors_count(); |
130 | | -#else |
131 | | - // Set threads equal to the number of performance cores. |
132 | | - static int num_threads = |
133 | | - ::executorch::extension::cpuinfo::get_num_performant_cores(); |
134 | | -#endif |
135 | | - |
| 104 | + int num_threads = cpuinfo_get_processors_count(); |
136 | 105 | /* |
137 | 106 | * For llvm-tsan, holding limit for the number of locks for a single thread |
138 | 107 | * is 63 (because of comparison < 64 instead of <=). pthreadpool's worst |
|
0 commit comments