From 9c9523fd0f20ea137bc8789674ec27fefc3ea2d6 Mon Sep 17 00:00:00 2001 From: Iwan Kawrakow Date: Sun, 21 Jan 2024 12:53:59 +0200 Subject: [PATCH] Make MSVC happy I had forgotten that MSVC does not make constexpr's available inside a lambda. --- examples/perplexity/perplexity.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/perplexity/perplexity.cpp b/examples/perplexity/perplexity.cpp index ed0305fb5..b7ef9a084 100644 --- a/examples/perplexity/perplexity.cpp +++ b/examples/perplexity/perplexity.cpp @@ -1196,26 +1196,25 @@ static void multiple_choice_score(llama_context * ctx, const gpt_params & params if (n_task > 500) { printf("..."); fflush(stdout); - constexpr int k_chunk = 4; std::atomic counter(0); std::atomic n_bad(0); auto prepare = [&counter, &n_bad, &tasks, ctx, add_bos] () { int num_tasks = tasks.size(); int n_bad_local = 0; while (true) { - int first = counter.fetch_add(k_chunk); + int first = counter.fetch_add(K_TOKEN_CHUNK); if (first >= num_tasks) { if (n_bad_local > 0) n_bad += n_bad_local; break; } - int last = std::min(first + k_chunk, num_tasks); + int last = std::min(first + K_TOKEN_CHUNK, num_tasks); for (int i = first; i < last; ++i) { if (!multiple_choice_prepare_one_task(ctx, add_bos, tasks[i], false)) ++n_bad_local; } } }; size_t max_thread = std::thread::hardware_concurrency(); - max_thread = std::min(max_thread, (tasks.size() + k_chunk - 1)/k_chunk); + max_thread = std::min(max_thread, (tasks.size() + K_TOKEN_CHUNK - 1)/K_TOKEN_CHUNK); std::vector workers(max_thread-1); for (auto& w : workers) w = std::thread(prepare); prepare();