Repository navigation
Fix the OpenCL CPU compiler crash in the one-work-group radix sort - #3191
Open
ndgrigorian wants to merge 2 commits into
Open
ndgrigorian wants to merge 2 commits into
ndgrigorian wants to merge 2 commits into
Conversation
…ices rather than synchronize the work-group On a CPU device whose kernel takes sub-groups shorter than 16, each counter update was followed by a group_barrier, the work-around of CMPLRLLVM-64592 (int8 radix argsort comes out unstable). With 16 or more elements per work-item, from rows of 2049 elements, these barriers crash the OpenCL CPU compiler in its sycl-kernel-reduce-cross-barrier-values pass, so dpnp.sort and dpnp.argsort of such rows segfault; bool, int8, uint8, int16 and uint16 take the radix sort by default. Seen with every OpenCL CPU runtime from 2024.18 to 2026.22. A work-group fence in place of the barrier still keeps int8 argsort stable and adds no barrier region, so the compiler no longer crashes. Sort and argsort of all integer and floating data types are correct on the same runtimes, and GPU timings are unchanged since GPUs don't take the work-around.
ndgrigorian
requested review from
antonwolfy and
vlad-perevezentsev
as code owners
November 16, 2026 22:07
antonwolfy
reviewed
Nov 16, 2026
| // due to a bug in CPU device implementation, an additional | ||
| // synchronization is necessary for short sub-group sizes | ||
| // the CPU device compiler miscompiles the counting for short | ||
| // sub-groups unless each update is fenced (CMPLRLLVM-64592); a |
Contributor
There was a problem hiding this comment.
Is it the same as CMPLRLLVM-79305?
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3191/index.html |
Contributor
|
Array API standard conformance tests for dpnp=0.22.0dev2=np2py314h8d9cdd5_8 ran successfully. |
Collaborator
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a crash of the OpenCL CPU compiler in the one-work-group radix sort, which
dpnp.sort,dpnp.argsortand theirdpnp.tensorcounterparts take for rows of 2049 to 16384 elements. Radix sort is the default forbool,int8,uint8,int16anduint16, so a plaindpnp.sortof such rows can segfault on a CPU device, for exampledpt.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
int8kernels on an AVX2 CPU), the kernel puts agroup_barrierafter 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 itssycl-kernel-reduce-cross-barrier-valuespass (copyAndReplaceUses). Which data types crash depends on the compiler's heap state; once,int64hung instead. The crash shows up with every OpenCL CPU runtime from 2024.18 (intel-opencl-rt2025.0.4) to 2026.22 (2026.2.0).The work-around is still needed: without it, the
int8radix argsort is unstable on the same runtimes. This PR replaces the barrier with a work-groupatomic_fence. That keeps theint8argsort 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,float32andfloat64matchstd::sort/std::stable_sortin 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_groupcovers rows of 257 to 16384 elements. Without the fix it segfaults onopencl:cpuforint8,uint8andint32, andint64times out; with it, it passes onopencl:cpuandlevel_zero:gpu, as do the sorting,top_kanduniquetests.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 onopencl:cpu, at sizes the old build compiles.