Skip to content

Commit

Permalink
Follow the maximum number of threads limit in gemma.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ufownl committed Jun 15, 2024
1 parent e988a30 commit 88bcfb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/scheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "scheduler.hpp"
#include <util/app.h>
#include <algorithm>
#include <thread>

namespace {
Expand All @@ -21,7 +22,12 @@ int destroy(lua_State* L) {
namespace cgemma {

scheduler::scheduler()
: pool_(std::thread::hardware_concurrency()) {
: pool_(std::min(static_cast<size_t>(std::thread::hardware_concurrency()), gcpp::kMaxThreads)) {
// nop
}

scheduler::scheduler(size_t num_threads)
: pool_(std::min(num_threads, gcpp::kMaxThreads)) {
// nop
}

Expand Down
2 changes: 1 addition & 1 deletion src/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace cgemma {
class scheduler {
public:
scheduler();
explicit scheduler(size_t num_threads) : pool_(num_threads) {}
explicit scheduler(size_t num_threads);

hwy::ThreadPool& pool() { return pool_; }

Expand Down

0 comments on commit 88bcfb3

Please sign in to comment.