|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | #include <executorch/extension/threadpool/threadpool.h>
|
| 10 | +#include <executorch/runtime/platform/runtime.h> |
10 | 11 |
|
11 | 12 | #include <mutex>
|
12 | 13 | #include <numeric>
|
@@ -71,6 +72,8 @@ void run_lambda_with_size(
|
71 | 72 | } // namespace
|
72 | 73 |
|
73 | 74 | TEST(ThreadPoolTest, ParallelAdd) {
|
| 75 | + executorch::runtime::runtime_init(); |
| 76 | + |
74 | 77 | std::vector<int32_t> a, b, c, c_ref;
|
75 | 78 | size_t vector_size = 100;
|
76 | 79 | size_t grain_size = 10;
|
@@ -111,6 +114,8 @@ TEST(ThreadPoolTest, ParallelAdd) {
|
111 | 114 |
|
112 | 115 | // Test parallel reduction where we acquire lock within lambda
|
113 | 116 | TEST(ThreadPoolTest, ParallelReduce) {
|
| 117 | + executorch::runtime::runtime_init(); |
| 118 | + |
114 | 119 | std::vector<int32_t> a;
|
115 | 120 | int32_t c = 0, c_ref = 0;
|
116 | 121 | size_t vector_size = 100;
|
@@ -144,6 +149,8 @@ TEST(ThreadPoolTest, ParallelReduce) {
|
144 | 149 | // Copied from
|
145 | 150 | // caffe2/aten/src/ATen/test/test_thread_pool_guard.cp
|
146 | 151 | TEST(TestNoThreadPoolGuard, TestThreadPoolGuard) {
|
| 152 | + executorch::runtime::runtime_init(); |
| 153 | + |
147 | 154 | auto threadpool_ptr = ::executorch::extension::threadpool::get_pthreadpool();
|
148 | 155 |
|
149 | 156 | ASSERT_NE(threadpool_ptr, nullptr);
|
@@ -173,6 +180,8 @@ TEST(TestNoThreadPoolGuard, TestThreadPoolGuard) {
|
173 | 180 | }
|
174 | 181 |
|
175 | 182 | TEST(TestNoThreadPoolGuard, TestRunWithGuard) {
|
| 183 | + executorch::runtime::runtime_init(); |
| 184 | + |
176 | 185 | const std::vector<int64_t> array = {1, 2, 3};
|
177 | 186 |
|
178 | 187 | auto pool = ::executorch::extension::threadpool::get_threadpool();
|
|
0 commit comments