summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKawrakow <iwankawrakow@gmail.com>2025-05-23 16:46:27 +0300
committerGitHub <noreply@github.com>2025-05-23 16:46:27 +0300
commit6b12c2e7e8c9f8e6925ff8d9e7ebd5231bb9e6ef (patch)
treeeb738fbaf619909dcb86de4372960131b4415160 /examples
parent7f2edd1a85044b407a6d4f2ad2ea4911598ddb66 (diff)
Fix MSVC compilation (#448)
* Fix MSVC compilation * MSVC cannot capture constexpr in lambdas * Arghhh --------- Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quantize-stats/quantize-stats.cpp12
1 files changed, 8 insertions, 4 deletions
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<float> scales(n_per_row/kBlockSize);
std::vector<int> 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<std::thread> workers(nthread-1);
+ std::vector<std::thread> 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<float> scales(n_per_row/kBlockSize);
std::vector<int> 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<std::thread> workers(nthread-1);
+ std::vector<std::thread> 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;