From 6b12c2e7e8c9f8e6925ff8d9e7ebd5231bb9e6ef Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Fri, 23 May 2025 16:46:27 +0300 Subject: Fix MSVC compilation (#448) * Fix MSVC compilation * MSVC cannot capture constexpr in lambdas * Arghhh --------- Co-authored-by: Iwan Kawrakow --- examples/quantize-stats/quantize-stats.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'examples/quantize-stats/quantize-stats.cpp') diff --git a/examples/quantize-stats/quantize-stats.cpp b/examples/quantize-stats/quantize-stats.cpp index 3a37f72c..d1598aec 100644 --- a/examples/quantize-stats/quantize-stats.cpp +++ b/examples/quantize-stats/quantize-stats.cpp @@ -550,6 +550,10 @@ static void analyze_x_v2(const char * name, int nrows, int n_per_row, const floa int counter = 0; float mse = 0, mse_q = 0; auto compute = [&mutex, &counter, &mse, &mse_q, values, nrows, n_per_row, chunk] () { + constexpr int kNumVal = 1 << 15; + constexpr int kBlockSize = 32; + constexpr int kGroupSize = 8; + constexpr int kNg = kBlockSize/kGroupSize; double lmse = 0, lmse_q = 0; std::vector scales(n_per_row/kBlockSize); std::vector best_idx(n_per_row/kGroupSize); @@ -689,9 +693,8 @@ static void analyze_x_v2(const char * name, int nrows, int n_per_row, const floa } } }; - std::vector workers(nthread-1); + std::vector workers(nthread); for (auto& w : workers) w = std::thread(compute); - compute(); for (auto& w : workers) w.join(); tot_mse += mse; tot_mse_q += mse_q; @@ -718,6 +721,8 @@ static void analyze_x(const char * name, int nrows, int n_per_row, const float * int counter = 0; float mse = 0, mse_q = 0; auto compute = [&mutex, &counter, &mse, &mse_q, &codes, &sumq2i, values, nrows, n_per_row, chunk] () { + constexpr int kBlockSize = 8; + constexpr int kNumVal = 1 << 12; float lmse = 0, lmse_q = 0; std::vector scales(n_per_row/kBlockSize); std::vector best_idx(n_per_row/kBlockSize); @@ -816,9 +821,8 @@ static void analyze_x(const char * name, int nrows, int n_per_row, const float * } } }; - std::vector workers(nthread-1); + std::vector workers(nthread); for (auto& w : workers) w = std::thread(compute); - compute(); for (auto& w : workers) w.join(); tot_mse += mse; tot_mse_q += mse_q; -- cgit v1.2.3