Skip to content

Commit

Permalink
[SRV-225] standardize thread pool size (#454)
Browse files Browse the repository at this point in the history
# Changes

See: swift-nav/ThreadPool#2 for background
information.

The changes here make it so that the thread size is explicit and avoids
stack overflow as the stack size differs between platform. This fixes
issues on MacOS, among other systems.
  • Loading branch information
RReichert authored Sep 20, 2023
1 parent 1a3ede9 commit 6c05a0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions include/albatross/src/utils/async_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,14 @@ static constexpr std::nullptr_t serial_thread_pool = nullptr;
// Returns a thread pool. By default, the thread pool has
// `get_default_thread_count()` threads.
inline std::shared_ptr<ThreadPool>
make_shared_thread_pool(std::size_t threads = 0) {
if (threads == 1) {
make_shared_thread_pool(std::size_t num_threads = 0,
std::size_t stack_size = 0) {
if (num_threads == 1) {
return serial_thread_pool;
}

if (threads < 1) {
threads = get_default_thread_count();
if (num_threads < 1) {
num_threads = get_default_thread_count();
}

#if defined(EIGEN_USE_MKL_ALL) || defined(EIGEN_USE_MKL_VML)
Expand All @@ -216,7 +217,7 @@ make_shared_thread_pool(std::size_t threads = 0) {
const auto init = []() {};
#endif // EIGEN_USE_MKL_ALL || EIGEN_USE_MKL_VML

return std::make_shared<ThreadPool>(threads, init);
return std::make_shared<ThreadPool>(num_threads, init, stack_size);
}

inline std::size_t get_thread_count(const std::shared_ptr<ThreadPool> &pool) {
Expand Down
2 changes: 1 addition & 1 deletion third_party/ThreadPool
Submodule ThreadPool updated 1 files
+45 −17 ThreadPool.h

0 comments on commit 6c05a0a

Please sign in to comment.