← Back to Pull requests

Fix the OpenCL CPU compiler crash in the one-work-group radix sort #3191

Open
unknown opened this pull request with 327 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 16, 2026 22:07 UTC
Author

This PR fixes a crash of the OpenCL CPU compiler in the one-work-group radix sort, which dpnp.sort, dpnp.argsort and their dpnp.tensor counterparts take for rows of 2049 to 16384 elements. Radix sort is the default for bool, int8, uint8, int16 and uint16, so a plain dpnp.sort of such rows can segfault on a CPU device, for example dpt.sort(dpt.zeros((1, 4096), dtype="i1", device="opencl:cpu")).

On a CPU device whose kernel gets sub-groups shorter than 16 (8 for the int8 kernels on an AVX2 CPU), the kernel puts a group_barrier after every unrolled counter update. That is the work-around for CMPLRLLVM-64592, added in IntelPython/dpctl@5125e11eb4. With 16 or more elements per work-item, those barriers crash the compiler in its sycl-kernel-reduce-cross-barrier-values pass (copyAndReplaceUses). Which data types crash depends on the compiler's heap state; once, int64 hung instead. The crash shows up with every OpenCL CPU runtime from 2024.18 (intel-opencl-rt 2025.0.4) to 2026.22 (2026.2.0).

The work-around is still needed: without it, the int8 radix argsort is unstable on the same runtimes. This PR replaces the barrier with a work-group atomic_fence. That keeps the int8 argsort stable, adds no barrier region, and so no longer crashes the compiler.

With a standalone SYCL reproducer, sort and stable argsort of bool, int8, uint8, int16, uint16, int32, int64, float32 and float64 match std::sort/std::stable_sort in both orders. That covers 1, 37 and 300 rows of every one-work-group size class, with full-range and low-cardinality data, on seven OpenCL CPU runtimes from 2025.0.4 to 2026.2.0. test_radix_sort_one_work_group covers rows of 257 to 16384 elements. Without the fix it segfaults on opencl:cpu for int8, uint8 and int32, and int64 times out; with it, it passes on opencl:cpu and level_zero:gpu, as do the sorting, top_k and unique tests.

GPUs don't take the work-around. Sort and argsort timings alternated between the two builds show no difference beyond noise on the iGPU (level_zero:gpu) or on opencl:cpu, at sizes the old build compiles.

  • Have you provided a meaningful PR description?

  • Have you added a test, reproducer or referred to an issue with a reproducer?

  • Have you tested your changes locally for CPU and GPU devices?

  • Have you made sure that new changes do not introduce compiler warnings?

  • Have you checked performance impact of proposed changes?

  • Have you added documentation for your changes, if necessary?

  • Have you added your changes to the changelog?
  • Diff: 327 lines (+245 / -82) across 4 files Reviewer: antonwolfy Review duration: 1030m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 327 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.347
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3191"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42% (MEDIUM) · Higher = larger blast radius
    42%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%