From b1a9d731bfd344e6844bf8308bd2eeb6947cd735 Mon Sep 17 00:00:00 2001 From: Cary Palmer <24235924+professorpalmer@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:19:10 -0500 Subject: [PATCH] tests: portable popcount in arclab_init_hadamard (MSVC has no __builtin_popcountll) --- tests/test-backend-ops.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp index bb39c3de59e5..11c5b61fe3bd 100644 --- a/tests/test-backend-ops.cpp +++ b/tests/test-backend-ops.cpp @@ -5062,13 +5062,23 @@ struct test_fwht_signed : public test_case { // shapes / token counts, and compares the fused outputs against the CPU backend. The graph's final node only keeps every // output alive; its operand order makes the graph come out in the model's node order. `seed` repeats a case with fresh // random data. Run with GGML_SYCL_PTQ1_T2=all so the ternary weights take the T2 (XMX) path the fusions feed. +// portable popcount (MSVC has no __builtin_popcountll) +static int arclab_popcount64(uint64_t x) { + int c = 0; + while (x) { + x &= x - 1; + c++; + } + return c; +} + static void arclab_init_hadamard(ggml_tensor * t) { const int64_t n = t->ne[0]; std::vector data(n * n); const float scale = 1.0f / sqrtf((float) n); for (int64_t r = 0; r < n; r++) { for (int64_t i = 0; i < n; i++) { - data[r * n + i] = (__builtin_popcountll((unsigned long long) (r & i)) % 2 == 0) ? scale : -scale; + data[r * n + i] = (arclab_popcount64((uint64_t) (r & i)) % 2 == 0) ? scale : -scale; } } ggml_backend_tensor_set(t, data.data(), 0, data.size() * sizeof(float));