From 9e0ac5de34bbdb57cebc5dccf7005df9b15f548d Mon Sep 17 00:00:00 2001 From: Phil Culliton Date: Thu, 25 Apr 2024 11:16:34 -0700 Subject: [PATCH] Update Clif wrapper to work with latest gemma.cpp and add simple example PiperOrigin-RevId: 628134201 --- util/app.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/app.h b/util/app.h index 8161419..1a96c22 100644 --- a/util/app.h +++ b/util/app.h @@ -80,8 +80,7 @@ class AppArgs : public ArgsBase { void ChooseNumThreads() { if (num_threads == kDefaultNumThreads) { // This is a rough heuristic, replace with something better in the future. - num_threads = static_cast(std::clamp( - static_cast(std::thread::hardware_concurrency()) - 2, 1, 18)); + num_threads = GetSupportedThreadCount(); } } @@ -91,6 +90,11 @@ class AppArgs : public ArgsBase { ChooseNumThreads(); } + static inline size_t GetSupportedThreadCount() { + return static_cast(std::clamp( + static_cast(std::thread::hardware_concurrency()) - 2, 1, 18)); + } + Path log; // output int verbosity; size_t num_threads;