|
26 | 26 | #include <map> |
27 | 27 | #include <mutex> |
28 | 28 | #include <new> |
| 29 | +#include <vector> |
29 | 30 |
|
30 | 31 | #ifdef CA_HOST_ENABLE_PAPI_COUNTERS |
31 | 32 | #include <papi.h> |
@@ -95,17 +96,14 @@ struct thread_pool_s final { |
95 | 96 | /// @param[in] user_data User data to pass to the function. |
96 | 97 | /// @param[in] user_data2 A second user data to pass to the function. |
97 | 98 | /// @param[in] user_data3 A third user data to pass to the function. |
98 | | - /// @param[in,out] signals A list of bools that will be signalled when each |
| 99 | + /// @param[in,out] signals A vector of bools that will be signalled when each |
99 | 100 | /// slice of the enqueue range has completed. |
100 | 101 | /// @param[in,out] count A number that is incremented immediately, and |
101 | 102 | /// decremented when the enqueued function has completed. |
102 | 103 | /// @param[in] slices The number of pieces that the work is to be divided into |
103 | 104 | /// when it is enqueued on the thread pool. |
104 | | - /// |
105 | | - /// @tparam N Length of `signals`. |
106 | | - template <size_t N> |
107 | 105 | void enqueue_range(function_t function, void *user_data, void *user_data2, |
108 | | - std::array<std::atomic<bool>, N> &signals, |
| 106 | + std::vector<std::atomic<bool>> &signals, |
109 | 107 | std::atomic<uint32_t> *count, size_t slices) { |
110 | 108 | const tracer::TraceGuard<tracer::Impl> traceGuard(__func__); |
111 | 109 |
|
@@ -173,20 +171,15 @@ struct thread_pool_s final { |
173 | 171 | /// enqueue, wait() will wait for the counter to reach zero. |
174 | 172 | void wait(std::atomic<uint32_t> *count); |
175 | 173 |
|
176 | | - /// The maximum number of threads our thread pool supports. Useful for |
177 | | - /// allocating memory (you know the max size of allocations required). |
178 | | - static const size_t max_num_threads = 32; |
179 | | - |
180 | 174 | /// The maximum number of work that can be enqueued. |
181 | 175 | static const size_t queue_max = 4096; |
182 | 176 |
|
183 | | - /// The number of threads actually initialized in the thread pool. General |
184 | | - /// the lower of the number of cores or max_num_threads, but could be lower in |
185 | | - /// the presence of debug settings. |
| 177 | + /// The number of threads actually initialized in the thread pool. In General |
| 178 | + /// the number of cores, but could be lower in the presence of debug settings. |
186 | 179 | size_t initialized_threads; |
187 | 180 |
|
188 | 181 | /// The pool of threads to use for execution. |
189 | | - std::array<cargo::thread, max_num_threads> pool; |
| 182 | + std::vector<cargo::thread> pool; |
190 | 183 |
|
191 | 184 | /// The buffer to hold the queue of work. |
192 | 185 | std::array<thread_pool_work_item_s, queue_max> queue; |
|
0 commit comments