fix(knn): replace _bit_scan_forward with __builtin_ctz in the kd-tree median search #4009
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 363 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.353
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4009"
general
weight: 0.35
david-cortes-intel
Description
Newer icx releases fail to compile the kd-tree kNN training kernel on Windows:
_bit_scan_forwardis not a standard intrinsic. In clang and icx it is a macro defined only inia32intrin.h, which is included through<x86intrin.h>; upstream LLVM's andintel/llvm's<immintrin.h>do not include it. The file includes only<immintrin.h>and compiled so far because earlier icx headers pulledia32intrin.hin from<immintrin.h>.Both uses, in the AVX2 float path of
computeBucketID(the lower-bound search behind the approximate median of a kd-tree split), now call__builtin_ctz(maskInt). It is a compiler builtin, so it needs no header, and icx accepts it on Linux and Windows.maskIntis already computed and checked non-zero on both lines, so the result is the same index_bit_scan_forwardreturned, and the generated code is the sametzcnt. These were the only two uses in the repository.Testing
The failure cannot be reproduced with the icx on hand, so there is no regression test; the compiler check is the test. Evidence:
ia32intrin.hfrom<immintrin.h>),-march=haswell -fsyntax-onlyreproduces the error on bothx86_64-unknown-linux-gnuandx86_64-pc-windows-msvcfor the old code and compiles the new code.make -f makefile daal PLAT=lnx32e COMPILER=icx REQCPU=avx2builds; the rebuilt..._fpt_flt_cpu_hsw.ohasvmovmskps+tzcntincomputeBucketID.bazel test --config=host //cpp/oneapi/dal/algo/knn:tests: 5 of 5 pass.---
<details>
<summary>Checklist:</summary>
Completeness and readability
Testing
Performance
</details>
🤖 Generated with Claude Code